[gtk+] inspector: Be more careful with dead objects
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] inspector: Be more careful with dead objects
- Date: Sun, 25 Oct 2015 17:13:46 +0000 (UTC)
commit f55e3f7eda1d54d1a87a098822cc5e345b2f36db
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Oct 25 13:11:17 2015 -0400
inspector: Be more careful with dead objects
gtk_inspector_object_tree_find_object accesses the type information
of the object, so we can't safely use it on an already decaying
object when we get a weak notify. Instead just walk the tree and
compare pointers, that is safe.
https://bugzilla.gnome.org/show_bug.cgi?id=756852
gtk/inspector/object-tree.c | 24 +++++++++++++++++++++---
1 files changed, 21 insertions(+), 3 deletions(-)
---
diff --git a/gtk/inspector/object-tree.c b/gtk/inspector/object-tree.c
index e3fa925..c124c79 100644
--- a/gtk/inspector/object-tree.c
+++ b/gtk/inspector/object-tree.c
@@ -607,14 +607,32 @@ on_selection_changed (GtkTreeSelection *selection,
g_signal_emit (wt, signals[OBJECT_SELECTED], 0, object);
}
+static gboolean
+remove_cb (GtkTreeModel *model,
+ GtkTreePath *path,
+ GtkTreeIter *iter,
+ gpointer data)
+{
+ GObject *dead_object = data;
+ GObject *lookup;
+
+ gtk_tree_model_get (model, iter, OBJECT, &lookup, -1);
+
+ if (lookup == dead_object)
+ {
+ gtk_tree_store_remove (GTK_TREE_STORE (model), iter);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
static void
gtk_object_tree_remove_dead_object (gpointer data, GObject *dead_object)
{
GtkInspectorObjectTree *wt = data;
- GtkTreeIter iter;
- if (gtk_inspector_object_tree_find_object (wt, dead_object, &iter))
- gtk_tree_store_remove (wt->priv->model, &iter);
+ gtk_tree_model_foreach (GTK_TREE_MODEL (wt->priv->model), remove_cb, dead_object);
}
static gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]