Don't refresh not yet realized widget in wxGTK wxDataViewCtrl.

If the text of any of wxDataViewCtrl cells was set before the control was
realized (e.g. during its creation), the code tried to refresh the not yet
shown widget resulting in GTK+ errors.

Avoid this by only refreshing the tree if it's realized.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68853 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2011-08-22 15:31:38 +00:00
parent dbab29b925
commit b30ad9676b

View File

@@ -1644,23 +1644,28 @@ bool wxGtkDataViewModelNotifier::ValueChanged( const wxDataViewItem &item, unsig
GtkTreeView *widget = GTK_TREE_VIEW(ctrl->GtkGetTreeView()); GtkTreeView *widget = GTK_TREE_VIEW(ctrl->GtkGetTreeView());
GtkTreeViewColumn *gcolumn = GTK_TREE_VIEW_COLUMN(column->GetGtkHandle()); GtkTreeViewColumn *gcolumn = GTK_TREE_VIEW_COLUMN(column->GetGtkHandle());
// Get cell area // Don't attempt to refresh not yet realized tree, it is useless
GtkTreeIter iter; // and results in GTK errors.
iter.stamp = wxgtk_model->stamp; if ( gtk_widget_get_realized(ctrl->GtkGetTreeView()) )
iter.user_data = (gpointer) item.GetID(); {
wxGtkTreePath path(wxgtk_tree_model_get_path( // Get cell area
GTK_TREE_MODEL(wxgtk_model), &iter )); GtkTreeIter iter;
GdkRectangle cell_area; iter.stamp = wxgtk_model->stamp;
gtk_tree_view_get_cell_area( widget, path, gcolumn, &cell_area ); iter.user_data = (gpointer) item.GetID();
wxGtkTreePath path(wxgtk_tree_model_get_path(
GTK_TREE_MODEL(wxgtk_model), &iter ));
GdkRectangle cell_area;
gtk_tree_view_get_cell_area( widget, path, gcolumn, &cell_area );
GtkAdjustment* hadjust = gtk_tree_view_get_hadjustment( widget ); GtkAdjustment* hadjust = gtk_tree_view_get_hadjustment( widget );
double d = gtk_adjustment_get_value( hadjust ); double d = gtk_adjustment_get_value( hadjust );
int xdiff = (int) d; int xdiff = (int) d;
int ydiff = gcolumn->button->allocation.height; int ydiff = gcolumn->button->allocation.height;
// Redraw // Redraw
gtk_widget_queue_draw_area( GTK_WIDGET(widget), gtk_widget_queue_draw_area( GTK_WIDGET(widget),
cell_area.x - xdiff, ydiff + cell_area.y, cell_area.width, cell_area.height ); cell_area.x - xdiff, ydiff + cell_area.y, cell_area.width, cell_area.height );
}
m_internal->ValueChanged( item, model_column ); m_internal->ValueChanged( item, model_column );