aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRob Bradford <rob@o-hand.com>2008-02-19 16:25:47 +0000
committerrob <rob@aea7fca7-3721-49c4-ace3-ac8c44b998bb>2008-02-19 16:25:47 +0000
commit0b09010f6486e0ffa1ec76e0a05adba79aa864c0 (patch)
tree55e27ba9a1b88b20c40f500b40635a61d6dfcf04
parent09c2a59ec84c856bcd89d749a964087dfee02425 (diff)
downloadanjuta-poky-0b09010f6486e0ffa1ec76e0a05adba79aa864c0.tar.gz
anjuta-poky-0b09010f6486e0ffa1ec76e0a05adba79aa864c0.tar.bz2
anjuta-poky-0b09010f6486e0ffa1ec76e0a05adba79aa864c0.zip
2008-02-19 Rob Bradford <rob@openedhand.com>
* src/plugin.c: (anjuta_plugin_sdk_deactivate): Ensure we nullify string pointers after freeing them in the deactivate function and add a comment why we are doing this.
-rw-r--r--ChangeLog6
-rw-r--r--src/plugin.c74
2 files changed, 58 insertions, 22 deletions
diff --git a/ChangeLog b/ChangeLog
index a646ccc..3301e60 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2008-02-19 Rob Bradford <rob@openedhand.com>
+ * src/plugin.c: (anjuta_plugin_sdk_deactivate):
+ Ensure we nullify string pointers after freeing them in the
+ deactivate function and add a comment why we are doing this.
+
+2008-02-19 Rob Bradford <rob@openedhand.com>
+
* README:
Update README.
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;
}