diff options
author | Matthias Clasen <mclasen@redhat.com> | 2004-05-14 13:37:07 +0000 |
---|---|---|
committer | Matthias Clasen <matthiasc@src.gnome.org> | 2004-05-14 13:37:07 +0000 |
commit | acc6a1aa605f2725cac5a541417272cecc8e98c4 (patch) | |
tree | 16c860369c1cc633fa778c249483380b1dd9aec6 /gtk/gtkstock.c | |
parent | c4f723597b27a02b963115a83729916848c6162a (diff) | |
download | gtk+-acc6a1aa605f2725cac5a541417272cecc8e98c4.tar.gz |
Add a comment about unused bits.
2004-05-14 Matthias Clasen <mclasen@redhat.com>
* gdk/gdktypes.h (GdkModifierType): Add a comment about unused
bits.
* gtk/gtkstock.c (real_add, gtk_stock_lookup): Use an unused
modifier bit to mark stock item which need to be freed
eventually. (#140654, Michal Pasternak, Scott Tsai)
Diffstat (limited to 'gtk/gtkstock.c')
-rw-r--r-- | gtk/gtkstock.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/gtk/gtkstock.c b/gtk/gtkstock.c index 5aea0eabaa..6bf445190e 100644 --- a/gtk/gtkstock.c +++ b/gtk/gtkstock.c @@ -35,6 +35,11 @@ static GHashTable *stock_hash = NULL; static void init_stock_hash (void); +/* We use an unused modifier bit to mark stock items which + * must be freed when they are removed from the hash table. + */ +#define NON_STATIC_MASK (1 << 29) + static void real_add (const GtkStockItem *items, guint n_items, @@ -52,14 +57,25 @@ real_add (const GtkStockItem *items, { gpointer old_key, old_value; const GtkStockItem *item = &items[i]; + + if (item->modifier & NON_STATIC_MASK) + { + g_warning ("Bit 29 set in stock accelerator.\n"); + copy = TRUE; + } + if (copy) - item = gtk_stock_item_copy (item); + { + item = gtk_stock_item_copy (item); + ((GtkStockItem *)item)->modifier |= NON_STATIC_MASK; + } if (g_hash_table_lookup_extended (stock_hash, item->stock_id, &old_key, &old_value)) { g_hash_table_remove (stock_hash, old_key); - gtk_stock_item_free (old_value); + if (((GtkStockItem *)old_value)->modifier & NON_STATIC_MASK) + gtk_stock_item_free (old_value); } g_hash_table_insert (stock_hash, @@ -136,6 +152,7 @@ gtk_stock_lookup (const gchar *stock_id, if (found) { *item = *found; + item->modifier &= ~NON_STATIC_MASK; if (item->label) item->label = dgettext (item->translation_domain, item->label); } |