From 6d1332ac7513f564c36949ed5d95fd6874f8bbb2 Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Mon, 17 Dec 2012 14:22:48 +0000 Subject: Disconnect the clipboard signal handler on window close Previously, if a window was closed and then the clipboard changed, update_paste_action would still be called with a now-invalid paste action. --- tikzit/src/gtk/Window.h | 2 ++ tikzit/src/gtk/Window.m | 12 ++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/tikzit/src/gtk/Window.h b/tikzit/src/gtk/Window.h index 0e8ccdc..570cdf4 100644 --- a/tikzit/src/gtk/Window.h +++ b/tikzit/src/gtk/Window.h @@ -41,6 +41,8 @@ GtkPaned *tikzPaneSplitter; GtkWidget *tikzPane; + gulong clipboard_handler_id; + // Classes that manage parts of the window Menu *menu; GraphEditorPanel *graphPanel; diff --git a/tikzit/src/gtk/Window.m b/tikzit/src/gtk/Window.m index ea87b6c..c5e7654 100644 --- a/tikzit/src/gtk/Window.m +++ b/tikzit/src/gtk/Window.m @@ -124,6 +124,9 @@ static void update_paste_action (GtkClipboard *clipboard, GdkEvent *event, GtkAc - (void) dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; + g_signal_handler_disconnect ( + gtk_clipboard_get (GDK_SELECTION_CLIPBOARD), + clipboard_handler_id); [menu release]; [graphPanel release]; @@ -565,10 +568,11 @@ static void update_paste_action (GtkClipboard *clipboard, GdkEvent *event, GtkAc - (void) _connectSignals { GtkClipboard *clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD); - g_signal_connect (G_OBJECT (clipboard), - "owner-change", - G_CALLBACK (update_paste_action), - [menu pasteAction]); + clipboard_handler_id = + g_signal_connect (G_OBJECT (clipboard), + "owner-change", + G_CALLBACK (update_paste_action), + [menu pasteAction]); g_signal_connect (G_OBJECT (window), "key-press-event", G_CALLBACK (tz_hijack_key_press), -- cgit v1.2.3