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>
extern void subsurface_open_conf(void);
extern void subsurface_set_conf(char *name, pref_type_t type, const void *value);
extern const void *subsurface_get_conf(char *name, pref_type_t type);
extern void subsurface_open_conf(void);
extern void subsurface_set_conf(char *name, pref_type_t type, const void *value);
extern const void *subsurface_get_conf(char *name, pref_type_t type);
+extern void subsurface_flush_conf(void);
extern void subsurface_close_conf(void);
extern const char *subsurface_USB_name(void);
extern void subsurface_close_conf(void);
extern const char *subsurface_USB_name(void);
extern void init_ui(int *argcp, char ***argvp);
extern void run_ui(void);
extern void init_ui(int *argcp, char ***argvp);
extern void run_ui(void);
+extern void exit_ui(void);
extern void report_error(GError* error);
extern void report_error(GError* error);
subsurface_set_conf("SAC", PREF_BOOL, BOOL_TO_PTR(visible_cols.sac));
subsurface_set_conf("OTU", PREF_BOOL, BOOL_TO_PTR(visible_cols.otu));
subsurface_set_conf("divelist_font", PREF_STRING, divelist_font);
subsurface_set_conf("SAC", PREF_BOOL, BOOL_TO_PTR(visible_cols.sac));
subsurface_set_conf("OTU", PREF_BOOL, BOOL_TO_PTR(visible_cols.otu));
subsurface_set_conf("divelist_font", PREF_STRING, divelist_font);
- subsurface_close_conf();
+
+ /* Flush the changes out to the system */
+ subsurface_flush_conf();
}
gtk_widget_destroy(dialog);
}
}
gtk_widget_destroy(dialog);
}
+void exit_ui(void)
+{
+ subsurface_close_conf();
+}
+
typedef struct {
cairo_rectangle_int_t rect;
const char *text;
typedef struct {
cairo_rectangle_int_t rect;
const char *text;
+void subsurface_flush_conf(void)
+{
+ /* this is a no-op */
+}
+
void subsurface_close_conf(void)
{
/* this is a no-op */
void subsurface_close_conf(void)
{
/* this is a no-op */
-void subsurface_close_conf(void)
+void subsurface_flush_conf(void)
{
int ok = CFPreferencesAppSynchronize(SUBSURFACE_PREFERENCES);
if (!ok)
fprintf(stderr,"Could not save preferences\n");
}
{
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";
const char *subsurface_USB_name()
{
return "/dev/tty.SLAB_USBtoUART";
report_dives(imported);
run_ui();
report_dives(imported);
run_ui();
-void subsurface_close_conf(void)
+void subsurface_flush_conf(void)
+ /* I wonder if we should even do this - it's apparently very expensive */
if (RegFlushKey(hkey) != ERROR_SUCCESS)
printf("RegFlushKey failed \n");
if (RegFlushKey(hkey) != ERROR_SUCCESS)
printf("RegFlushKey failed \n");
+}
+
+void subsurface_close_conf(void)
+{