[vte] widget: Emit EOF signal from idle handler



commit e472bb2ad7010c5bf4daa62f81467f193f2a6308
Author: Christian Persch <chpe src gnome org>
Date:   Tue Nov 19 18:43:17 2019 +0100

    widget: Emit EOF signal from idle handler
    
    Fixes a crash in xfce terminal which destroys the terminal from
    its EOF signal handler.

 src/vte.cc         | 22 +++++++++++++++++++++-
 src/vteinternal.hh |  1 +
 2 files changed, 22 insertions(+), 1 deletion(-)
---
diff --git a/src/vte.cc b/src/vte.cc
index db8371ce..99be7950 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -798,6 +798,26 @@ Terminal::emit_eof()
                 widget()->emit_eof();
 }
 
+static gboolean
+emit_eof_idle_cb(VteTerminal *terminal)
+{
+        _vte_terminal_get_impl(terminal)->emit_eof();
+        // @terminal might be destroyed at this point
+
+        return G_SOURCE_REMOVE;
+}
+
+void
+Terminal::queue_eof()
+{
+        _vte_debug_print(VTE_DEBUG_SIGNALS, "Queueing `eof'.\n");
+
+        g_idle_add_full(G_PRIORITY_HIGH,
+                        (GSourceFunc)emit_eof_idle_cb,
+                        g_object_ref(m_terminal),
+                        g_object_unref);
+}
+
 void
 Terminal::emit_child_exited()
 {
@@ -10394,7 +10414,7 @@ Terminal::emit_pending_signals()
 
         auto const eos = m_eos_pending;
         if (m_eos_pending) {
-                emit_eof();
+                queue_eof();
                 m_eos_pending = false;
 
                 unset_pty();
diff --git a/src/vteinternal.hh b/src/vteinternal.hh
index d8656785..5484bceb 100644
--- a/src/vteinternal.hh
+++ b/src/vteinternal.hh
@@ -1118,6 +1118,7 @@ public:
         void queue_cursor_moved();
         void queue_contents_changed();
         void queue_child_exited();
+        void queue_eof();
 
         void emit_text_deleted();
         void emit_text_inserted();


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