Re: [gtkmm] remove all children of a Gtk::Container



Ok. It doesn't work... Here is a sample code: I just add some entries in the
list of a combo box, and then remove them: segmentation fault ...
Dos anyone have an idea ?
nb: I use derived objects of Gtk::ComboDropDownItem as items. But it should
not disturb, should it?

    Erwan

here is the sample code:


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

#include <list>

class SampleWindow: public Gtk::Window
{
public:
    SampleWindow()
    {
        add(_combo);
        for (int i=1; i<=10; ++i)
        {
            char buff[100];
            sprintf(buff, "entry number %d", i);
            _combo.get_list()->children().push_back(*Gtk::manage(new
ComboItem(buff)));
        }
        _combo.get_list()->children().clear();
        show_all_children();
    }

private:
    Gtk::Combo _combo;
    class ComboItem: public Gtk::ComboDropDownItem
    {
    public:
        ComboItem(const char* s):
            _label(s)
        {
            add(_label);
            show_all();
        }
        Gtk::Label _label;
    };
};


int main(int argc, char *argv[])
{
    Gtk::Main kit(argc, argv);
    SampleWindow sw;
    Gtk::Main::run(sw);
    return 0;
}





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]