Skip to content
This repository has been archived by the owner on Nov 17, 2020. It is now read-only.

Commit

Permalink
GSettings: make _sync() a no-op if uninitialised
Browse files Browse the repository at this point in the history
If GSettings is uninitialised then g_settings_sync() should very
obviously just return right away (rather than attempting to initialise
GSettings first).
  • Loading branch information
allisonkarlitskaya committed Apr 11, 2011
1 parent 4537725 commit 68aef33
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions gio/gsettingsbackend.c
Expand Up @@ -45,6 +45,13 @@ struct _GSettingsBackendPrivate
GStaticMutex lock;
};

/* For g_settings_backend_sync_default(), we only want to actually do
* the sync if the backend already exists. This avoids us creating an
* entire GSettingsBackend in order to call a do-nothing sync()
* operation on it. This variable lets us avoid that.
*/
static gboolean g_settings_has_backend;

/**
* SECTION:gsettingsbackend
* @title: GSettingsBackend
Expand Down Expand Up @@ -982,6 +989,7 @@ g_settings_backend_get_default (void)

extension_type = g_io_extension_get_type (extension);
instance = g_object_new (extension_type, NULL);
g_settings_has_backend = TRUE;

g_once_init_leave (&backend, (gsize) instance);
}
Expand Down Expand Up @@ -1021,12 +1029,15 @@ g_settings_backend_get_permission (GSettingsBackend *backend,
void
g_settings_backend_sync_default (void)
{
GSettingsBackendClass *class;
GSettingsBackend *backend;
if (g_settings_has_backend)
{
GSettingsBackendClass *class;
GSettingsBackend *backend;

backend = g_settings_backend_get_default ();
class = G_SETTINGS_BACKEND_GET_CLASS (backend);
backend = g_settings_backend_get_default ();
class = G_SETTINGS_BACKEND_GET_CLASS (backend);

if (class->sync)
class->sync (backend);
if (class->sync)
class->sync (backend);
}
}

0 comments on commit 68aef33

Please sign in to comment.