[gdm/wip/foreach-fixes: 1/4] display-store: make foreach ignore callback return value
- From: Ray Strode <halfline src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gdm/wip/foreach-fixes: 1/4] display-store: make foreach ignore callback return value
- Date: Thu, 21 Feb 2019 20:25:41 +0000 (UTC)
commit 47d01abe279cf4d5d2f4f3aea934004b87542d69
Author: xiaoguang wang <xwang suse com>
Date: Wed Feb 20 09:26:02 2019 +0800
display-store: make foreach ignore callback return value
gdm_display_store_foreach is designed to iterate through all
displays in the display store. Under the hood, it currently
uses gdm_display_store_find, though, so will prematurely stop
it's loop if a callback returns TRUE. Callers are getting this
wrong. Some return TRUE with the expectation it goes on, and
some fail to return a value at all.
This commit changes gdm_display_store_foreach to use
g_hash_table_foreach instead, so the callback return values no
longer matter.
daemon/gdm-display-store.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
---
diff --git a/daemon/gdm-display-store.c b/daemon/gdm-display-store.c
index fd24334e..910468cd 100644
--- a/daemon/gdm-display-store.c
+++ b/daemon/gdm-display-store.c
@@ -146,6 +146,16 @@ find_func (const char *id,
closure->user_data);
}
+static void
+foreach_func (const char *id,
+ StoredDisplay *stored_display,
+ FindClosure *closure)
+{
+ (void) closure->predicate (id,
+ stored_display->display,
+ closure->user_data);
+}
+
void
gdm_display_store_foreach (GdmDisplayStore *store,
GdmDisplayStoreFunc func,
@@ -159,9 +169,9 @@ gdm_display_store_foreach (GdmDisplayStore *store,
closure.predicate = func;
closure.user_data = user_data;
- g_hash_table_find (store->priv->displays,
- (GHRFunc) find_func,
- &closure);
+ g_hash_table_foreach (store->priv->displays,
+ (GHFunc) foreach_func,
+ &closure);
}
GdmDisplay *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]