[glade3] Allow destroying (and recreation) of GladeApp object



commit 66e2d573486fadc07a3537508248ca6cb2db1778
Author: Johannes Schmid <jhs gnome org>
Date:   Wed May 12 18:30:31 2010 +0200

    Allow destroying (and recreation) of GladeApp object
    
    That is what happens when a glade file is loaded in anjuta, then closes and opened again.
    Currently, we hold an extra reference on GladeApp to avoid destroying it but that's not clean
    of course and leaves a big mem leak.
    We cannot free the catalogs though as they register GTypes that we cannot unregister. Thus,
    we have to keep them in memory once they were loaded.

 gladeui/glade-app.c           |   14 +++++++-------
 gladeui/glade-catalog.c       |    6 +++++-
 gladeui/glade-signal-editor.c |    5 -----
 3 files changed, 12 insertions(+), 13 deletions(-)
---
diff --git a/gladeui/glade-app.c b/gladeui/glade-app.c
index 3570c40..8c52bb1 100644
--- a/gladeui/glade-app.c
+++ b/gladeui/glade-app.c
@@ -106,6 +106,7 @@ static gchar *pixmaps_dir  = NULL;
 static gchar *locale_dir   = NULL;
 
 static GladeApp *singleton_app = NULL;
+static gboolean check_initialised = FALSE;
 
 static void glade_init_check (void);
 
@@ -199,8 +200,9 @@ glade_app_finalize (GObject *app)
 	g_free (modules_dir);
 	g_free (pixmaps_dir);	
 	g_free (locale_dir);
-	
-	glade_catalog_destroy_all ();
+
+	singleton_app = NULL;
+	check_initialised = FALSE;
 
 	G_OBJECT_CLASS (glade_app_parent_class)->finalize (app);
 }
@@ -396,10 +398,8 @@ build_package_paths (void)
 /* initialization function for libgladeui (not GladeApp) */
 static void
 glade_init_check (void)
-{
-	static gboolean initialised = FALSE;
-	
-	if (initialised)
+{	
+	if (check_initialised)
 		return;
 
 	/* Make sure path accessors work on osx */
@@ -410,7 +410,7 @@ glade_init_check (void)
 	bindtextdomain (GETTEXT_PACKAGE, locale_dir);
 	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
 
-	initialised = TRUE;
+	check_initialised = TRUE;
 }
 
 static void
diff --git a/gladeui/glade-catalog.c b/gladeui/glade-catalog.c
index 60417d7..fecbd3e 100644
--- a/gladeui/glade-catalog.c
+++ b/gladeui/glade-catalog.c
@@ -533,6 +533,11 @@ glade_catalog_load_all (void)
 	gchar        **split;
 	GString       *icon_warning = NULL;
 	gint           i;
+
+
+	/* Make sure we don't init the catalogs twice */
+	if (loaded_catalogs)
+		return loaded_catalogs;
 	
 	/* First load catalogs from user specified directories ... */
 	if ((search_path = g_getenv (GLADE_ENV_CATALOG_PATH)) != NULL)
@@ -724,7 +729,6 @@ catalog_destroy (GladeCatalog *catalog)
 
 	if (catalog->adaptors)
 	{
-		/* TODO: free adaptors */
 		g_list_free (catalog->adaptors);
 	}
 
diff --git a/gladeui/glade-signal-editor.c b/gladeui/glade-signal-editor.c
index 862c157..b33bf78 100644
--- a/gladeui/glade-signal-editor.c
+++ b/gladeui/glade-signal-editor.c
@@ -1446,11 +1446,6 @@ glade_signal_editor_dispose (GObject *object)
 	
 	glade_signal_editor_load_widget (self, NULL);
 
-	if (priv->handler_store)
-		g_object_unref (priv->handler_store);
-	if (priv->userdata_store)
-		g_object_unref (priv->userdata_store);
-
 	G_OBJECT_CLASS (glade_signal_editor_parent_class)->dispose (object);
 }
 



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