[sysprof] window: protect against delayed ::stopped



commit ff395e94c676e417138e99c93e042c57746e23e0
Author: Christian Hergert <chergert redhat com>
Date:   Mon Apr 18 00:02:50 2016 -0700

    window: protect against delayed ::stopped
    
    Large captures could take a while to complete the stop request, so protect
    against that so that the user can't accidentally start another capture.

 src/sp-window.c |   19 ++++++++++---------
 1 files changed, 10 insertions(+), 9 deletions(-)
---
diff --git a/src/sp-window.c b/src/sp-window.c
index 2cf5805..89898a4 100644
--- a/src/sp-window.c
+++ b/src/sp-window.c
@@ -379,14 +379,6 @@ sp_window_start_recording (SpWindow *self)
 {
   g_assert (SP_IS_WINDOW (self));
 
-  if (self->state == SP_WINDOW_STATE_RECORDING)
-    {
-      /* SpProfiler::stopped will move us to generating */
-      gtk_label_set_label (self->subtitle, _("Stopping…"));
-      sp_profiler_stop (self->profiler);
-      return;
-    }
-
   if ((self->state == SP_WINDOW_STATE_EMPTY) ||
       (self->state == SP_WINDOW_STATE_FAILED) ||
       (self->state == SP_WINDOW_STATE_BROWSING))
@@ -407,7 +399,16 @@ sp_window_stop_recording (SpWindow *self)
   if (self->state == SP_WINDOW_STATE_RECORDING)
     {
       if (self->profiler != NULL)
-        sp_profiler_stop (self->profiler);
+        {
+          /* SpProfiler::stopped will move us to generating */
+          gtk_label_set_label (self->subtitle, _("Stopping…"));
+          /*
+           * In case that ::stopped takes a while to execute,
+           * disable record button immediately.
+           */
+          gtk_widget_set_sensitive (GTK_WIDGET (self->record_button), FALSE);
+          sp_profiler_stop (self->profiler);
+        }
     }
 }
 


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