[gtk+] GtkSearchEngine: Avoid a crash
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] GtkSearchEngine: Avoid a crash
- Date: Fri, 19 Jun 2015 04:49:06 +0000 (UTC)
commit ed50772b4154fb7fa3d48be3c37785199ed21276
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Jun 19 00:32:49 2015 -0400
GtkSearchEngine: Avoid a crash
Add a destroy notify for the data of the callback, so we don't
end up leaving a dangling pointer behind for a short while if
the native engine is finalized before the simple one. This
was showing up as crash when typing and backspacing in the
search entry of the file chooser.
gtk/gtksearchengine.c | 3 ++-
gtk/gtksearchenginesimple.c | 15 ++++++++++++++-
gtk/gtksearchenginesimple.h | 3 ++-
3 files changed, 18 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtksearchengine.c b/gtk/gtksearchengine.c
index de992e5..67110f9 100644
--- a/gtk/gtksearchengine.c
+++ b/gtk/gtksearchengine.c
@@ -334,7 +334,8 @@ _gtk_search_engine_new (void)
connect_engine_signals (engine->priv->native, engine);
_gtk_search_engine_simple_set_indexed_cb (GTK_SEARCH_ENGINE_SIMPLE (engine->priv->simple),
_gtk_search_engine_tracker_is_indexed,
- engine->priv->native);
+ g_object_ref (engine->priv->native),
+ g_object_unref);
}
#endif
diff --git a/gtk/gtksearchenginesimple.c b/gtk/gtksearchenginesimple.c
index b405aef..00543ea 100644
--- a/gtk/gtksearchenginesimple.c
+++ b/gtk/gtksearchenginesimple.c
@@ -57,6 +57,7 @@ struct _GtkSearchEngineSimplePrivate
GtkSearchEngineSimpleIsIndexed is_indexed_callback;
gpointer is_indexed_data;
+ GDestroyNotify is_indexed_data_destroy;
};
@@ -83,6 +84,13 @@ gtk_search_engine_simple_dispose (GObject *object)
priv->active_search = NULL;
}
+ if (priv->is_indexed_data_destroy)
+ priv->is_indexed_data_destroy (priv->is_indexed_data);
+
+ priv->is_indexed_callback = NULL;
+ priv->is_indexed_data = NULL;
+ priv->is_indexed_data_destroy = NULL;
+
G_OBJECT_CLASS (_gtk_search_engine_simple_parent_class)->dispose (object);
}
@@ -365,8 +373,13 @@ _gtk_search_engine_simple_new (void)
void
_gtk_search_engine_simple_set_indexed_cb (GtkSearchEngineSimple *engine,
GtkSearchEngineSimpleIsIndexed callback,
- gpointer data)
+ gpointer data,
+ GDestroyNotify destroy)
{
+ if (engine->priv->is_indexed_data_destroy)
+ engine->priv->is_indexed_data_destroy (engine->priv->is_indexed_data);
+
engine->priv->is_indexed_callback = callback;
engine->priv->is_indexed_data = data;
+ engine->priv->is_indexed_data_destroy = destroy;
}
diff --git a/gtk/gtksearchenginesimple.h b/gtk/gtksearchenginesimple.h
index 83a60b1..421b208 100644
--- a/gtk/gtksearchenginesimple.h
+++ b/gtk/gtksearchenginesimple.h
@@ -57,7 +57,8 @@ typedef gboolean (*GtkSearchEngineSimpleIsIndexed) (GFile *location, gpointer da
void _gtk_search_engine_simple_set_indexed_cb (GtkSearchEngineSimple *engine,
GtkSearchEngineSimpleIsIndexed callback,
- gpointer data);
+ gpointer data,
+ GDestroyNotify destroy);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]