[Mac] Avoiding creating .plist file for all wx applications?

41 views
Skip to first unread message

Vadim Zeitlin

unread,
Nov 22, 2016, 10:51:10 AM11/22/16
to wx-dev
Hello,

I hadn't realized this when applying this patch, but the commit 534899ba
(https://github.com/wxWidgets/wxWidgets/commit/534899baa28940692f8ae639896b2009f688e981)
resulted in a .plist file with NSTreatUnknownArgumentsAsOpen=NO
automatically created in ~/Library/Preferences for any wxWidgets
application.

It's not really catastrophic, of course, but it does seem strange to
litter the user preferences directory like this. Is there really no way to
avoid it?

Thanks in advance for any ideas,
VZ

Václav Slavík

unread,
Nov 22, 2016, 11:07:20 AM11/22/16
to wx-...@googlegroups.com
Hi,

> It's not really catastrophic, of course, but it does seem strange to
> litter the user preferences directory like this. Is there really no way to
> avoid it?

I’m not sure if it’s worth bothering with, because it seems libraries will write stuff there too (I can see e.g. NSFontPanelAttributes or NSFontPanelPreviewHeight that I don’t remember writing explicitly in my plist). I’d consider it a worse problem that the written setting is sticky and once set, even an update that removes this code won’t remove it.

You should be able to make it ephemeral by registering these defaults early from a dictionary (using Obj-C 2.0 syntax and not tested):

NSDictionary *defaults = @{
@"NSTreatUnknownArgumentsAsOpen": @NO // or @"NO" as in the commit
};
[[NSUserDefaults standardUserDefaults] registerDefaults:defaults];

Note that plist values will overwrite any values set like this.

Regards,
Václav

Vadim Zeitlin

unread,
Nov 22, 2016, 11:51:49 AM11/22/16
to wx-...@googlegroups.com
On Tue, 22 Nov 2016 17:07:16 +0100 Václav Slavík wrote:

VS> > It's not really catastrophic, of course, but it does seem strange to
VS> > litter the user preferences directory like this. Is there really no way to
VS> > avoid it?
VS>
VS> I’m not sure if it’s worth bothering with, because it seems libraries
VS> will write stuff there too (I can see e.g. NSFontPanelAttributes or
VS> NSFontPanelPreviewHeight that I don’t remember writing explicitly in my
VS> plist). I’d consider it a worse problem that the written setting is
VS> sticky and once set, even an update that removes this code won’t remove
VS> it.

Yes, this is true as well, although it's difficult to imagine a situation
when we would want to set this option to "YES".

VS> You should be able to make it ephemeral by registering these defaults
VS> early from a dictionary (using Obj-C 2.0 syntax and not tested):
VS>
VS> NSDictionary *defaults = @{
VS> @"NSTreatUnknownArgumentsAsOpen": @NO // or @"NO" as in the commit
VS> };
VS> [[NSUserDefaults standardUserDefaults] registerDefaults:defaults];

Interesting, thanks, I'd definitely prefer to do it like this. But while
preparing to make this change, I realized I didn't have any test case for
the problem and my attempts to make one just failed, see
http://trac.wxwidgets.org/ticket/14558#comment:8

So now the question becomes: what exactly is the problem and does it still
exist in modern OS X versions? Maybe the best thing to do would be to just
revert 534899b?

Regards,
VZ
Reply all
Reply to author
Forward
0 new messages