From e1d8137e70ab7697a27b9439476e83ebd9cad1d0 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 24 Jan 2018 23:08:15 +0100 Subject: [PATCH] Use wxGtkTreePath instead of calling gtk_tree_path_free() Use RAII helper class instead of freeing the object manually. Also add a couple of "const"s and other minor style fixes. No real changes. --- src/gtk/dataview.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/gtk/dataview.cpp b/src/gtk/dataview.cpp index ee482cd68c..91b7621fde 100644 --- a/src/gtk/dataview.cpp +++ b/src/gtk/dataview.cpp @@ -1902,10 +1902,6 @@ bool wxGtkDataViewModelNotifier::Cleared() // has been deleted so call row_deleted() for every // child of root... - int count = m_internal->iter_n_children( NULL ); // number of children of root - - GtkTreePath *path = gtk_tree_path_new_first(); // points to root - // It is important to avoid selection changed events being generated from // here as they would reference the already deleted model items, which // would result in crashes in any code attempting to handle these events. @@ -1917,11 +1913,12 @@ bool wxGtkDataViewModelNotifier::Cleared() const gint stampOrig = wxgtk_model->stamp; wxgtk_model->stamp = 0; - int i; - for (i = 0; i < count; i++) - gtk_tree_model_row_deleted( GTK_TREE_MODEL(wxgtk_model), path ); - - gtk_tree_path_free( path ); + { + wxGtkTreePath path(gtk_tree_path_new_first()); // points to root + const int count = m_internal->iter_n_children( NULL ); // number of children of root + for (int i = 0; i < count; i++) + gtk_tree_model_row_deleted( GTK_TREE_MODEL(wxgtk_model), path ); + } wxgtk_model->stamp = stampOrig;