[anjuta/system-db-refactor: 20/22] language-support-cpp-java: Fix crash when loading user_packages and fix preferences.



commit 9cd28fb549f0ed4158054a3575a298b31197e1b5
Author: Johannes Schmid <jhs gnome org>
Date:   Thu Mar 3 17:11:55 2011 +0100

    language-support-cpp-java: Fix crash when loading user_packages and fix preferences.

 plugins/language-support-cpp-java/cpp-packages.c |   10 ++++++++--
 plugins/language-support-cpp-java/plugin.c       |   15 ++++++++-------
 2 files changed, 16 insertions(+), 9 deletions(-)
---
diff --git a/plugins/language-support-cpp-java/cpp-packages.c b/plugins/language-support-cpp-java/cpp-packages.c
index 4b8d5fe..97cf158 100644
--- a/plugins/language-support-cpp-java/cpp-packages.c
+++ b/plugins/language-support-cpp-java/cpp-packages.c
@@ -175,6 +175,7 @@ on_queue_finished (AnjutaCommandQueue* queue, CppPackages* packages)
 {
 	g_object_unref (queue);
 	packages->loading = FALSE;
+	g_object_unref (packages);
 }
 
 static void
@@ -251,6 +252,7 @@ cpp_packages_load_real (CppPackages* packages, GError* error, IAnjutaProjectMana
 		cpp_packages_activate_package (sm, pkg->data, &packages_to_add);
 	}
 	g_list_free (pkgs);
+	packages->queue = anjuta_command_queue_new (ANJUTA_COMMAND_QUEUE_EXECUTE_MANUAL);
 	for (pkg = packages_to_add; pkg != NULL; pkg = g_list_next (pkg))
 	{
 		PackageData* pkg_data = pkg->data;
@@ -264,6 +266,8 @@ cpp_packages_load_real (CppPackages* packages, GError* error, IAnjutaProjectMana
 	g_list_free (packages_to_add);
 
 	g_signal_connect (packages->queue, "finished", G_CALLBACK (on_queue_finished), packages);
+	/* Make sure the pointer is valid when the queue finishes */
+	g_object_ref (packages);
 	anjuta_command_queue_start (packages->queue);
 }
 
@@ -298,6 +302,7 @@ cpp_packages_load_user (CppPackages* packages, gboolean force)
 		g_strfreev (pkgs);
 		g_free (packages_str);
 
+		packages->queue = anjuta_command_queue_new (ANJUTA_COMMAND_QUEUE_EXECUTE_MANUAL);
 		for (pkg = packages_to_add; pkg != NULL; pkg = g_list_next (pkg))
 		{
 			PackageData* pkg_data = pkg->data;
@@ -313,7 +318,9 @@ cpp_packages_load_user (CppPackages* packages, gboolean force)
 		g_object_set_data (G_OBJECT (shell), 
 		                   USER_LOADED, GINT_TO_POINTER (TRUE));
 
-		g_signal_connect (packages->queue, "finished", G_CALLBACK (on_queue_finished), NULL);
+		g_signal_connect (packages->queue, "finished", G_CALLBACK (on_queue_finished), packages);
+		/* Make sure the pointer is valid when the queue finishes */
+		g_object_ref (packages);
 		anjuta_command_queue_start (packages->queue);
 	}
 }
@@ -362,7 +369,6 @@ cpp_packages_load (CppPackages* packages, gboolean force)
 static void
 cpp_packages_init (CppPackages *packages)
 {	
-	packages->queue = anjuta_command_queue_new (ANJUTA_COMMAND_QUEUE_EXECUTE_MANUAL);
 	packages->loading = FALSE;
 }
 
diff --git a/plugins/language-support-cpp-java/plugin.c b/plugins/language-support-cpp-java/plugin.c
index 94ee40b..94c83e6 100644
--- a/plugins/language-support-cpp-java/plugin.c
+++ b/plugins/language-support-cpp-java/plugin.c
@@ -1384,17 +1384,17 @@ on_project_packages_toggled (GtkToggleButton* button,
                              CppJavaPlugin* plugin)
 {
 	GtkWidget* pkg_config;
-	gboolean sensitive = !gtk_toggle_button_get_active (button);
+	gboolean active = gtk_toggle_button_get_active (button);
 	pkg_config = GTK_WIDGET (gtk_builder_get_object (plugin->bxml, PREF_WIDGET_PKG_CONFIG));
 
-	gtk_widget_set_sensitive (pkg_config, sensitive);
-	anjuta_pkg_config_chooser_show_active_only (ANJUTA_PKG_CONFIG_CHOOSER (pkg_config),
-	                                            !sensitive);
+	gtk_widget_set_sensitive (pkg_config, !active);
 
 	anjuta_pkg_config_chooser_set_active_packages (ANJUTA_PKG_CONFIG_CHOOSER (pkg_config),
 	                                               NULL);
-	if (!sensitive)
+	if (!active)
 	{
+		anjuta_pkg_config_chooser_show_active_only (ANJUTA_PKG_CONFIG_CHOOSER (pkg_config),
+		                                            FALSE);
 		cpp_java_plugin_select_user_packages (plugin, ANJUTA_PKG_CONFIG_CHOOSER (pkg_config));
 		cpp_packages_load (plugin->packages, TRUE);
 	}
@@ -1402,6 +1402,9 @@ on_project_packages_toggled (GtkToggleButton* button,
 	{
 		anjuta_pkg_config_chooser_set_active_packages (ANJUTA_PKG_CONFIG_CHOOSER (pkg_config),
 		                                               NULL);
+		anjuta_pkg_config_chooser_show_active_only (ANJUTA_PKG_CONFIG_CHOOSER (pkg_config),
+		                                            TRUE);
+
 	}
 }
 
@@ -1421,7 +1424,6 @@ cpp_java_plugin_update_user_packages (CppJavaPlugin* plugin,
 		}
 		pkg_string = g_string_append (pkg_string, pkg->data);
 	}
-	g_message ("Packages: %s", pkg_string->str);
 	g_settings_set_string (plugin->settings, PREF_USER_PACKAGES,
 	                       pkg_string->str);
 	g_string_free (pkg_string, TRUE);
@@ -1496,7 +1498,6 @@ ipreferences_merge (IAnjutaPreferences* ipref, AnjutaPreferences* prefs,
 	toggle = GTK_WIDGET (gtk_builder_get_object (plugin->bxml, PREF_WIDGET_PACKAGES));
 	g_signal_connect (toggle, "toggled", G_CALLBACK (on_project_packages_toggled),
 	                  plugin);
-	on_autocompletion_toggled (GTK_TOGGLE_BUTTON (toggle), plugin);
 	on_project_packages_toggled (GTK_TOGGLE_BUTTON (toggle), plugin);
 	
 	pkg_config = GTK_WIDGET (gtk_builder_get_object (plugin->bxml, PREF_WIDGET_PKG_CONFIG));



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