[gnome-builder] terminal: prevent flapping in event we can't launch a child



commit b31640d92ceeadb6a32b1676be59e1ce6042c219
Author: Christian Hergert <christian hergert me>
Date:   Sun Sep 13 13:33:52 2015 -0700

    terminal: prevent flapping in event we can't launch a child

 plugins/terminal/gb-terminal-view-private.h |    2 ++
 plugins/terminal/gb-terminal-view.c         |    7 +++++++
 2 files changed, 9 insertions(+), 0 deletions(-)
---
diff --git a/plugins/terminal/gb-terminal-view-private.h b/plugins/terminal/gb-terminal-view-private.h
index 23f014a..5f83e0f 100644
--- a/plugins/terminal/gb-terminal-view-private.h
+++ b/plugins/terminal/gb-terminal-view-private.h
@@ -42,6 +42,8 @@ struct _GbTerminalView
 
   GtkWidget           *scrolled_window_bottom;
 
+  gint64               last_respawn;
+
   guint                top_has_spawned : 1;
   guint                bottom_has_spawned : 1;
   guint                bottom_has_focus : 1;
diff --git a/plugins/terminal/gb-terminal-view.c b/plugins/terminal/gb-terminal-view.c
index f2d140b..a447a9b 100644
--- a/plugins/terminal/gb-terminal-view.c
+++ b/plugins/terminal/gb-terminal-view.c
@@ -103,6 +103,7 @@ gb_terminal_respawn (GbTerminalView *self,
   IdeVcs *vcs;
   GFile *workdir;
   GPid child_pid;
+  gint64 now;
 
   g_assert (GB_IS_TERMINAL_VIEW (self));
 
@@ -112,6 +113,12 @@ gb_terminal_respawn (GbTerminalView *self,
   if (!GB_IS_WORKBENCH (toplevel))
     return;
 
+  /* Prevent flapping */
+  now = g_get_monotonic_time ();
+  if ((now - self->last_respawn) < (G_USEC_PER_SEC / 10))
+    return;
+  self->last_respawn = now;
+
   context = gb_workbench_get_context (GB_WORKBENCH (toplevel));
   vcs = ide_context_get_vcs (context);
   workdir = ide_vcs_get_working_directory (vcs);


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