Don't close config file when changing preferences

On Linux and MacOS the subsurface_close_conf() doesn't really close the
config file (it flushes writes on MacOS), but on Windows it does
actually close the registry hkey.

Which is bad, if you change the settings multiple times - we assume that
the config file is open the whole time.

So add a "subsurface_flush_conf()" function, and call *that* when
changing configuration parameters.  And call the close function only at
the very end.

Alternatively, maybe we should just open the config file separately
every time. I don't much care, maybe somebody else does.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Linus Torvalds 2012-05-02 10:03:48 -07:00
parent 2d1a316d84
commit 725e4582d9
7 changed files with 28 additions and 3 deletions

View file

@ -59,13 +59,18 @@ const void *subsurface_get_conf(char *name, pref_type_t type)
return NULL;
}
void subsurface_close_conf(void)
void subsurface_flush_conf(void)
{
int ok = CFPreferencesAppSynchronize(SUBSURFACE_PREFERENCES);
if (!ok)
fprintf(stderr,"Could not save preferences\n");
}
void subsurface_close_conf(void)
{
/* Nothing */
}
const char *subsurface_USB_name()
{
return "/dev/tty.SLAB_USBtoUART";