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. QSettings .plist file not present?
Qt 6.11 is out! See what's new in the release blog

QSettings .plist file not present?

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 4 Posters 1.3k Views 3 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.
  • artwawA Offline
    artwawA Offline
    artwaw
    wrote on last edited by
    #1

    Dear all,
    I run into peculiar issue using QSettings in native mode on macOS.

    I set domain etc. using QCoreApplication static calls in main() and it usually works fine. Using qDebug() and QSettings::fileName() I know that my file is located in ~/Library/Preferences/ and named com.mydomain.something. No issues with that.

    But during the development I wanted to erase the config file to trigger my ZeroConfig() method - I wrote it so the program can properly initialise itself with default values. But... after erasing the file the program still reads the modified values from QSettings (still pointing to the file that no longer exists!).

    I even implemented check using QFile that tells me the file does not exists but settings are still read from what QSettings claims is the actual file. Which doesn't exist anymore.

    Restarting the machine helps so I assume that file still is cached somewhere. This happens on macOS only (tried out of curiosity Windows 10 and Debian 10). Any advice please? Restarting machine is somehow... inconvenient.

    For more information please re-read.

    Kind Regards,
    Artur

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mpergand
      wrote on last edited by
      #2

      Hi,

      What happens if you do:

      QSettings().clear();
      QSettings().sync();
      
      1 Reply Last reply
      0
      • artwawA Offline
        artwawA Offline
        artwaw
        wrote on last edited by
        #3

        Clear file (according to debug info) is created. I've been there.
        There is also delay (sometimes even 30 minutes!) before clear/new file appears in the Preferences folder. I've managed to overcome this for now by forcing QSettings::IniFormat as a temporary solution.

        I came to conclusion that with update to Catalina something changed in the guts of the system and this hopefully will be reflected in future releases to Qt. I might be wrong though, hence the topic here.

        For more information please re-read.

        Kind Regards,
        Artur

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,

          IIRC, macOS has a settings cache. I don't know whether its handling has changed with recent version of macOS but I do remember some similar troubles at some point but I don't remember exactly how it coud be "force cleaned".

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          artwawA 1 Reply Last reply
          1
          • M Offline
            M Offline
            mpergand
            wrote on last edited by
            #5

            Maybe your can try this in the terminal:
            defaults delete yourDomain

            The other way is to kill the pref manager in the Monitor.app.
            I'm using an old version of OSX (10.9) the name of the process to kill is "cfprefsd" , but maybe this name has changed since then.

            1 Reply Last reply
            1
            • SGaistS SGaist

              Hi,

              IIRC, macOS has a settings cache. I don't know whether its handling has changed with recent version of macOS but I do remember some similar troubles at some point but I don't remember exactly how it coud be "force cleaned".

              artwawA Offline
              artwawA Offline
              artwaw
              wrote on last edited by
              #6

              @SGaist Thank you, will keep that in mind. QSettings::IniFormat works so far, I'd just prefer to use native settings per platform. Seems... cleaner approach.

              @mpergand I could. However this approach is a no-go from the final user perspective in case the settings are not synchronised immediately. Thank you for your suggestion, it seems valid when I think of it, but not useful in the longer shot.

              For more information please re-read.

              Kind Regards,
              Artur

              R 1 Reply Last reply
              0
              • artwawA artwaw

                @SGaist Thank you, will keep that in mind. QSettings::IniFormat works so far, I'd just prefer to use native settings per platform. Seems... cleaner approach.

                @mpergand I could. However this approach is a no-go from the final user perspective in case the settings are not synchronised immediately. Thank you for your suggestion, it seems valid when I think of it, but not useful in the longer shot.

                R Offline
                R Offline
                r2d3
                wrote on last edited by
                #7

                NSDefaults are cached on recent macOS. If you want to get rid of the defaults, you could use the "defaults" command line tool.

                defaults delete com.mycompany.myapp
                

                Regards

                David

                1 Reply Last reply
                0

                • Login

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