Re: gtk combobox questions
- From: Anca Mitrica <ancamitrica yahoo com>
- To: Bob Caryl <bob fis-cal com>
- Cc: gtkmm-list gnome org
- Subject: Re: gtk combobox questions
- Date: Thu, 14 Jul 2005 04:09:12 -0700 (PDT)
--- Bob Caryl <bob fis-cal com> wrote:
> Anca Mitrica wrote:
>
> >Hello,
> >
> >I am trying to attach a Gtk::ComboBox to a
> Gtk::Table,
> >in a dynamical way: the combobox list store is
> filled
> >with values read from different list<Glib::ustring>
> >(several if branches). The problem is that I
> receive a
> >segmentation fault each time I try to visualize the
> >combobox.
> >
> >Here is the code :
> >
> >DirWindow.h file:
> >..................
> >class DirWindow{
> > public:
> > .............
> > protected:
> > //define class for tree model for combobox
> > class ModelTree:public
> Gtk::TreeModel::ColumnRecord{
> > public:
> >
> > ModelTree(){
> > add(colName);
> > }
> > Gtk::TreeModelColumn<Glib::ustring> colName;
> > };
> >
> > private:
> > Glib::RefPtr<Gtk::ListStore> typelist;
> > Gtk::ComboBox *combo ;
> >.......................
> >};
> >
> >DirWindow.cc file :
> >......................................
> >
> >void DirWindow::on_Combo_Name_Type(){
> > Glib::ustring parname,partype,pardelim;
> >
> > Glib::ustring ns = getComboNameActive();
> > Glib::ustring typesel = getComboTypeActive();
> >
> > //oxLabel = new Gtk::Label("0x");
> > butAjouter->set_sensitive(true);
> > delete intable;
> >
> > paramTableRowNumber = 1;
> > intable = new
> Gtk::Table(paramTableRowNumber,3,true);
> > intable->set_col_spacings(8);
> > intable->set_row_spacings(8);
> >
> > if(typesel =="SES"){
> > for(parseIterator=seslist.begin();parseIterator
> !=
> >seslist.end();parseIterator++){
> > Glib::ustring elem = *parseIterator;
> > Glib::ustring name =
> >elem.substr(0,elem.find_first_of("<",0));
> > if((name == ns)||(name =="\t"+ns)){
> > //get all parameters for a directive in put
> thzm
> >into a list
> > tokenizeString(elem,"<");
> >
> > //li = list containing all parameters of a
> >directive
> > for(p = li.begin();p != li.end();++p){
> > //p = a parameter with name type and
> delimiter
> > Glib::ustring parameter = *p;
> > tokenizeParameter(parameter);
> > for(unsigned int i = 0;i<vecteur.size();i++){
> > if(i == 0)
> > parname = vecteur[i];
> > else if(i == 1){
> > partype = vecteur[i];
> > }else if(i == 2){
> > pardelim = vecteur[i];
> > }
> > }
> >
> >
> > paramTableRowNumber++;
> >
> > intable->resize(paramTableRowNumber,3);
> >
> intable->set_resize_mode(Gtk::RESIZE_IMMEDIATE);
> >
> > newParameterName = new Gtk::Label(parname);
> > newParameterType = new
>
>Gtk::Label(Glib::ustring("(")+partype+Glib::ustring(")"));
> > newParameterEntry = new Gtk::Entry();
> >
> > combo = new Gtk::ComboBox();
> >
> > typelist = Gtk::ListStore::create(columns);
> > combo->set_model(typelist);
> >
> > for(parsetypeIterator =
>
>hexlist.begin();parsetypeIterator!=hexlist.end();++parsetypeIterator){
> > Glib::ustring s = *parsetypeIterator;
> > Gtk::TreeModel::Row firstrow =
> >*(typelist->append());
> > firstrow[columns.colName] = s;
> > }
> > combo->pack_start(columns.colName);
> >
>
>combo->signal_changed().connect(sigc::mem_fun(*this,&DirWindow::on_Combo_Type_Enum));
> > combo->set_active(0);
> >
> >
>
>intable->attach(*newParameterName,0,1,paramTableRowNumber-1,paramTableRowNumber,Gtk::EXPAND,Gtk::EXPAND,0,0);
> >
> > if(partype == "ENUM_HEX"){
> > hb = new Gtk::HBox();
> > oxLabel = new Gtk::Label("0x");
> > hb->pack_start(*oxLabel,Gtk::PACK_SHRINK);
> >
>
>hb->pack_start(*newParameterEntry,Gtk::PACK_SHRINK);
> >
>
>intable->attach(*hb,1,2,paramTableRowNumber-1,paramTableRowNumber,Gtk::FILL,Gtk::FILL,0,0);
> > hb->show_all_children();
> >
>
>intable->attach(*combo,2,3,paramTableRowNumber-1,paramTableRowNumber);
> > }else{
> >
>
>intable->attach(*newParameterEntry,1,2,paramTableRowNumber-1,paramTableRowNumber,Gtk::FILL,Gtk::FILL,0,0);
> >
>
>intable->attach(*newParameterType,2,3,paramTableRowNumber-1,paramTableRowNumber,Gtk::FILL,Gtk::FILL,0,0);
> > } intable->queue_resize();
> > }
> > }
> > }
> > }
> >..............................................
> >
> >
> >The table also is updated dynamically.
> >
> >Does anyone has an idea about what's wrong with my
> >code? Or what could generate a seg fault?
> >
> >Thank you
> >
> >
> >
> >Anca Mitrica
> >
> >__________________________________________________
> >Do You Yahoo!?
> >Tired of spam? Yahoo! Mail has the best spam
> protection around
> >http://mail.yahoo.com
> >_______________________________________________
> >gtkmm-list mailing list
> >gtkmm-list gnome org
> >http://mail.gnome.org/mailman/listinfo/gtkmm-list
> >
> >
> >
>
> In "DirWindow::on_Combo_Name_Type()" you delete
> "intable" and then you
> reinstantiate it, attaching several widgets to it,
> but I do not see you
> adding this table to a container (not even to your
> main app window).
> You have potential memory leak problems with the
> various widgets you are
> instantiating to put into the new intable widget. I
> would suggest using
> the "manage" method of your main application window
> when you instantiate
> these widgets. You might want to want until you
> finish initializing
> typelist before you set it as the model for combo.
> Beyond that, I do
> not see anything that appears to be wrong with your
> construction of combo.
>
> Perhaps you have left out a good deal of detail for
> the sake of brevity,
> so I think it might be helpful if more information
> were available.
>
> Bob Caryl
>
Hi Bob,
All widgets that I used are properly instantiated and
attached to their containers. Also, the table used
here is attached to a Gtk::VBox of main Dialog.
I don't have any problem if I choose to attach to this
table a Gtk::Label, instead of a Gtk::ComboBox, so the
problem is in attaching a combobox to a Gtk::Table.
I am thinking there is a problem with the list store
model, but again, i did this operation before, in
other parts of my application, and it worked properly.
The problem is only in this function.
I removed a lot of code, in order to short the
message.
Anca Mitrica
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]