perf ui: Add ui_progress__finish()
authorNamhyung Kim <namhyung.kim@lge.com>
Tue, 13 Nov 2012 13:30:34 +0000 (22:30 +0900)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 14 Nov 2012 19:52:56 +0000 (16:52 -0300)
Sometimes we need to know when the progress bar should disappear.

Checking curr >= total wasn't enough since there're cases not met that
condition for the last call.

So add a new ->finish callback to identify this explicitly.  Currently
only GTK frontend needs it.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1352813436-14173-4-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/ui/gtk/progress.c
tools/perf/ui/progress.c
tools/perf/ui/progress.h
tools/perf/util/debug.h
tools/perf/util/session.c

index 903426f..482bcf3 100644 (file)
@@ -40,8 +40,17 @@ static void gtk_progress_update(u64 curr, u64 total, const char *title)
                gtk_main_iteration();
 }
 
+static void gtk_progress_finish(void)
+{
+       /* this will also destroy all of its children */
+       gtk_widget_destroy(dialog);
+
+       dialog = NULL;
+}
+
 static struct ui_progress gtk_progress_fns = {
        .update         = gtk_progress_update,
+       .finish         = gtk_progress_finish,
 };
 
 void perf_gtk__init_progress(void)
index f5e4d1b..3ec6956 100644 (file)
@@ -18,3 +18,9 @@ void ui_progress__update(u64 curr, u64 total, const char *title)
 {
        return progress_fns->update(curr, total, title);
 }
+
+void ui_progress__finish(void)
+{
+       if (progress_fns->finish)
+               progress_fns->finish();
+}
index 717814b..257cc22 100644 (file)
@@ -5,6 +5,7 @@
 
 struct ui_progress {
        void (*update)(u64, u64, const char *);
+       void (*finish)(void);
 };
 
 extern struct ui_progress *progress_fns;
@@ -12,5 +13,6 @@ extern struct ui_progress *progress_fns;
 void ui_progress__init(void);
 
 void ui_progress__update(u64 curr, u64 total, const char *title);
+void ui_progress__finish(void);
 
 #endif
index dec9875..83e8d23 100644 (file)
@@ -26,6 +26,7 @@ int ui__error(const char *format, ...) __attribute__((format(printf, 1, 2)));
 static inline void ui_progress__update(u64 curr __maybe_unused,
                                       u64 total __maybe_unused,
                                       const char *title __maybe_unused) {}
+static inline void ui_progress__finish(void) {}
 
 #define ui__error(format, arg...) ui__warning(format, ##arg)
 
index 15abe40..ce6f511 100644 (file)
@@ -1458,6 +1458,7 @@ more:
        session->ordered_samples.next_flush = ULLONG_MAX;
        err = flush_sample_queue(session, tool);
 out_err:
+       ui_progress__finish();
        perf_session__warn_about_errors(session, tool);
        perf_session_free_sample_buffers(session);
        return err;