[evince/gnome-42] shell: Disconnect signal handler to prevent invalid read



commit 900bd32ee31ebc434b589d4fbf9221933aff3305
Author: Marek Kasik <mkasik redhat com>
Date:   Thu Apr 28 17:00:22 2022 +0200

    shell: Disconnect signal handler to prevent invalid read
    
    Disconnect handler of "finished" signal of EvJobAnnots in EvSidebarAnnotations'
    dispose method.
    This prevents the callback to access the EvSidebarAnnotations object after
    it has been disposed if the job takes a long time.
    
    Fixes #1784

 shell/ev-sidebar-annotations.c | 9 +++++++++
 1 file changed, 9 insertions(+)
---
diff --git a/shell/ev-sidebar-annotations.c b/shell/ev-sidebar-annotations.c
index bc43dc2cd..21595e49e 100644
--- a/shell/ev-sidebar-annotations.c
+++ b/shell/ev-sidebar-annotations.c
@@ -70,6 +70,8 @@ static gboolean ev_sidebar_annotations_popup_menu_show (EvSidebarAnnotations *si
                                                        const GdkRectangle   *rect,
                                                        EvMapping            *annot_mapping,
                                                        const GdkEvent       *event);
+static void job_finished_callback (EvJobAnnots          *job,
+                                  EvSidebarAnnotations *sidebar_annots);
 static guint signals[N_SIGNALS];
 
 G_DEFINE_TYPE_EXTENDED (EvSidebarAnnotations,
@@ -88,6 +90,13 @@ ev_sidebar_annotations_dispose (GObject *object)
        EvSidebarAnnotations *sidebar_annots = EV_SIDEBAR_ANNOTATIONS (object);
        EvSidebarAnnotationsPrivate *priv = sidebar_annots->priv;
 
+       if (priv->job != NULL) {
+               g_signal_handlers_disconnect_by_func (priv->job,
+                                                     job_finished_callback,
+                                                     sidebar_annots);
+               g_clear_object (&priv->job);
+       }
+
        if (priv->document) {
                g_object_unref (priv->document);
                priv->document = NULL;


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