[gtkmm] Gtk::TreeView: Fix a crash in get_tooltip_context_path()



commit 44c834448720d3cb55fbc795a707087ce79aabc2
Author: Philipp Lenk <fillius 2d-rp de>
Date:   Fri Jan 1 16:50:37 2016 +0100

    Gtk::TreeView: Fix a crash in get_tooltip_context_path()
    
    * gtk/src/treeview.ccg: Don't create a temporary TreeModel::Path object.
    Its GtkTreePath is deleted twice, if gtk_tree_view_get_tooltip_context()
    returns false. Bug #760030.
    
    This is equivalent to commit fdbdce42f4a4405e9709f5a206c9df96c2adb6e4,
    which fixed the same issue in IconView.

 gtk/src/treeview.ccg |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)
---
diff --git a/gtk/src/treeview.ccg b/gtk/src/treeview.ccg
index 8ee904a..5de2ddc 100644
--- a/gtk/src/treeview.ccg
+++ b/gtk/src/treeview.ccg
@@ -412,11 +412,7 @@ TreeView::get_tooltip_context_path(int& x, int& y,
                                    bool keyboard_tip,
                                    TreeModel::Path& path)
 {
-  //It's cleaner to use a temporary C++ object and get a C pointer to it,
-  //because GtkTreePath is a simple struct, not a GtkObject, so
-  //gtk_tree_path_new() would be necessary. markoa.
-  TreeModel::Path tmp_path;
-  auto cpath = tmp_path.gobj();
+  GtkTreePath* cpath = nullptr;
 
   gboolean result =
     gtk_tree_view_get_tooltip_context(gobj(),
@@ -426,6 +422,8 @@ TreeView::get_tooltip_context_path(int& x, int& y,
                                       &cpath,
                                       nullptr);
 
+  //If result is false, cpath is not modified, it's still nullptr.
+  //wrap() can handle that situation.
   path = Glib::wrap(cpath, false /* take_copy=false */);
 
   return result;


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