Use g_clear_object in dispose

parent 2b3d1bd0
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -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;
......
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -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 (&notebook->priv->ui_settings);
g_clear_object (&notebook->priv->css);
G_OBJECT_CLASS (gedit_notebook_parent_class)->dispose (object);
}
......
......@@ -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);
}
......
......@@ -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)
{
......
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -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.
......
......@@ -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);
}
......
......@@ -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");
......
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -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)
{
......@@ -131,12 +127,23 @@ gedit_spell_checker_dialog_dispose (GObject *object)
G_OBJECT_CLASS (gedit_spell_checker_dialog_parent_class)->dispose (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",
......
......@@ -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);
}
......
......@@ -209,23 +209,9 @@ gedit_time_plugin_dispose (GObject *object)
gedit_debug_message (DEBUG_PLUGINS, "GeditTimePlugin disposing");
if (plugin->priv->settings != NULL)
{