diff options
author | Ted Gould <ted@gould.cx> | 2011-03-04 12:37:14 -0600 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2011-03-04 12:37:14 -0600 |
commit | 911ce51574b4771318d5af94a239a4d41e6001a3 (patch) | |
tree | 6a4fac36efa3febc50653a857f4dec23e25a0164 | |
parent | 59336ca7d7d4706bbe122446f6a1179a12f9ba55 (diff) | |
download | libdbusmenu-911ce51574b4771318d5af94a239a4d41e6001a3.tar.gz libdbusmenu-911ce51574b4771318d5af94a239a4d41e6001a3.tar.bz2 libdbusmenu-911ce51574b4771318d5af94a239a4d41e6001a3.zip |
Build the theme directory database when we build objects
-rw-r--r-- | libdbusmenu-gtk/client.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index c998517..88671f7 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -96,6 +96,22 @@ dbusmenu_gtkclient_init (DbusmenuGtkClient *self) priv->agroup = NULL; priv->old_themedirs = NULL; + /* We either build the theme db or we get a reference + to it. This way when all clients die the hashtable + will be free'd as well. */ + if (theme_dir_db == NULL) { + theme_dir_db = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); + + /* NOTE: We're adding an extra ref here because there + is no way to clear the pointer when the hash table + dies, so it's safer to keep the hash table around + forever than not know if it's free'd or not. Patch + submitted to GLib. */ + g_hash_table_ref(theme_dir_db); + } else { + g_hash_table_ref(theme_dir_db); + } + dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(self), DBUSMENU_CLIENT_TYPES_DEFAULT, new_item_normal); dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(self), DBUSMENU_CLIENT_TYPES_SEPARATOR, new_item_seperator); @@ -124,6 +140,12 @@ dbusmenu_gtkclient_dispose (GObject *object) priv->old_themedirs = NULL; } + if (theme_dir_db != NULL) { + g_hash_table_unref(theme_dir_db); + } else { + g_assert_not_reached(); + } + G_OBJECT_CLASS (dbusmenu_gtkclient_parent_class)->dispose (object); return; } |