diff options
author | Alex Merry <alex.merry@cs.ox.ac.uk> | 2012-12-17 14:22:48 +0000 |
---|---|---|
committer | Alex Merry <alex.merry@cs.ox.ac.uk> | 2012-12-17 14:22:48 +0000 |
commit | 6d1332ac7513f564c36949ed5d95fd6874f8bbb2 (patch) | |
tree | dd4721e95f34035932f4efd11d2d6051359905e3 | |
parent | dd70f3391d05753a86c30508afd3ada76770ca65 (diff) |
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.
-rw-r--r-- | tikzit/src/gtk/Window.h | 2 | ||||
-rw-r--r-- | 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), |