After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 142746 - Open loses some GtkComboBox items
Open loses some GtkComboBox items
Status: RESOLVED FIXED
Product: glade-legacy
Classification: Deprecated
Component: general
unspecified
Other Linux
: Urgent critical
: ---
Assigned To: Damon Chaplin
Damon Chaplin
Depends on:
Blocks:
 
 
Reported: 2004-05-18 21:23 UTC by pjm
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Test case (1.73 KB, text/plain)
2004-05-18 21:26 UTC, pjm
Details

Description pjm 2004-05-18 21:23:18 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.
Comment 1 pjm 2004-05-18 21:26:32 UTC
Created attachment 27816 [details]
Test case
Comment 2 Damon Chaplin 2004-05-19 15:38:15 UTC
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.
Comment 3 Damon Chaplin 2004-05-19 18:20:42 UTC
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;
        }
     }