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 110206 - removing items from a Ctk::Combo crashes
removing items from a Ctk::Combo crashes
Status: RESOLVED FIXED
Product: gtkmm
Classification: Bindings
Component: general
2.4
Other Windows
: Normal normal
: ---
Assigned To: gtkmm-forge
gtkmm-forge
Depends on:
Blocks:
 
 
Reported: 2003-04-07 20:26 UTC by erwan.ancel
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description erwan.ancel 2003-04-07 20:26:38 UTC
When I try to remove some items from a Gtk::Combo (eg from a 
Gtk::ComboDropDown), the program crashes.

sample program:


#include <gtkmm/main.h>
#include <gtkmm/window.h>
#include <gtkmm/combo.h>

#include <list>

class SampleWindow: public Gtk::Window
{
public:
    SampleWindow()
    {
        add(_combo);
        std::list<Glib::ustring> listStrings;
        listStrings.push_back("something");
        listStrings.push_back("something else");
        listStrings.push_back("something or other");
        _combo.set_popdown_strings(listStrings);
        _combo.get_list()->children().clear(); // <- CRASH HERE
        show_all_children();
    }
    
private:
    Gtk::Combo _combo;
};


int main(int argc, char *argv[])
{
    Gtk::Main kit(argc, argv);
    SampleWindow sw;
    Gtk::Main::run(sw);
    return 0;
}
Comment 1 Murray Cumming 2003-04-08 07:41:27 UTC
Could someone check this on Linux?
Comment 2 Murray Cumming 2003-04-08 07:41:50 UTC
And please _attach_ test code in future.
Comment 3 Elke Meier 2003-04-09 07:39:24 UTC
Tried it out on Linux with version 2.0.2, and it segfaults.
Backtrace:
(gdb) bt
  • #0 Gtk::ComboDropDown_Helpers::ComboDropDownList::erase
  • #1 Gtk::ComboDropDown_Helpers::ComboDropDownList::erase
  • #2 Glib::HelperList<Gtk::ComboDropDownItem, Gtk::ComboDropDownItem const, Glib::List_Iterator<Gtk::ComboDropDownItem> >::clear()
  • #3 SampleWindow::SampleWindow()
  • #4 main
  • #5 __libc_start_main
    from /lib/i686/libc.so.6

Comment 4 Murray Cumming 2003-04-13 12:54:39 UTC
This one looks serious. I think that ComboDropDownList should be using
List_Cpp_iterator instead of List_Iterator, because at the moment it
casts a C instance from GList::node->data directly to C++ instance. In
fact, I don't think List_Iterator should ever work. I would really
like Daniel Elsner to take a look too.

This patch seems to fix things, but it would be API or ABI breaking,
so I'm changing this to a 2.4 bug.

I guess it's a good thing that we generally have dual
STL-like/GTK+-like for these things. Gtk::Combo is kind of a special
case because we had to hide the deprecated GtkList widget. Hopefully
it's OK for you to completely rebuild the list of items.
Comment 5 Murray Cumming 2003-04-13 12:57:36 UTC
Hmm, now I find that that patch isn't really on my floppy. Well, it
just added this line
  GP_LIST_ITER(Glib::List_Cpp_Iterator<GtkListItem, ComboDropDownItem>)
like in menushell:
http://cvs.gnome.org/lxr/source/gtkmm-root/gtk-src/menushell.hg#53
Comment 6 erwan.ancel 2003-04-13 14:59:39 UTC
the combo.h file doesn't change if I add the line. More, if I erase
the combo.h generated file, compilation complains that it doesn't have
any rule to generate it...
Comment 7 Murray Cumming 2003-04-14 12:07:59 UTC
That's unusual. You could try running autogen.sh, or try it from cvs.
But anyway, this won't be very helpful to you now because you probably
want to continue using the gtkmm 2.2 stable API instead of gtkmm 2.4.
Comment 8 Murray Cumming 2003-04-23 13:51:44 UTC
I have applied this to gtkmm 2.4 so that people can test it out. (I
need to check in some important install/pkg-config fixes to gtkmm 2.4
later today).
Comment 9 Murray Cumming 2003-06-03 05:13:27 UTC
By the way, for gtkmm 2.2 these are the workarounds that I can think of:
1. Remove all the items and add them again. (Removing might need 2.)
2. Use GTK+ functions, after using gobj() to get the C instance.