Problems with Gtk::Table
- From: Marcus Lundblad <ml Update UU SE>
- To: gtkmm-list gnome org
- Subject: Problems with Gtk::Table
- Date: Tue, 9 Aug 2005 18:49:54 +0200 (CEST)
Hello.
I have a problem with a class derived from Gtk::Table
In this class I have a method "rearrange" that is called when changing
the layout of this table:
void
desks_table::rearrange()
{
int num_cols = (unsigned int)(std::ceil(double(double(num_desks())/
double(num_rows()))));
std::cerr << "resize( " << num_rows() << ", " << num_cols << std::endl;
TableList& tl = children();
std::cerr << "children size = " << tl.size() << std::endl;
int child_size = tl.size();
tl.clear();
resize(num_rows(), num_cols);
int desk = 0;
for(int i = 0 ; i < num_rows() ; i++) {
for(int j = 0 ; j < num_cols && desk < num_desks() ; j++) {
std::cerr << "attaching desk " << desk << std::endl;
attach(*(desk_widgets[desk]), j, j+1, i, i+1);
desk++;
}
}
}
The "desk_widgets" is (currently) std::vector<Gtk::Label>, but will be a
derived class later on, this vector is maintained outside of this method
(the idea is that this should be usable both when changing number of
subwidgets and rearraging, columns and rows).
The first time this is called (as a consequence of the constructor), there
is no widgets attached and there's 4 widgets allocated in the vector.
The follwing gets printed:
------------------------------------------------------
resize( 1, 4
children size = 0
attaching desk 0
attaching desk 1
attaching desk 2
attaching desk 3
------------------------------------------------------
and the widgets appear in the table as expected.
The second time the vector has one more element.
the printout now:
-------------------------------------------------------------------------
resize( 1, 5
children size = 4
(gov:7206): Gtk-CRITICAL **: gtk_container_remove: assertion
`GTK_IS_WIDGET (widget)' failed
(gov:7206): Gtk-CRITICAL **: gtk_container_remove: assertion
`GTK_IS_WIDGET (widget)' failed
(gov:7206): Gtk-CRITICAL **: gtk_container_remove: assertion
`GTK_IS_WIDGET (widget)' failed
(gov:7206): Gtk-CRITICAL **: gtk_container_remove: assertion
`GTK_IS_WIDGET (widget)' failed
attaching desk 0
(gov:7206): Gtk-CRITICAL **: gtk_table_attach: assertion `child->parent ==
NULL' failed
attaching desk 1
(gov:7206): Gtk-CRITICAL **: gtk_table_attach: assertion `child->parent ==
NULL' failed
attaching desk 2
(gov:7206): Gtk-CRITICAL **: gtk_table_attach: assertion `child->parent ==
NULL' failed
attaching desk 3
(gov:7206): Gtk-CRITICAL **: gtk_table_attach: assertion `child->parent ==
NULL' failed
attaching desk 4
--------------------------------------------------------------------------
When calling tl.clear() on the children something goes wrong,
(the exact same thing happens using tl.erase(tl.begin(),tl.end()) )
the table is resized, but the new slot is empty (even though the last
attach, on the slot that's new didn't seem to fail.
What am I doing wrong? (I've read the documentation and check sample
codes, but can't seem to get it right).
//Marcus
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]