Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QSettings .plist file not present?
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.
mpergand last edited by
What happens if you do:
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.
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".
mpergand last edited by
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.
@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.
r2d3 last edited by
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