[gedit] Use g_clear_object in dispose
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit] Use g_clear_object in dispose
- Date: Sat, 17 Dec 2011 14:45:39 +0000 (UTC)
commit 0c14f47c04a9add7792b4ae7347a822cbb80fa31
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Sat Dec 17 15:46:42 2011 +0100
Use g_clear_object in dispose
gedit/dialogs/gedit-encodings-dialog.c | 6 +--
gedit/dialogs/gedit-preferences-dialog.c | 6 +--
gedit/gedit-animated-overlay.c | 6 +--
gedit/gedit-app.c | 23 ++--------
gedit/gedit-dbus.c | 20 +--------
gedit/gedit-document-loader.c | 40 +++----------------
gedit/gedit-document-output-stream.c | 6 +--
gedit/gedit-document-saver.c | 40 +++----------------
gedit/gedit-document.c | 27 ++-----------
gedit/gedit-documents-panel.c | 6 +--
gedit/gedit-encodings-combo-box.c | 13 +-----
gedit/gedit-file-chooser-dialog.c | 6 +--
gedit/gedit-history-entry.c | 6 +--
gedit/gedit-notebook.c | 13 +-----
gedit/gedit-plugins-engine.c | 6 +--
gedit/gedit-print-job.c | 13 +-----
gedit/gedit-settings.c | 31 +++-----------
gedit/gedit-tab.c | 13 +-----
gedit/gedit-view.c | 13 +-----
gedit/gedit-window.c | 47 +++------------------
plugins/changecase/gedit-changecase-plugin.c | 13 +-----
plugins/checkupdate/gedit-check-update-plugin.c | 20 +--------
plugins/docinfo/gedit-docinfo-plugin.c | 13 +-----
plugins/filebrowser/gedit-file-bookmarks-store.c | 6 +--
plugins/filebrowser/gedit-file-browser-plugin.c | 27 ++-----------
plugins/modelines/gedit-modeline-plugin.c | 6 +--
plugins/sort/gedit-sort-plugin.c | 13 +-----
plugins/spell/gedit-spell-checker-dialog.c | 17 ++++++--
plugins/spell/gedit-spell-plugin.c | 13 +-----
plugins/time/gedit-time-plugin.c | 20 +--------
plugins/zeitgeist/gedit-zeitgeist-plugin.c | 17 ++------
31 files changed, 91 insertions(+), 415 deletions(-)
---
diff --git a/gedit/dialogs/gedit-encodings-dialog.c b/gedit/dialogs/gedit-encodings-dialog.c
index 19fe226..abd2e96 100644
--- a/gedit/dialogs/gedit-encodings-dialog.c
+++ b/gedit/dialogs/gedit-encodings-dialog.c
@@ -80,11 +80,7 @@ gedit_encodings_dialog_dispose (GObject *object)
{
GeditEncodingsDialogPrivate *priv = GEDIT_ENCODINGS_DIALOG (object)->priv;
- if (priv->enc_settings != NULL)
- {
- g_object_unref (priv->enc_settings);
- priv->enc_settings = NULL;
- }
+ g_clear_object (&priv->enc_settings);
G_OBJECT_CLASS (gedit_encodings_dialog_parent_class)->dispose (object);
}
diff --git a/gedit/dialogs/gedit-preferences-dialog.c b/gedit/dialogs/gedit-preferences-dialog.c
index c488574..881fc11 100644
--- a/gedit/dialogs/gedit-preferences-dialog.c
+++ b/gedit/dialogs/gedit-preferences-dialog.c
@@ -133,11 +133,7 @@ gedit_preferences_dialog_dispose (GObject *object)
{
GeditPreferencesDialog *dlg = GEDIT_PREFERENCES_DIALOG (object);
- if (dlg->priv->editor != NULL)
- {
- g_object_unref (dlg->priv->editor);
- dlg->priv->editor = NULL;
- }
+ g_clear_object (&dlg->priv->editor);
G_OBJECT_CLASS (gedit_preferences_dialog_parent_class)->dispose (object);
}
diff --git a/gedit/gedit-animated-overlay.c b/gedit/gedit-animated-overlay.c
index 8160f2f..173148d 100644
--- a/gedit/gedit-animated-overlay.c
+++ b/gedit/gedit-animated-overlay.c
@@ -36,11 +36,7 @@ gedit_animated_overlay_dispose (GObject *object)
{
GeditAnimatedOverlayPrivate *priv = GEDIT_ANIMATED_OVERLAY (object)->priv;
- if (priv->stage != NULL)
- {
- g_object_unref (priv->stage);
- priv->stage = NULL;
- }
+ g_clear_object (&priv->stage);
G_OBJECT_CLASS (gedit_animated_overlay_parent_class)->dispose (object);
}
diff --git a/gedit/gedit-app.c b/gedit/gedit-app.c
index ce6d726..e5ea77f 100644
--- a/gedit/gedit-app.c
+++ b/gedit/gedit-app.c
@@ -111,25 +111,12 @@ gedit_app_dispose (GObject *object)
{
GeditApp *app = GEDIT_APP (object);
- if (app->priv->window_settings != NULL)
- {
- g_object_unref (app->priv->window_settings);
- app->priv->window_settings = NULL;
- }
+ g_clear_object (&app->priv->window_settings);
+ g_clear_object (&app->priv->settings);
- if (app->priv->settings != NULL)
- {
- g_object_unref (app->priv->settings);
- app->priv->settings = NULL;
- }
-
- if (app->priv->extensions != NULL)
- {
- /* Note that unreffing the extensions will automatically remove
- all extensions which in turn will deactivate the extension */
- g_object_unref (app->priv->extensions);
- app->priv->extensions = NULL;
- }
+ /* Note that unreffing the extensions will automatically remove
+ all extensions which in turn will deactivate the extension */
+ g_clear_object (&app->priv->extensions);
G_OBJECT_CLASS (gedit_app_parent_class)->dispose (object);
}
diff --git a/gedit/gedit-dbus.c b/gedit/gedit-dbus.c
index 64aafe8..e182433 100644
--- a/gedit/gedit-dbus.c
+++ b/gedit/gedit-dbus.c
@@ -160,23 +160,9 @@ gedit_dbus_dispose (GObject *object)
dbus->priv->stdin_cancellable = NULL;
}
- if (dbus->priv->stdin_fifo)
- {
- g_object_unref (dbus->priv->stdin_fifo);
- dbus->priv->stdin_fifo = NULL;
- }
-
- if (dbus->priv->stdin_out_stream)
- {
- g_object_unref (dbus->priv->stdin_out_stream);
- dbus->priv->stdin_out_stream = NULL;
- }
-
- if (dbus->priv->stdin_in_stream)
- {
- g_object_unref (dbus->priv->stdin_in_stream);
- dbus->priv->stdin_in_stream = NULL;
- }
+ g_clear_object (&dbus->priv->stdin_fifo);
+ g_clear_object (&dbus->priv->stdin_out_stream);
+ g_clear_object (&dbus->priv->stdin_in_stream);
G_OBJECT_CLASS (gedit_dbus_parent_class)->dispose (object);
}
diff --git a/gedit/gedit-document-loader.c b/gedit/gedit-document-loader.c
index ba77950..3d367f0 100644
--- a/gedit/gedit-document-loader.c
+++ b/gedit/gedit-document-loader.c
@@ -210,41 +210,13 @@ gedit_document_loader_dispose (GObject *object)
priv->cancellable = NULL;
}
- if (priv->stream != NULL)
- {
- g_object_unref (priv->stream);
- priv->stream = NULL;
- }
-
- if (priv->output != NULL)
- {
- g_object_unref (priv->output);
- priv->output = NULL;
- }
-
- if (priv->error != NULL)
- {
- g_error_free (priv->error);
- priv->error = NULL;
- }
+ g_clear_error (&priv->error);
- if (priv->info != NULL)
- {
- g_object_unref (priv->info);
- priv->info = NULL;
- }
-
- if (priv->location != NULL)
- {
- g_object_unref (priv->location);
- priv->location = NULL;
- }
-
- if (priv->enc_settings != NULL)
- {
- g_object_unref (priv->enc_settings);
- priv->enc_settings = NULL;
- }
+ g_clear_object (&priv->stream);
+ g_clear_object (&priv->output);
+ g_clear_object (&priv->info);
+ g_clear_object (&priv->location);
+ g_clear_object (&priv->enc_settings);
G_OBJECT_CLASS (gedit_document_loader_parent_class)->dispose (object);
}
diff --git a/gedit/gedit-document-output-stream.c b/gedit/gedit-document-output-stream.c
index 0e3bae2..0e4c984 100644
--- a/gedit/gedit-document-output-stream.c
+++ b/gedit/gedit-document-output-stream.c
@@ -144,11 +144,7 @@ gedit_document_output_stream_dispose (GObject *object)
{
GeditDocumentOutputStream *stream = GEDIT_DOCUMENT_OUTPUT_STREAM (object);
- if (stream->priv->charset_conv != NULL)
- {
- g_object_unref (stream->priv->charset_conv);
- stream->priv->charset_conv = NULL;
- }
+ g_clear_object (&stream->priv->charset_conv);
G_OBJECT_CLASS (gedit_document_output_stream_parent_class)->dispose (object);
}
diff --git a/gedit/gedit-document-saver.c b/gedit/gedit-document-saver.c
index 66932aa..d97b985 100644
--- a/gedit/gedit-document-saver.c
+++ b/gedit/gedit-document-saver.c
@@ -202,41 +202,13 @@ gedit_document_saver_dispose (GObject *object)
priv->cancellable = NULL;
}
- if (priv->error != NULL)
- {
- g_error_free (priv->error);
- priv->error = NULL;
- }
-
- if (priv->stream != NULL)
- {
- g_object_unref (priv->stream);
- priv->stream = NULL;
- }
-
- if (priv->input != NULL)
- {
- g_object_unref (priv->input);
- priv->input = NULL;
- }
+ g_clear_error (&priv->error);
- if (priv->info != NULL)
- {
- g_object_unref (priv->info);
- priv->info = NULL;
- }
-
- if (priv->location != NULL)
- {
- g_object_unref (priv->location);
- priv->location = NULL;
- }
-
- if (priv->editor_settings != NULL)
- {
- g_object_unref (priv->editor_settings);
- priv->editor_settings = NULL;
- }
+ g_clear_object (&priv->stream);
+ g_clear_object (&priv->input);
+ g_clear_object (&priv->info);
+ g_clear_object (&priv->location);
+ g_clear_object (&priv->editor_settings);
G_OBJECT_CLASS (gedit_document_saver_parent_class)->dispose (object);
}
diff --git a/gedit/gedit-document.c b/gedit/gedit-document.c
index ab2253a..61bf520 100644
--- a/gedit/gedit-document.c
+++ b/gedit/gedit-document.c
@@ -304,29 +304,10 @@ gedit_document_dispose (GObject *object)
g_free (position);
}
- if (doc->priv->loader)
- {
- g_object_unref (doc->priv->loader);
- doc->priv->loader = NULL;
- }
-
- if (doc->priv->editor_settings)
- {
- g_object_unref (doc->priv->editor_settings);
- doc->priv->editor_settings = NULL;
- }
-
- if (doc->priv->metadata_info != NULL)
- {
- g_object_unref (doc->priv->metadata_info);
- doc->priv->metadata_info = NULL;
- }
-
- if (doc->priv->location != NULL)
- {
- g_object_unref (doc->priv->location);
- doc->priv->location = NULL;
- }
+ g_clear_object (&doc->priv->loader);
+ g_clear_object (&doc->priv->editor_settings);
+ g_clear_object (&doc->priv->metadata_info);
+ g_clear_object (&doc->priv->location);
doc->priv->dispose_has_run = TRUE;
diff --git a/gedit/gedit-documents-panel.c b/gedit/gedit-documents-panel.c
index c156ec6..0a5a2b4 100644
--- a/gedit/gedit-documents-panel.c
+++ b/gedit/gedit-documents-panel.c
@@ -697,11 +697,7 @@ gedit_documents_panel_dispose (GObject *object)
panel->priv->refresh_idle_id = 0;
}
- if (panel->priv->window != NULL)
- {
- g_object_unref (panel->priv->window);
- panel->priv->window = NULL;
- }
+ g_clear_object (&panel->priv->window);
G_OBJECT_CLASS (gedit_documents_panel_parent_class)->dispose (object);
}
diff --git a/gedit/gedit-encodings-combo-box.c b/gedit/gedit-encodings-combo-box.c
index 439b251..6ca0a05 100644
--- a/gedit/gedit-encodings-combo-box.c
+++ b/gedit/gedit-encodings-combo-box.c
@@ -126,17 +126,8 @@ gedit_encodings_combo_box_dispose (GObject *object)
{
GeditEncodingsComboBox *combo = GEDIT_ENCODINGS_COMBO_BOX (object);
- if (combo->priv->store != NULL)
- {
- g_object_unref (combo->priv->store);
- combo->priv->store = NULL;
- }
-
- if (combo->priv->enc_settings != NULL)
- {
- g_object_unref (combo->priv->enc_settings);
- combo->priv->enc_settings = NULL;
- }
+ g_clear_object (&combo->priv->store);
+ g_clear_object (&combo->priv->enc_settings);
G_OBJECT_CLASS (gedit_encodings_combo_box_parent_class)->dispose (object);
}
diff --git a/gedit/gedit-file-chooser-dialog.c b/gedit/gedit-file-chooser-dialog.c
index 9046f53..ba1170a 100644
--- a/gedit/gedit-file-chooser-dialog.c
+++ b/gedit/gedit-file-chooser-dialog.c
@@ -71,11 +71,7 @@ gedit_file_chooser_dialog_dispose (GObject *object)
{
GeditFileChooserDialog *dialog = GEDIT_FILE_CHOOSER_DIALOG (object);
- if (dialog->priv->filter_settings != NULL)
- {
- g_object_unref (dialog->priv->filter_settings);
- dialog->priv->filter_settings = NULL;
- }
+ g_clear_object (&dialog->priv->filter_settings);
G_OBJECT_CLASS (gedit_file_chooser_dialog_parent_class)->dispose (object);
}
diff --git a/gedit/gedit-history-entry.c b/gedit/gedit-history-entry.c
index 291ef4f..4f9820b 100644
--- a/gedit/gedit-history-entry.c
+++ b/gedit/gedit-history-entry.c
@@ -133,11 +133,7 @@ gedit_history_entry_dispose (GObject *object)
gedit_history_entry_set_enable_completion (GEDIT_HISTORY_ENTRY (object),
FALSE);
- if (priv->settings != NULL)
- {
- g_object_unref (G_OBJECT (priv->settings));
- priv->settings = NULL;
- }
+ g_clear_object (&priv->settings);
G_OBJECT_CLASS (gedit_history_entry_parent_class)->dispose (object);
}
diff --git a/gedit/gedit-notebook.c b/gedit/gedit-notebook.c
index ec924b2..5e6b7db 100644
--- a/gedit/gedit-notebook.c
+++ b/gedit/gedit-notebook.c
@@ -165,17 +165,8 @@ gedit_notebook_dispose (GObject *object)
{
GeditNotebook *notebook = GEDIT_NOTEBOOK (object);
- if (notebook->priv->ui_settings != NULL)
- {
- g_object_unref (notebook->priv->ui_settings);
- notebook->priv->ui_settings = NULL;
- }
-
- if (notebook->priv->css != NULL)
- {
- g_object_unref (notebook->priv->css);
- notebook->priv->css = NULL;
- }
+ g_clear_object (¬ebook->priv->ui_settings);
+ g_clear_object (¬ebook->priv->css);
G_OBJECT_CLASS (gedit_notebook_parent_class)->dispose (object);
}
diff --git a/gedit/gedit-plugins-engine.c b/gedit/gedit-plugins-engine.c
index bb2c34a..3c510d0 100644
--- a/gedit/gedit-plugins-engine.c
+++ b/gedit/gedit-plugins-engine.c
@@ -122,11 +122,7 @@ gedit_plugins_engine_dispose (GObject *object)
{
GeditPluginsEngine *engine = GEDIT_PLUGINS_ENGINE (object);
- if (engine->priv->plugin_settings != NULL)
- {
- g_object_unref (engine->priv->plugin_settings);
- engine->priv->plugin_settings = NULL;
- }
+ g_clear_object (&engine->priv->plugin_settings);
G_OBJECT_CLASS (gedit_plugins_engine_parent_class)->dispose (object);
}
diff --git a/gedit/gedit-print-job.c b/gedit/gedit-print-job.c
index d34218a..1152520 100644
--- a/gedit/gedit-print-job.c
+++ b/gedit/gedit-print-job.c
@@ -175,17 +175,8 @@ gedit_print_job_dispose (GObject *object)
{
GeditPrintJob *job = GEDIT_PRINT_JOB (object);
- if (job->priv->print_settings != NULL)
- {
- g_object_unref (job->priv->print_settings);
- job->priv->print_settings = NULL;
- }
-
- if (job->priv->compositor != NULL)
- {
- g_object_unref (job->priv->compositor);
- job->priv->compositor = NULL;
- }
+ g_clear_object (&job->priv->print_settings);
+ g_clear_object (&job->priv->compositor);
if (job->priv->operation != NULL)
{
diff --git a/gedit/gedit-settings.c b/gedit/gedit-settings.c
index bf0be5e..cbc24c2 100644
--- a/gedit/gedit-settings.c
+++ b/gedit/gedit-settings.c
@@ -68,31 +68,12 @@ gedit_settings_finalize (GObject *object)
static void
gedit_settings_dispose (GObject *object)
{
- GeditSettings *gs = GEDIT_SETTINGS (object);
-
- if (gs->priv->lockdown != NULL)
- {
- g_object_unref (gs->priv->lockdown);
- gs->priv->lockdown = NULL;
- }
-
- if (gs->priv->interface != NULL)
- {
- g_object_unref (gs->priv->interface);
- gs->priv->interface = NULL;
- }
-
- if (gs->priv->editor != NULL)
- {
- g_object_unref (gs->priv->editor);
- gs->priv->editor = NULL;
- }
-
- if (gs->priv->ui != NULL)
- {
- g_object_unref (gs->priv->ui);
- gs->priv->ui = NULL;
- }
+ GeditSettingsPrivate *priv = GEDIT_SETTINGS (object)->priv;
+
+ g_clear_object (&priv->lockdown);
+ g_clear_object (&priv->interface);
+ g_clear_object (&priv->editor);
+ g_clear_object (&priv->ui);
G_OBJECT_CLASS (gedit_settings_parent_class)->dispose (object);
}
diff --git a/gedit/gedit-tab.c b/gedit/gedit-tab.c
index 31df406..e8dca9d 100644
--- a/gedit/gedit-tab.c
+++ b/gedit/gedit-tab.c
@@ -250,17 +250,8 @@ gedit_tab_dispose (GObject *object)
tab->priv->print_preview = NULL;
}
- if (tab->priv->tmp_save_location != NULL)
- {
- g_object_unref (tab->priv->tmp_save_location);
- tab->priv->tmp_save_location = NULL;
- }
-
- if (tab->priv->editor != NULL)
- {
- g_object_unref (tab->priv->editor);
- tab->priv->editor = NULL;
- }
+ g_clear_object (&tab->priv->tmp_save_location);
+ g_clear_object (&tab->priv->editor);
G_OBJECT_CLASS (gedit_tab_parent_class)->dispose (object);
}
diff --git a/gedit/gedit-view.c b/gedit/gedit-view.c
index eec3473..228ae1d 100644
--- a/gedit/gedit-view.c
+++ b/gedit/gedit-view.c
@@ -249,17 +249,8 @@ gedit_view_dispose (GObject *object)
{
GeditView *view = GEDIT_VIEW (object);
- if (view->priv->extensions != NULL)
- {
- g_object_unref (view->priv->extensions);
- view->priv->extensions = NULL;
- }
-
- if (view->priv->editor_settings != NULL)
- {
- g_object_unref (view->priv->editor_settings);
- view->priv->editor_settings = NULL;
- }
+ g_clear_object (&view->priv->extensions);
+ g_clear_object (&view->priv->editor_settings);
G_OBJECT_CLASS (gedit_view_parent_class)->dispose (object);
}
diff --git a/gedit/gedit-window.c b/gedit/gedit-window.c
index 23def6b..5a2363d 100644
--- a/gedit/gedit-window.c
+++ b/gedit/gedit-window.c
@@ -307,48 +307,15 @@ gedit_window_dispose (GObject *object)
window->priv->update_documents_list_menu_id = 0;
}
- if (window->priv->manager != NULL)
- {
- g_object_unref (window->priv->manager);
- window->priv->manager = NULL;
- }
-
- if (window->priv->message_bus != NULL)
- {
- g_object_unref (window->priv->message_bus);
- window->priv->message_bus = NULL;
- }
-
- if (window->priv->window_group != NULL)
- {
- g_object_unref (window->priv->window_group);
- window->priv->window_group = NULL;
- }
+ g_clear_object (&window->priv->manager);
+ g_clear_object (&window->priv->message_bus);
+ g_clear_object (&window->priv->window_group);
+ g_clear_object (&window->priv->default_location);
/* We must free the settings after saving the panels */
- if (window->priv->editor_settings != NULL)
- {
- g_object_unref (window->priv->editor_settings);
- window->priv->editor_settings = NULL;
- }
-
- if (window->priv->ui_settings != NULL)
- {
- g_object_unref (window->priv->ui_settings);
- window->priv->ui_settings = NULL;
- }
-
- if (window->priv->window_settings != NULL)
- {
- g_object_unref (window->priv->window_settings);
- window->priv->window_settings = NULL;
- }
-
- if (window->priv->default_location != NULL)
- {
- g_object_unref (window->priv->default_location);
- window->priv->default_location = NULL;
- }
+ g_clear_object (&window->priv->editor_settings);
+ g_clear_object (&window->priv->ui_settings);
+ g_clear_object (&window->priv->window_settings);
/* Now that there have broken some reference loops,
* force collection again.
diff --git a/plugins/changecase/gedit-changecase-plugin.c b/plugins/changecase/gedit-changecase-plugin.c
index e2210a1..ac6e17a 100644
--- a/plugins/changecase/gedit-changecase-plugin.c
+++ b/plugins/changecase/gedit-changecase-plugin.c
@@ -287,17 +287,8 @@ gedit_changecase_plugin_dispose (GObject *object)
gedit_debug_message (DEBUG_PLUGINS, "GeditChangecasePlugin disponsing");
- if (plugin->priv->window != NULL)
- {
- g_object_unref (plugin->priv->window);
- plugin->priv->window = NULL;
- }
-
- if (plugin->priv->action_group != NULL)
- {
- g_object_unref (plugin->priv->action_group);
- plugin->priv->action_group = NULL;
- }
+ g_clear_object (&plugin->priv->window);
+ g_clear_object (&plugin->priv->action_group);
G_OBJECT_CLASS (gedit_changecase_plugin_parent_class)->dispose (object);
}
diff --git a/plugins/checkupdate/gedit-check-update-plugin.c b/plugins/checkupdate/gedit-check-update-plugin.c
index b7394a8..361c22c 100644
--- a/plugins/checkupdate/gedit-check-update-plugin.c
+++ b/plugins/checkupdate/gedit-check-update-plugin.c
@@ -99,23 +99,9 @@ gedit_check_update_plugin_dispose (GObject *object)
{
GeditCheckUpdatePlugin *plugin = GEDIT_CHECK_UPDATE_PLUGIN (object);
- if (plugin->priv->session != NULL)
- {
- g_object_unref (plugin->priv->session);
- plugin->priv->session = NULL;
- }
-
- if (plugin->priv->settings != NULL)
- {
- g_object_unref (plugin->priv->settings);
- plugin->priv->settings = NULL;
- }
-
- if (plugin->priv->window != NULL)
- {
- g_object_unref (plugin->priv->window);
- plugin->priv->window = NULL;
- }
+ g_clear_object (&plugin->priv->session);
+ g_clear_object (&plugin->priv->settings);
+ g_clear_object (&plugin->priv->window);
gedit_debug_message (DEBUG_PLUGINS,
"GeditCheckUpdatePlugin disposing");
diff --git a/plugins/docinfo/gedit-docinfo-plugin.c b/plugins/docinfo/gedit-docinfo-plugin.c
index 73a206f..4714c8d 100644
--- a/plugins/docinfo/gedit-docinfo-plugin.c
+++ b/plugins/docinfo/gedit-docinfo-plugin.c
@@ -471,17 +471,8 @@ gedit_docinfo_plugin_dispose (GObject *object)
gedit_debug_message (DEBUG_PLUGINS, "GeditDocinfoPlugin dispose");
- if (plugin->priv->action_group != NULL)
- {
- g_object_unref (plugin->priv->action_group);
- plugin->priv->action_group = NULL;
- }
-
- if (plugin->priv->window != NULL)
- {
- g_object_unref (plugin->priv->window);
- plugin->priv->window = NULL;
- }
+ g_clear_object (&plugin->priv->action_group);
+ g_clear_object (&plugin->priv->window);
G_OBJECT_CLASS (gedit_docinfo_plugin_parent_class)->dispose (object);
}
diff --git a/plugins/filebrowser/gedit-file-bookmarks-store.c b/plugins/filebrowser/gedit-file-bookmarks-store.c
index 85b9398..ce45ad6 100644
--- a/plugins/filebrowser/gedit-file-bookmarks-store.c
+++ b/plugins/filebrowser/gedit-file-bookmarks-store.c
@@ -72,11 +72,7 @@ gedit_file_bookmarks_store_dispose (GObject *object)
obj->priv->volume_monitor = NULL;
}
- if (obj->priv->bookmarks_monitor != NULL)
- {
- g_object_unref (obj->priv->bookmarks_monitor);
- obj->priv->bookmarks_monitor = NULL;
- }
+ g_clear_object (&obj->priv->bookmarks_monitor);
G_OBJECT_CLASS (gedit_file_bookmarks_store_parent_class)->dispose (object);
}
diff --git a/plugins/filebrowser/gedit-file-browser-plugin.c b/plugins/filebrowser/gedit-file-browser-plugin.c
index f319053..dc4be43 100644
--- a/plugins/filebrowser/gedit-file-browser-plugin.c
+++ b/plugins/filebrowser/gedit-file-browser-plugin.c
@@ -178,29 +178,10 @@ gedit_file_browser_plugin_dispose (GObject *object)
{
GeditFileBrowserPlugin *plugin = GEDIT_FILE_BROWSER_PLUGIN (object);
- if (plugin->priv->settings != NULL)
- {
- g_object_unref (plugin->priv->settings);
- plugin->priv->settings = NULL;
- }
-
- if (plugin->priv->nautilus_settings != NULL)
- {
- g_object_unref (plugin->priv->nautilus_settings);
- plugin->priv->nautilus_settings = NULL;
- }
-
- if (plugin->priv->terminal_settings != NULL)
- {
- g_object_unref (plugin->priv->terminal_settings);
- plugin->priv->terminal_settings = NULL;
- }
-
- if (plugin->priv->window != NULL)
- {
- g_object_unref (plugin->priv->window);
- plugin->priv->window = NULL;
- }
+ g_clear_object (&plugin->priv->settings);
+ g_clear_object (&plugin->priv->nautilus_settings);
+ g_clear_object (&plugin->priv->terminal_settings);
+ g_clear_object (&plugin->priv->window);
G_OBJECT_CLASS (gedit_file_browser_plugin_parent_class)->dispose (object);
}
diff --git a/plugins/modelines/gedit-modeline-plugin.c b/plugins/modelines/gedit-modeline-plugin.c
index 3d55701..9b90b29 100644
--- a/plugins/modelines/gedit-modeline-plugin.c
+++ b/plugins/modelines/gedit-modeline-plugin.c
@@ -87,11 +87,7 @@ gedit_modeline_plugin_dispose (GObject *object)
gedit_debug_message (DEBUG_PLUGINS, "GeditModelinePlugin disposing");
- if (plugin->priv->view != NULL)
- {
- g_object_unref (plugin->priv->view);
- plugin->priv->view = NULL;
- }
+ g_clear_object (&plugin->priv->view);
G_OBJECT_CLASS (gedit_modeline_plugin_parent_class)->dispose (object);
}
diff --git a/plugins/sort/gedit-sort-plugin.c b/plugins/sort/gedit-sort-plugin.c
index 3e7062b..02fb5cf 100644
--- a/plugins/sort/gedit-sort-plugin.c
+++ b/plugins/sort/gedit-sort-plugin.c
@@ -527,17 +527,8 @@ gedit_sort_plugin_dispose (GObject *object)
gedit_debug_message (DEBUG_PLUGINS, "GeditSortPlugin disposing");
- if (plugin->priv->ui_action_group)
- {
- g_object_unref (plugin->priv->ui_action_group);
- plugin->priv->ui_action_group = NULL;
- }
-
- if (plugin->priv->window != NULL)
- {
- g_object_unref (plugin->priv->window);
- plugin->priv->window = NULL;
- }
+ g_clear_object (&plugin->priv->ui_action_group);
+ g_clear_object (&plugin->priv->window);
G_OBJECT_CLASS (gedit_sort_plugin_parent_class)->dispose (object);
}
diff --git a/plugins/spell/gedit-spell-checker-dialog.c b/plugins/spell/gedit-spell-checker-dialog.c
index b5158d4..3a3806d 100644
--- a/plugins/spell/gedit-spell-checker-dialog.c
+++ b/plugins/spell/gedit-spell-checker-dialog.c
@@ -116,11 +116,7 @@ gedit_spell_checker_dialog_dispose (GObject *object)
{
GeditSpellCheckerDialog *dlg = GEDIT_SPELL_CHECKER_DIALOG (object);
- if (dlg->spell_checker != NULL)
- {
- g_object_unref (dlg->spell_checker);
- dlg->spell_checker = NULL;
- }
+ g_clear_object (&dlg->spell_checker);
if (dlg->misspelled_word != NULL)
{
@@ -132,11 +128,22 @@ gedit_spell_checker_dialog_dispose (GObject *object)
}
static void
+gedit_spell_checker_dialog_finalize (GObject *object)
+{
+ GeditSpellCheckerDialog *dlg = GEDIT_SPELL_CHECKER_DIALOG (object);
+
+ g_free (dlg->misspelled_word);
+
+ G_OBJECT_CLASS (gedit_spell_checker_dialog_parent_class)->finalize (object);
+}
+
+static void
gedit_spell_checker_dialog_class_init (GeditSpellCheckerDialogClass * klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->dispose = gedit_spell_checker_dialog_dispose;
+ object_class->finalize = gedit_spell_checker_dialog_finalize;
signals[IGNORE] =
g_signal_new ("ignore",
diff --git a/plugins/spell/gedit-spell-plugin.c b/plugins/spell/gedit-spell-plugin.c
index 57f7ca9..f48a74e 100644
--- a/plugins/spell/gedit-spell-plugin.c
+++ b/plugins/spell/gedit-spell-plugin.c
@@ -151,17 +151,8 @@ gedit_spell_plugin_dispose (GObject *object)
gedit_debug_message (DEBUG_PLUGINS, "GeditSpellPlugin disposing");
- if (plugin->priv->action_group != NULL)
- {
- g_object_unref (plugin->priv->action_group);
- plugin->priv->action_group = NULL;
- }
-
- if (plugin->priv->window != NULL)
- {
- g_object_unref (plugin->priv->window);
- plugin->priv->window = NULL;
- }
+ g_clear_object (&plugin->priv->action_group);
+ g_clear_object (&plugin->priv->window);
G_OBJECT_CLASS (gedit_spell_plugin_parent_class)->dispose (object);
}
diff --git a/plugins/time/gedit-time-plugin.c b/plugins/time/gedit-time-plugin.c
index fa914c1..8ae053b 100644
--- a/plugins/time/gedit-time-plugin.c
+++ b/plugins/time/gedit-time-plugin.c
@@ -209,23 +209,9 @@ gedit_time_plugin_dispose (GObject *object)
gedit_debug_message (DEBUG_PLUGINS, "GeditTimePlugin disposing");
- if (plugin->priv->settings != NULL)
- {
- g_object_unref (plugin->priv->settings);
- plugin->priv->settings = NULL;
- }
-
- if (plugin->priv->action_group != NULL)
- {
- g_object_unref (plugin->priv->action_group);
- plugin->priv->action_group = NULL;
- }
-
- if (plugin->priv->window != NULL)
- {
- g_object_unref (plugin->priv->window);
- plugin->priv->window = NULL;
- }
+ g_clear_object (&plugin->priv->settings);
+ g_clear_object (&plugin->priv->action_group);
+ g_clear_object (&plugin->priv->window);
G_OBJECT_CLASS (gedit_time_plugin_parent_class)->dispose (object);
}
diff --git a/plugins/zeitgeist/gedit-zeitgeist-plugin.c b/plugins/zeitgeist/gedit-zeitgeist-plugin.c
index 60214b9..59a0b54 100644
--- a/plugins/zeitgeist/gedit-zeitgeist-plugin.c
+++ b/plugins/zeitgeist/gedit-zeitgeist-plugin.c
@@ -91,17 +91,8 @@ gedit_zeitgeist_plugin_dispose (GObject *object)
gedit_debug_message (DEBUG_PLUGINS, "GeditZeitgeistPlugin disposing");
- if (plugin->priv->view != NULL)
- {
- g_object_unref (plugin->priv->view);
- plugin->priv->view = NULL;
- }
-
- if (plugin->priv->app != NULL)
- {
- g_object_unref (plugin->priv->app);
- plugin->priv->app = NULL;
- }
+ g_clear_object (&plugin->priv->view);
+ g_clear_object (&plugin->priv->app);
G_OBJECT_CLASS (gedit_zeitgeist_plugin_parent_class)->dispose (object);
}
@@ -109,9 +100,9 @@ gedit_zeitgeist_plugin_dispose (GObject *object)
static void
gedit_zeitgeist_plugin_finalize (GObject *object)
{
- G_OBJECT_CLASS (gedit_zeitgeist_plugin_parent_class)->finalize (object);
-
gedit_debug_message (DEBUG_PLUGINS, "GeditZeitgeistPlugin finalizing");
+
+ G_OBJECT_CLASS (gedit_zeitgeist_plugin_parent_class)->finalize (object);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]