Merge branch 'regwatch-appinfo-fixes' into 'main'

GWin32RegistryKey / GWin32AppInfo registry watch fixes

See merge request GNOME/glib!2205
This commit is contained in:
Philip Withnall 2021-08-02 10:51:28 +00:00
commit ce5a2cfed5
2 changed files with 12 additions and 8 deletions

View File

@ -3828,6 +3828,9 @@ update_registry_data (void)
return; return;
} }
static void
watch_keys (void);
/* This function is called when any of our registry watchers detect /* This function is called when any of our registry watchers detect
* changes in the registry. * changes in the registry.
*/ */
@ -3835,6 +3838,7 @@ static void
keys_updated (GWin32RegistryKey *key, keys_updated (GWin32RegistryKey *key,
gpointer user_data) gpointer user_data)
{ {
watch_keys ();
/* Indicate the tree as not up-to-date, push a new job for the AppInfo thread */ /* Indicate the tree as not up-to-date, push a new job for the AppInfo thread */
g_atomic_int_inc (&gio_win32_appinfo_update_counter); g_atomic_int_inc (&gio_win32_appinfo_update_counter);
/* We don't use the data pointer, but it must be non-NULL */ /* We don't use the data pointer, but it must be non-NULL */
@ -4029,7 +4033,6 @@ gio_win32_appinfo_init (gboolean do_wait)
g_mutex_lock (&gio_win32_appinfo_mutex); g_mutex_lock (&gio_win32_appinfo_mutex);
while (g_atomic_int_get (&gio_win32_appinfo_update_counter) > 0) while (g_atomic_int_get (&gio_win32_appinfo_update_counter) > 0)
g_cond_wait (&gio_win32_appinfo_cond, &gio_win32_appinfo_mutex); g_cond_wait (&gio_win32_appinfo_cond, &gio_win32_appinfo_mutex);
watch_keys ();
g_mutex_unlock (&gio_win32_appinfo_mutex); g_mutex_unlock (&gio_win32_appinfo_mutex);
} }
} }

View File

@ -2425,17 +2425,20 @@ key_changed (PVOID closure,
ULONG reserved) ULONG reserved)
{ {
GWin32RegistryKey *key = G_WIN32_REGISTRY_KEY (closure); GWin32RegistryKey *key = G_WIN32_REGISTRY_KEY (closure);
gpointer user_data;
GWin32RegistryKeyWatchCallbackFunc callback;
callback = g_steal_pointer (&key->priv->callback);
user_data = g_steal_pointer (&key->priv->user_data);
g_free (status_block); g_free (status_block);
g_atomic_int_set (&key->priv->change_indicator, G_WIN32_KEY_CHANGED); g_atomic_int_set (&key->priv->change_indicator, G_WIN32_KEY_CHANGED);
g_atomic_int_set (&key->priv->watch_indicator, G_WIN32_KEY_UNWATCHED); g_atomic_int_set (&key->priv->watch_indicator, G_WIN32_KEY_UNWATCHED);
key->priv->update_flags = G_WIN32_REGISTRY_UPDATED_NOTHING; key->priv->update_flags = G_WIN32_REGISTRY_UPDATED_NOTHING;
if (key->priv->callback) if (callback)
key->priv->callback (key, key->priv->user_data); callback (key, user_data);
key->priv->callback = NULL;
key->priv->user_data = NULL;
g_object_unref (key); g_object_unref (key);
} }
@ -2550,9 +2553,7 @@ g_win32_registry_key_watch (GWin32RegistryKey *key,
0, 0,
TRUE); TRUE);
g_assert (status != STATUS_SUCCESS); if (status == STATUS_PENDING || status == STATUS_SUCCESS)
if (status == STATUS_PENDING)
return TRUE; return TRUE;
g_atomic_int_set (&key->priv->change_indicator, G_WIN32_KEY_UNKNOWN); g_atomic_int_set (&key->priv->change_indicator, G_WIN32_KEY_UNKNOWN);