Correctly disconnect signals attached to the print job operation.

parent 97442bdc
...@@ -108,6 +108,14 @@ static guint print_job_signals[LAST_SIGNAL] = { 0 }; ...@@ -108,6 +108,14 @@ static guint print_job_signals[LAST_SIGNAL] = { 0 };
G_DEFINE_TYPE (GeditPrintJob, gedit_print_job, G_TYPE_OBJECT) G_DEFINE_TYPE (GeditPrintJob, gedit_print_job, G_TYPE_OBJECT)
static void end_print_cb (GtkPrintOperation *operation,
GtkPrintContext *context,
GeditPrintJob *job);
static void done_cb (GtkPrintOperation *operation,
GtkPrintOperationResult result,
GeditPrintJob *job);
static void static void
set_view (GeditPrintJob *job, GeditView *view) set_view (GeditPrintJob *job, GeditView *view)
{ {
...@@ -159,12 +167,6 @@ gedit_print_job_finalize (GObject *object) ...@@ -159,12 +167,6 @@ gedit_print_job_finalize (GObject *object)
GeditPrintJob *job = GEDIT_PRINT_JOB (object); GeditPrintJob *job = GEDIT_PRINT_JOB (object);
g_free (job->priv->status_string); g_free (job->priv->status_string);
if (job->priv->compositor != NULL)
g_object_unref (job->priv->compositor);
if (job->priv->operation != NULL)
g_object_unref (job->priv->operation);
G_OBJECT_CLASS (gedit_print_job_parent_class)->finalize (object); G_OBJECT_CLASS (gedit_print_job_parent_class)->finalize (object);
} }
...@@ -173,12 +175,28 @@ static void ...@@ -173,12 +175,28 @@ static void
gedit_print_job_dispose (GObject *object) gedit_print_job_dispose (GObject *object)
{ {
GeditPrintJob *job = GEDIT_PRINT_JOB (object); GeditPrintJob *job = GEDIT_PRINT_JOB (object);
if (job->priv->print_settings != NULL) if (job->priv->print_settings != NULL)
{ {
g_object_unref (job->priv->print_settings); g_object_unref (job->priv->print_settings);
job->priv->print_settings = NULL; job->priv->print_settings = NULL;
} }
if (job->priv->compositor != NULL)
{
g_object_unref (job->priv->compositor);
job->priv->compositor = NULL;
}
if (job->priv->operation != NULL)
{
g_signal_handlers_disconnect_by_func (job->priv->operation,
end_print_cb, job);
g_signal_handlers_disconnect_by_func (job->priv->operation,
done_cb, job);
g_object_unref (job->priv->operation);
job->priv->operation = NULL;
}
G_OBJECT_CLASS (gedit_print_job_parent_class)->dispose (object); G_OBJECT_CLASS (gedit_print_job_parent_class)->dispose (object);
} }
...@@ -702,8 +720,11 @@ end_print_cb (GtkPrintOperation *operation, ...@@ -702,8 +720,11 @@ end_print_cb (GtkPrintOperation *operation,
GtkPrintContext *context, GtkPrintContext *context,
GeditPrintJob *job) GeditPrintJob *job)
{ {
g_object_unref (job->priv->compositor); if (job->priv->compositor != NULL)
job->priv->compositor = NULL; {
g_object_unref (job->priv->compositor);
job->priv->compositor = NULL;
}
} }
static void static void
......
...@@ -106,6 +106,11 @@ static guint signals[LAST_SIGNAL] = { 0 }; ...@@ -106,6 +106,11 @@ static guint signals[LAST_SIGNAL] = { 0 };
static gboolean gedit_tab_auto_save (GeditTab *tab); static gboolean gedit_tab_auto_save (GeditTab *tab);
static void done_printing_cb (GeditPrintJob *job,
GeditPrintJobResult result,
const GError *error,
GeditTab *tab);
static void static void
install_auto_save_timeout (GeditTab *tab) install_auto_save_timeout (GeditTab *tab)
{ {
...@@ -236,6 +241,15 @@ gedit_tab_dispose (GObject *object) ...@@ -236,6 +241,15 @@ gedit_tab_dispose (GObject *object)
{ {
GeditTab *tab = GEDIT_TAB (object); GeditTab *tab = GEDIT_TAB (object);
if (tab->priv->print_job != NULL)
{
g_signal_handlers_disconnect_by_func (tab->priv->print_job,
done_printing_cb, tab);
g_object_unref (tab->priv->print_job);
tab->priv->print_job = NULL;
tab->priv->print_preview = NULL;
}
if (tab->priv->tmp_save_location != NULL) if (tab->priv->tmp_save_location != NULL)
{ {
g_object_unref (tab->priv->tmp_save_location); g_object_unref (tab->priv->tmp_save_location);
...@@ -2489,8 +2503,11 @@ done_printing_cb (GeditPrintJob *job, ...@@ -2489,8 +2503,11 @@ done_printing_cb (GeditPrintJob *job,
view = gedit_tab_get_view (tab); view = gedit_tab_get_view (tab);
gtk_widget_grab_focus (GTK_WIDGET (view)); gtk_widget_grab_focus (GTK_WIDGET (view));
g_object_unref (tab->priv->print_job); if (tab->priv->print_job != NULL)
tab->priv->print_job = NULL; {
g_object_unref (tab->priv->print_job);
tab->priv->print_job = NULL;
}
} }
#if 0 #if 0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment