fix: prevent calling chiled-exited function more than once per term
authorYao Wei (魏銘廷) <mwei@lxde.org>
Sun, 16 Sep 2018 16:07:16 +0000 (00:07 +0800)
committerYao Wei (魏銘廷) <mwei@lxde.org>
Sun, 16 Sep 2018 16:37:52 +0000 (00:37 +0800)
child-exited signal behavior changed in VTE 0.54.
This needs more proper refactoring.

Closes #61

src/lxterminal.c
src/lxterminal.h

index 8802a12..70ed131 100644 (file)
@@ -881,6 +881,8 @@ static void terminal_child_exited_event(VteTerminal * vte, Term * term)
 {
     LXTerminal * terminal = term->parent;
 
+    g_signal_handler_disconnect(G_OBJECT(term->vte), term->exit_handler_id);
+
     /* Last tab being deleted.  Deallocate memory and close the window. */
     if (gtk_notebook_get_n_pages(GTK_NOTEBOOK(terminal->notebook)) == 1)
     {
@@ -1278,7 +1280,7 @@ static Term * terminal_new(LXTerminal * terminal, const gchar * label, const gch
     g_signal_connect(G_OBJECT(term->vte), "button-press-event", G_CALLBACK(terminal_vte_button_press_event), term);
     g_signal_connect(G_OBJECT(term->vte), "button-release-event", G_CALLBACK(terminal_vte_button_release_event), term);
     g_signal_connect(G_OBJECT(term->vte), "commit", G_CALLBACK(terminal_vte_commit), term);
-    g_signal_connect(G_OBJECT(term->vte), "child-exited", G_CALLBACK(terminal_child_exited_event), term);
+    term->exit_handler_id = g_signal_connect(G_OBJECT(term->vte), "child-exited", G_CALLBACK(terminal_child_exited_event), term);
     g_signal_connect(G_OBJECT(term->vte), "cursor-moved", G_CALLBACK(terminal_vte_cursor_moved_event), term);
     g_signal_connect(G_OBJECT(term->vte), "window-title-changed", G_CALLBACK(terminal_window_title_changed_event), term);
 
index 1f4bcdd..b5373d0 100644 (file)
@@ -72,6 +72,7 @@ typedef struct _term {
     GClosure * closure;             /* Accelerator structure */
     gchar * matched_url;
     gboolean open_menu_on_button_release;
+    gulong exit_handler_id;
 } Term;
 
 /* Output of lxterminal_process_arguments. */