mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-26 05:56:14 +01:00
GSettings: fix check for delaying backend subscription
g_settings_has_signal_handlers() checks whether any of the signals has pending handlers. However, g_signal_has_handler_pending() matches on exact detail, even when passing 0. Subscribing to one of GSettings' signals with a detail will fail this check and never connect to the backend. Fix this by calling has_handler_pending() with the key as detail as well. https://bugzilla.gnome.org/show_bug.cgi?id=740848
This commit is contained in:
parent
7f2f4ab12d
commit
d511d6b37f
@ -317,18 +317,24 @@ g_settings_real_writable_change_event (GSettings *settings,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
g_settings_has_signal_handlers (GSettings *settings)
|
g_settings_has_signal_handlers (GSettings *settings,
|
||||||
|
const gchar *key)
|
||||||
{
|
{
|
||||||
GSettingsClass *class = G_SETTINGS_GET_CLASS (settings);
|
GSettingsClass *class = G_SETTINGS_GET_CLASS (settings);
|
||||||
|
GQuark keyq;
|
||||||
|
|
||||||
if (class->change_event != g_settings_real_change_event ||
|
if (class->change_event != g_settings_real_change_event ||
|
||||||
class->writable_change_event != g_settings_real_writable_change_event)
|
class->writable_change_event != g_settings_real_writable_change_event)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
|
keyq = g_quark_from_string (key);
|
||||||
|
|
||||||
if (g_signal_has_handler_pending (settings, g_settings_signals[SIGNAL_WRITABLE_CHANGE_EVENT], 0, TRUE) ||
|
if (g_signal_has_handler_pending (settings, g_settings_signals[SIGNAL_WRITABLE_CHANGE_EVENT], 0, TRUE) ||
|
||||||
g_signal_has_handler_pending (settings, g_settings_signals[SIGNAL_WRITABLE_CHANGED], 0, TRUE) ||
|
g_signal_has_handler_pending (settings, g_settings_signals[SIGNAL_WRITABLE_CHANGED], 0, TRUE) ||
|
||||||
|
g_signal_has_handler_pending (settings, g_settings_signals[SIGNAL_WRITABLE_CHANGED], keyq, TRUE) ||
|
||||||
g_signal_has_handler_pending (settings, g_settings_signals[SIGNAL_CHANGE_EVENT], 0, TRUE) ||
|
g_signal_has_handler_pending (settings, g_settings_signals[SIGNAL_CHANGE_EVENT], 0, TRUE) ||
|
||||||
g_signal_has_handler_pending (settings, g_settings_signals[SIGNAL_CHANGED], 0, TRUE))
|
g_signal_has_handler_pending (settings, g_settings_signals[SIGNAL_CHANGED], 0, TRUE) ||
|
||||||
|
g_signal_has_handler_pending (settings, g_settings_signals[SIGNAL_CHANGED], keyq, TRUE))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
/* None of that? Then surely nobody is watching.... */
|
/* None of that? Then surely nobody is watching.... */
|
||||||
@ -1078,7 +1084,7 @@ g_settings_read_from_backend (GSettings *settings,
|
|||||||
gchar *path;
|
gchar *path;
|
||||||
|
|
||||||
/* If we are not yet watching for changes, consider doing it now... */
|
/* If we are not yet watching for changes, consider doing it now... */
|
||||||
if (!settings->priv->is_subscribed && g_settings_has_signal_handlers (settings))
|
if (!settings->priv->is_subscribed && g_settings_has_signal_handlers (settings, key->name))
|
||||||
{
|
{
|
||||||
g_settings_backend_subscribe (settings->priv->backend, settings->priv->path);
|
g_settings_backend_subscribe (settings->priv->backend, settings->priv->path);
|
||||||
settings->priv->is_subscribed = TRUE;
|
settings->priv->is_subscribed = TRUE;
|
||||||
|
Loading…
Reference in New Issue
Block a user