[vte] widget: Move some methods to VteTerminalPrivate



commit 50aee40af7d16c2bec82f4f8bcdd259b6913c541
Author: Christian Persch <chpe gnome org>
Date:   Mon Nov 30 17:23:34 2015 +0100

    widget: Move some methods to VteTerminalPrivate

 src/vte.cc         |   63 ++++++++++++++++++++++++++++-----------------------
 src/vteinternal.hh |    3 ++
 2 files changed, 38 insertions(+), 28 deletions(-)
---
diff --git a/src/vte.cc b/src/vte.cc
index 0e53f19..2e04324 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -3367,42 +3367,49 @@ vte_terminal_child_watch_cb(GPid pid,
                return;
        }
 
-       if (pid == terminal->pvt->pty_pid) {
-                GObject *object = G_OBJECT(terminal);
+        g_object_ref(terminal);
+        terminal->pvt->child_watch_done(pid, status);
+        g_object_unref(terminal);
+        /* Note: terminal may be destroyed at this point */
+}
+
+void
+VteTerminalPrivate::child_watch_done(GPid pid,
+                                     int status)
+{
+       if (pid != m_pty_pid)
+                return;
 
-                g_object_ref(object);
-                g_object_freeze_notify(object);
+        GObject *object = G_OBJECT(m_terminal);
+        g_object_ref(object);
+        g_object_freeze_notify(object);
 
-               _VTE_DEBUG_IF (VTE_DEBUG_LIFECYCLE) {
-                       g_printerr ("Child[%d] exited with status %d\n",
-                                       pid, status);
+        _VTE_DEBUG_IF (VTE_DEBUG_LIFECYCLE) {
+                g_printerr ("Child[%d] exited with status %d\n",
+                            pid, status);
 #ifdef HAVE_SYS_WAIT_H
-                       if (WIFEXITED (status)) {
-                               g_printerr ("Child[%d] exit code %d.\n",
-                                               pid, WEXITSTATUS (status));
-                       }else if (WIFSIGNALED (status)) {
-                               g_printerr ("Child[%d] dies with signal %d.\n",
-                                               pid, WTERMSIG (status));
-                       }
+                if (WIFEXITED (status)) {
+                        g_printerr ("Child[%d] exit code %d.\n",
+                                    pid, WEXITSTATUS (status));
+                } else if (WIFSIGNALED (status)) {
+                        g_printerr ("Child[%d] dies with signal %d.\n",
+                                    pid, WTERMSIG (status));
+                }
 #endif
-               }
+        }
 
-               terminal->pvt->child_watch_source = 0;
-               terminal->pvt->pty_pid = -1;
+        m_child_watch_source = 0;
+        m_pty_pid = -1;
 
-               /* Close out the PTY. */
-                vte_terminal_set_pty(terminal, NULL);
+        /* Close out the PTY. */
+        set_pty(nullptr);
 
-               /* Tell observers what's happened. */
-                _vte_debug_print(VTE_DEBUG_SIGNALS,
-                                 "Emitting `child-exited'.\n");
-                g_signal_emit(object, signals[SIGNAL_CHILD_EXITED], 0, status);
+        /* Tell observers what's happened. */
+        _vte_debug_print(VTE_DEBUG_SIGNALS,
+                         "Emitting `child-exited'.\n");
+        g_signal_emit(object, signals[SIGNAL_CHILD_EXITED], 0, status);
 
-                g_object_thaw_notify(object);
-                g_object_unref(object);
-
-                /* Note: terminal may be destroyed at this point */
-       }
+        g_object_thaw_notify(object);
 }
 
 static void mark_input_source_invalid(VteTerminal *terminal)
diff --git a/src/vteinternal.hh b/src/vteinternal.hh
index 85f19b1..6b95b48 100644
--- a/src/vteinternal.hh
+++ b/src/vteinternal.hh
@@ -537,6 +537,9 @@ public:
         void pty_scroll_lock_changed(bool locked);
 
         void watch_child (GPid child_pid);
+        void child_watch_done(GPid pid,
+                              int status);
+
         bool spawn_sync(VtePtyFlags pty_flags,
                         const char *working_directory,
                         char **argv,


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