GNOME Bugzilla – Bug 142746
Open loses some GtkComboBox items
Last modified: 2004-12-22 21:47:04 UTC
When loading a project some GtkComboBox items are lost. It does not happen for every combo box, but I have been able to generate a small test case. The steps are: 1. Open glade-2 2. Create a window 3. Put an h-box (size 2) in the window 4. Put a combo box in each h-box cell 5. Set the items property to have two items (I used a1 and a2) in each box 6. Save (all defaults) 7. Open the .glade file The second combo box will only have item a1 and saving will cause silent loss of data (item a2 will disappear). This is on Fedora-1 with the following installed in a test directory: glade-2.6.0, libxml2-2.6.10, gtk+-2.4.1, glib-2.4.1, pango-1.4.0, atk-1.6.1 and various other support libraries. I've stepped through it and it appears to be a glade bug. However, I've not been able to figure it out (not very familiar with glade). The items are read properly by libxml2 (the first combo box is correct). This is a big issue for me, so I'm very happy to help in any way. However, I've not been able to fix it myself.
Created attachment 27816 [details] Test case
Yes, I can reproduce it by loading your test file. I can't spot the problem yet. It seems to be in the loading code, since the second 'a2' line is not even being passed to the combo widget. It is also pretty strange that it works for the first widget and not the second.
I know what the problem is now. It only happens if you have exactly the same items in the 2 combos. i.e. if you change the second 'a2' to 'a3' it works OK. The problem is that the code in glade-parser.c uses a cache of strings, and since the items are the same for both widgets it uses 1 string for both. But the code that creates the combos modifies the string! This is the fix for GtkComboBox. I've applied similar fixes for GtkComboBoxEntry and GtkCombo. diff -u -r1.2 gbcombobox.c --- glade/gbwidgets/gbcombobox.c 8 Mar 2004 16:24:12 -0000 1.2 +++ glade/gbwidgets/gbcombobox.c 19 May 2004 18:14:53 -0000 @@ -123,6 +123,9 @@ gtk_combo_box_append_text (GTK_COMBO_BOX (widget), pos); + if (item_end != items_end) + *item_end = '\n'; + pos = item_end + 1; } }