aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/plugin.c74
1 files changed, 52 insertions, 22 deletions
diff --git a/src/plugin.c b/src/plugin.c
index 25ad2cd..85b3158 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -1518,55 +1518,76 @@ anjuta_plugin_sdk_deactivate (AnjutaPlugin *plugin)
sp->remote_msg_view = NULL;
}
+
+ if (sp->buildable)
+ {
+ ianjuta_buildable_reset_commands (sp->buildable, &error);
+
+ if (error)
+ {
+ g_warning ("Error whilst resetting buildable commands: %s",
+ error->message);
+ g_clear_error (&error);
+ }
+ }
+
+ anjuta_preferences_notify_remove (sp->prefs, sp->sdk_root_notifyid);
+ anjuta_preferences_notify_remove (sp->prefs, sp->triplet_notifyid);
+ anjuta_preferences_notify_remove (sp->prefs, sp->rootfs_notifyid);
+ anjuta_preferences_notify_remove (sp->prefs, sp->kernel_notifyid);
+
+ anjuta_plugin_remove_watch (plugin, sp->project_root_uri_watch, FALSE);
+
+ g_signal_handlers_disconnect_by_func (plugin->shell, shell_session_load_cb, sp);
+ g_signal_handlers_disconnect_by_func (plugin->shell, shell_session_save_cb, sp);
+
+
+ /*
+ * Do lots of things you'd normally expect to see in a dispose/finalize,
+ * i.e. to free up memory but because a plugin won't get disposed/finalized
+ * when being turned off we want to be nice and free up memory.
+ */
+
if (sp->deploy_launcher)
{
g_object_unref (sp->deploy_launcher);
+ sp->deploy_launcher = NULL;
}
if (sp->qemu_launcher)
{
g_object_unref (sp->qemu_launcher);
+ sp->qemu_launcher = NULL;
}
if (sp->remote_launcher)
{
g_object_unref (sp->remote_launcher);
+ sp->remote_launcher = NULL;
}
if (sp->remote_gdb_launcher)
{
g_object_unref (sp->remote_gdb_launcher);
+ sp->remote_gdb_launcher = NULL;
}
if (sp->oprofileui_launcher)
{
g_object_unref (sp->oprofileui_launcher);
+ sp->oprofileui_launcher = NULL;
}
- if (sp->buildable)
+ if (sp->prefs_icon)
{
- ianjuta_buildable_reset_commands (sp->buildable, &error);
-
- if (error)
- {
- g_warning ("Error whilst resetting buildable commands: %s",
- error->message);
- g_clear_error (&error);
- }
+ g_object_unref (sp->prefs_icon);
+ sp->prefs_icon = NULL;
}
- anjuta_preferences_notify_remove (sp->prefs, sp->sdk_root_notifyid);
- anjuta_preferences_notify_remove (sp->prefs, sp->triplet_notifyid);
- anjuta_preferences_notify_remove (sp->prefs, sp->rootfs_notifyid);
- anjuta_preferences_notify_remove (sp->prefs, sp->kernel_notifyid);
-
- anjuta_plugin_remove_watch (plugin, sp->project_root_uri_watch, FALSE);
-
- g_signal_handlers_disconnect_by_func (plugin->shell, shell_session_load_cb, sp);
- g_signal_handlers_disconnect_by_func (plugin->shell, shell_session_save_cb, sp);
-
- if (sp->prefs_icon)
- g_object_unref (sp->prefs_icon);
+ /*
+ * Must set these to NULL because the plugin object might get reused after
+ * deactivation.
+ */
g_free (sp->sdk_root);
g_free (sp->triplet);
@@ -1574,10 +1595,19 @@ anjuta_plugin_sdk_deactivate (AnjutaPlugin *plugin)
g_free (sp->rootfs);
g_free (sp->project_root_uri);
g_free (sp->path_component);
-
g_free (sp->gdb_local_path);
g_free (sp->gdb_remote_command);
g_free (sp->remote_command);
+
+ sp->sdk_root = NULL;
+ sp->triplet = NULL;
+ sp->kernel = NULL;
+ sp->rootfs = NULL;
+ sp->project_root_uri = NULL;
+ sp->path_component = NULL;
+ sp->gdb_local_path = NULL;
+ sp->gdb_remote_command = NULL;
+ sp->remote_command = NULL;
return TRUE;
}