Re: Gtk::TreeView cell background color



My guess would be that the dynamic_cast<Gtk::CellRendererText
*>(cell_renderer) call is unable to make the cast requested and is
returning a NULL pointer.

Maybe a check to see if cell_renderer_text is valid would be in order.

Bob

Jason Burchfield wrote:

> When I add a Gtk::TreeModelColumn<bool>, which uses a
> Gtk::CellRendererToggle, to a Gtk::TreeView and try to change the cell
> color I get a seg fault.
> Is this a bug or am I doing something wrong.  All other columns work...
>
>
> tv->append_column_editable( "Test", Columns.m_col_test );
>
>
> void ColorRows( Gtk::TreeView* treeview ){
>
>    Gtk::CellRendererText* cell_renderer_text;
>    Gtk::TreeViewColumn* color_column;
>    vector<Gtk::TreeViewColumn*> columns = treeview->get_columns();
>    Gtk::TreeModel::Children children = treeview->get_model()->children();
>    Gtk::TreeModel::Row row;
>    CModelColumns ModelColumns;
>      for( int x = 0; x < children.size(); x++ ){
>          row = *(children[x]);
>              if( (x % 2) == 0 )                     
> row[ModelColumns.m_col_color] = "grey";
>                  else
>            row[ModelColumns.m_col_color] = "white";
>              for( int y = 0; y < columns.size(); y++ ){
>                      color_column = treeview->get_column(y);
>            Gtk::CellRenderer* cell_renderer =
> color_column->get_first_cell_renderer();
>                              cell_renderer_text =
>                       
> dynamic_cast<Gtk::CellRendererText*>(cell_renderer);
>                  
> color_column->add_attribute(cell_renderer_text->property_cell_background(),
>
>                        ModelColumns.m_col_color);   //
> <----------segmentation fault
>        }
>    }
> }
>



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