[gedit] Fix leaking the GeditApp
- From: Garrett Regier <gregier src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit] Fix leaking the GeditApp
- Date: Wed, 25 Jun 2014 13:44:14 +0000 (UTC)
commit ee457a67c5c57a867dc397280d4c84cfb27021ed
Author: Garrett Regier <garrettregier gmail com>
Date: Wed Jun 25 06:43:27 2014 -0700
Fix leaking the GeditApp
This was caused due to a reference cycle with GeditAppActivatable.
Also report a debug message if the GeditApp is leaked.
gedit/gedit.c | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)
---
diff --git a/gedit/gedit.c b/gedit/gedit.c
index 8561e13..5bd4066 100644
--- a/gedit/gedit.c
+++ b/gedit/gedit.c
@@ -21,7 +21,9 @@
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
+
#include <glib.h>
+
#include "gedit-app.h"
#ifdef OS_OSX
#include "gedit-app-osx.h"
@@ -33,6 +35,8 @@
#endif
#endif
+#include "gedit-debug.h"
+
#ifdef G_OS_WIN32
#include <gmodule.h>
static GModule *libgedit_dll = NULL;
@@ -113,8 +117,20 @@ main (int argc, char *argv[])
status = g_application_run (G_APPLICATION (app), argc, argv);
+ /* Break reference cycles caused by the PeasExtensionSet
+ * for GeditAppActivatable which holds a ref on the GeditApp
+ */
+ g_object_run_dispose (G_OBJECT (app));
+
+ g_object_add_weak_pointer (G_OBJECT (app), (gpointer *) &app);
g_object_unref (app);
+ if (app != NULL)
+ {
+ gedit_debug_message (DEBUG_APP, "Leaking with %i refs",
+ G_OBJECT (app)->ref_count);
+ }
+
#ifdef G_OS_WIN32
gedit_w32_unload_private_dll ();
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]