Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QFile permission not reporting correctly
Qt 6.11 is out! See what's new in the release blog

QFile permission not reporting correctly

Scheduled Pinned Locked Moved Solved General and Desktop
19 Posts 6 Posters 4.7k Views 4 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ocgltdO ocgltd

    @JonB Yeah, if I changed via command line and Qt didn't see the change then I would suspect a cache. But if writing permissions from Qt I would expect it to update any Qt cache. I would have guess bug, but both QFile and QFileInfo suffering from the same bug makes me think I'm doing something wrong

    JonBJ Offline
    JonBJ Offline
    JonB
    wrote on last edited by JonB
    #9

    @ocgltd , @sierdzio
    I checked this on my Ubuntu 20.04, Qt5.15, and it does indeed behave as you say. So then I looked and found bug QFile::permissions() returns old, cached value after call to QFile::setPermissions() on the same QFile object, Qt 4.6, Unresolved:

    I can understand why QFile would not detect changes to the file's permissions outside of the QFile object, although if the permissions
    change is done via QFile::setPermissions() then the object can clear its cached value automatically.
    Alternatively, the fact that permissions() returns a cached value should be documented.

    A related issue is that there is no explicit refresh() method for QFile as there is for QFileInfo, although QFile::exists() does trigger a refresh when called

    This task is old and has been idle for a long time. It is therefore being closed on the assumption that it will not be addressed in the foreseeable future. If you really do care about this task, you may reopen it and vote for it.

    It was created in 2010 and last updated in 2016. We agree it's a bit bad. You will have to use some alternative, e.g. maybe the static QFile permissions methods work, or the QFileInfo ones.

    1 Reply Last reply
    1
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #10

      Oh my, this should have been fixed, not closed :o

      (Z(:^

      1 Reply Last reply
      1
      • Christian EhrlicherC Offline
        Christian EhrlicherC Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #11

        Reopened: https://bugreports.qt.io/browse/QTBUG-7211

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        1 Reply Last reply
        3
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #12

          Thanks! Voted.

          (Z(:^

          1 Reply Last reply
          0
          • Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #13

            There is also already a patch for it... sometimes it's interesting to see how long bugs linger around and then a small change (here: chooinsg the correct maintainer) suddenly fixes it :)

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            1 Reply Last reply
            1
            • HoMaH Offline
              HoMaH Offline
              HoMa
              wrote on last edited by
              #14

              I guess you can just use the static function!?

              JonBJ 1 Reply Last reply
              0
              • HoMaH HoMa

                I guess you can just use the static function!?

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by JonB
                #15

                @HoMa
                I suggested earlier that the OP could try that, but there is no guarantee it will behave any differently. The cache may be by filepath, not by QFile/QFileInfo instance, we don't know.

                HoMaH 1 Reply Last reply
                0
                • JonBJ JonB

                  @HoMa
                  I suggested earlier that the OP could try that, but there is no guarantee it will behave any differently. The cache may be by filepath, not by QFile/QFileInfo instance, we don't know.

                  HoMaH Offline
                  HoMaH Offline
                  HoMa
                  wrote on last edited by
                  #16

                  @JonB Sorry - I missed that.

                  JonBJ 1 Reply Last reply
                  0
                  • HoMaH HoMa

                    @JonB Sorry - I missed that.

                    JonBJ Offline
                    JonBJ Offline
                    JonB
                    wrote on last edited by JonB
                    #17

                    @HoMa Not a problem :) I'm just saying it may or may not make any difference! But worth a try.

                    ocgltdO 1 Reply Last reply
                    0
                    • JonBJ JonB

                      @HoMa Not a problem :) I'm just saying it may or may not make any difference! But worth a try.

                      ocgltdO Offline
                      ocgltdO Offline
                      ocgltd
                      wrote on last edited by
                      #18

                      @JonB I'll use the workaround thanks. I couldn't imagine I found such a bug..so I assumed it must be my code.

                      JonBJ 1 Reply Last reply
                      0
                      • ocgltdO ocgltd

                        @JonB I'll use the workaround thanks. I couldn't imagine I found such a bug..so I assumed it must be my code.

                        JonBJ Offline
                        JonBJ Offline
                        JonB
                        wrote on last edited by
                        #19

                        @ocgltd said in QFile permission not reporting correctly:

                        I couldn't imagine I found such a bug.

                        You produced a simple example, minimal code, clear output to show bad behaviour. If everybody did similar that would be really great :)

                        1 Reply Last reply
                        1

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved