[gedit] tab: remove useless weak pointer



commit bb07b13074a950eea89e030a5725341c2d62c0f0
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Sat Feb 21 14:41:07 2015 +0100

    tab: remove useless weak pointer
    
    GeditTab already owns a ref to the PrintJob, so having a weak pointer is
    redundant. If memory management is handled correctly it shouldn't be
    needed. Setting the attribute to NULL was indeed missing at one place.

 gedit/gedit-tab.c |   11 +++--------
 1 files changed, 3 insertions(+), 8 deletions(-)
---
diff --git a/gedit/gedit-tab.c b/gedit/gedit-tab.c
index ec7b963..794818e 100644
--- a/gedit/gedit-tab.c
+++ b/gedit/gedit-tab.c
@@ -51,9 +51,9 @@ struct _GeditTabPrivate
 
        GtkWidget              *info_bar;
        GtkWidget              *info_bar_hidden;
-       GtkWidget              *print_preview;
 
        GeditPrintJob          *print_job;
+       GtkWidget              *print_preview;
 
        GTask                  *task_saver;
        GtkSourceFileSaverFlags save_flags;
@@ -2739,11 +2739,7 @@ done_printing_cb (GeditPrintJob       *job,
        view = gedit_tab_get_view (tab);
        gtk_widget_grab_focus (GTK_WIDGET (view));
 
-       if (tab->priv->print_job != NULL)
-       {
-               g_object_unref (tab->priv->print_job);
-               tab->priv->print_job = NULL;
-       }
+       g_clear_object (&tab->priv->print_job);
 }
 
 #if 0
@@ -2910,8 +2906,6 @@ _gedit_tab_print (GeditTab *tab)
        view = gedit_tab_get_view (tab);
 
        tab->priv->print_job = gedit_print_job_new (view);
-       g_object_add_weak_pointer (G_OBJECT (tab->priv->print_job),
-                                  (gpointer *) &tab->priv->print_job);
 
        show_printing_info_bar (tab);
 
@@ -2954,6 +2948,7 @@ _gedit_tab_print (GeditTab *tab)
                gedit_tab_set_state (tab, GEDIT_TAB_STATE_NORMAL);
                g_warning ("Async print preview failed (%s)", error->message);
                g_object_unref (tab->priv->print_job);
+               tab->priv->print_job = NULL;
                g_error_free (error);
        }
 


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