diff options
author | Patrick McDermott <pj@pehjota.net> | 2017-10-30 17:11:05 (EDT) |
---|---|---|
committer | Patrick McDermott <pj@pehjota.net> | 2017-10-30 17:11:05 (EDT) |
commit | 83c0780b4137e2dc42d8812687c0170de8f634b0 (patch) | |
tree | 7aa21dd746f5fb699b74b52eb0c25c6468057987 /src | |
parent | f3ad4fbba7b8c1759f7bfccdd5ce3a8c9076935a (diff) | |
download | marquee-83c0780b4137e2dc42d8812687c0170de8f634b0.zip marquee-83c0780b4137e2dc42d8812687c0170de8f634b0.tar.gz marquee-83c0780b4137e2dc42d8812687c0170de8f634b0.tar.bz2 |
mq_application_register_tab(): Copy tab ID into hash table
Otherwise, every key in the hash table is incremented to the same
invalid value on each mq_application_register_tab() call.
Also set key destruction function in mq_application_new().
Diffstat (limited to 'src')
-rw-r--r-- | src/application.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/application.c b/src/application.c index 38904c8..4d4c815 100644 --- a/src/application.c +++ b/src/application.c @@ -84,7 +84,8 @@ mq_application_new(const gchar *profile, gboolean G_GNUC_UNUSED private) application->config = mq_config_new(profile); mq_config_load(application->config); application->windows = NULL; - application->tabs = g_hash_table_new(g_int64_hash, g_int64_equal); + application->tabs = g_hash_table_new_full(g_int64_hash, g_int64_equal, + g_free, NULL); application->last_tab_id = 0; application->marquee_mode = FALSE; @@ -251,9 +252,11 @@ mq_application_delete_window(MqApplication *application, MqWindow *window) gint64 mq_application_register_tab(MqApplication *application, MqTabPage *tab_page) { - ++application->last_tab_id; - g_hash_table_insert(application->tabs, &application->last_tab_id, - tab_page); + gint64 *tab_id; + + tab_id = g_new(gint64, 1); + *tab_id = ++application->last_tab_id; + g_hash_table_insert(application->tabs, tab_id, tab_page); return application->last_tab_id; } |