[anjuta] anjuta: unload all plugins before closing a window.



commit 84ad3c74bc59b6247bad0518c430b1ffa92a09d4
Author: Carl-Anton Ingmarsson <ca ingmarsson gmail com>
Date:   Sun Nov 25 21:49:45 2012 +0100

    anjuta: unload all plugins before closing a window.
    
    Since all Anjuta windows are in the same process it's now important that we properly unload
    all plugins when destroying the window. If we don't the plugins may have active
    timeouts/asynchronous operations etc. that when triggered reference plugins/widgets that
    are no longer alive.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=689054

 src/anjuta-application.c |   38 ++++++++++++++++++--------------------
 1 files changed, 18 insertions(+), 20 deletions(-)
---
diff --git a/src/anjuta-application.c b/src/anjuta-application.c
index a756695..7fdc856 100644
--- a/src/anjuta-application.c
+++ b/src/anjuta-application.c
@@ -62,10 +62,11 @@ struct _AnjutaApplicationPrivate {
 static gboolean
 on_anjuta_delete_event (AnjutaWindow *win, GdkEvent *event, gpointer user_data)
 {
-	AnjutaApplication *app = ANJUTA_APPLICATION (user_data);
+	AnjutaApplication *app = user_data;
+	AnjutaApplicationPrivate *priv = app->priv;
+
 	AnjutaPluginManager *plugin_manager;
 	AnjutaProfileManager *profile_manager;
-	AnjutaProfile *current_profile;
 	AnjutaSavePrompt *save_prompt;
 	gchar *remembered_plugins;
 
@@ -101,6 +102,8 @@ on_anjuta_delete_event (AnjutaWindow *win, GdkEvent *event, gpointer user_data)
 				break;
 		}
 	}
+	gtk_widget_destroy (GTK_WIDGET (save_prompt));
+
 	/* Wait for files to be really saved (asyncronous operation) */
 	if (win->save_count > 0)
 	{
@@ -111,30 +114,25 @@ on_anjuta_delete_event (AnjutaWindow *win, GdkEvent *event, gpointer user_data)
 		}
 	}
 
-	/* If current active profile is "user", save current session as
-	 * default session
-	 */
-	current_profile = anjuta_profile_manager_get_current (profile_manager);
-	if (strcmp (anjuta_profile_get_name (current_profile), "user") == 0)
-	{
-		gchar *session_dir;
-		session_dir = USER_SESSION_PATH_NEW;
-		anjuta_shell_session_save (ANJUTA_SHELL (win), session_dir, NULL);
-		g_free (session_dir);
-	}
-
 	anjuta_shell_notify_exit (ANJUTA_SHELL (win), NULL);
 
-	gtk_widget_destroy (GTK_WIDGET (save_prompt));
+	/* Close the profile manager which will emit "profile-descoped" and release
+	 * all previous profiles. */
+	anjuta_profile_manager_close (profile_manager);
 
-	/* Shutdown */
-	if (anjuta_application_get_proper_shutdown (app))
+	/* If this is the last window we can just quit the application and skip
+	 * deactivating plugins and other cleanup. */
+	if (!priv->proper_shutdown &&
+	    g_list_length (gtk_application_get_windows (GTK_APPLICATION (app))) == 1)
 	{
-		gtk_widget_hide (GTK_WIDGET (win));
-		anjuta_plugin_manager_unload_all_plugins
-			(anjuta_shell_get_plugin_manager (ANJUTA_SHELL (win), NULL));
+		g_application_quit (G_APPLICATION (app));
+		return TRUE;
 	}
 
+	/* Hide the window while unloading all the plugins. */
+	gtk_widget_hide (GTK_WIDGET (win));
+	anjuta_plugin_manager_unload_all_plugins (plugin_manager);
+
 	return FALSE;
 }
 



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