Skip to contentSkip to conversation

perf ui/gtk: Ensure not to call gtk_main_quit() twice

PATCH In review Namhyung Kim 2 participants 7 messages Aug 17, 2012 – Aug 21, 2012 perf events

lore
Share & tools
lore

Namhyung Kim

author maintainer
#0 lore raw

PATCH 1/1 perf ui/gtk: Ensure not to call gtk_main_quit() twice

Currently the gtk_main_quit() is called twice when perf exits so the following warning is emitted:

  [penberg@tux perf]$ ./perf report --gtk
  ^Cperf: Interrupt

(perf:4048): Gtk-CRITICAL **: IA__gtk_main_quit: assertion `main_loops != NULL' failed

Fix it by not to call it unnecessarily.

---
 tools/perf/ui/gtk/setup.c |    2 ++
 1 file changed, 2 insertions(+)
tools/perf/ui/gtk/setup.c +2 -0
index ad40b3626fdb..ec1ee26b485a 100644
@@ -13,6 +13,8 @@ int perf_gtk__init(void)
 
 void perf_gtk__exit(bool wait_for_ok __used)
 {
+	if (!perf_gtk__is_active_context(pgctx))
+		return;
 	perf_error__unregister(&perf_gtk_eops);
 	gtk_main_quit();
 }
Signature · 1 line
1.7.9.2
#1 lore raw
Quoted 21 lines · Namhyung Kim

Currently the gtk_main_quit() is called twice when perf exits so the following warning is emitted:

  [penberg@tux perf]$ ./perf report --gtk
  ^Cperf: Interrupt

(perf:4048): Gtk-CRITICAL **: IA__gtk_main_quit: assertion `main_loops != NULL' failed

Fix it by not to call it unnecessarily.

---
 tools/perf/ui/gtk/setup.c |    2 ++
 1 file changed, 2 insertions(+)
tools/perf/ui/gtk/setup.c +0 -0
index ad40b3626fdb..ec1ee26b485a 100644

tools/perf/ui/gtk/setup.c int perf_gtk__init(void) · line 20

Quoted 8 lines
tools/perf/ui/gtk/setup.c +2 -0
@@ -13,6 +13,8 @@ int perf_gtk__init(void)
 
 void perf_gtk__exit(bool wait_for_ok __used)
 {
+       if (!perf_gtk__is_active_context(pgctx))
+               return;
        perf_error__unregister(&perf_gtk_eops);
        gtk_main_quit();
 }

Wouldn't it be nicer to rearrange the callers so that perf_gtk__exit() is not called twice?

author maintainer
#2 lore raw
Quoted 23 lines · Pekka Enberg
Quoted 22 lines · Namhyung Kim

Currently the gtk_main_quit() is called twice when perf exits so the following warning is emitted:

  [penberg@tux perf]$ ./perf report --gtk
  ^Cperf: Interrupt

(perf:4048): Gtk-CRITICAL **: IA__gtk_main_quit: assertion `main_loops != NULL' failed

Fix it by not to call it unnecessarily.

---
 tools/perf/ui/gtk/setup.c |    2 ++
 1 file changed, 2 insertions(+)
tools/perf/ui/gtk/setup.c +0 -0
index ad40b3626fdb..ec1ee26b485a 100644
@@ -13,6 +13,8 @@ int perf_gtk__init(void)
 
Quoted 10 lines

tools/perf/ui/gtk/setup.c int perf_gtk__init(void) · line 20

Quoted 7 lines
tools/perf/ui/gtk/setup.c +2 -0
 void perf_gtk__exit(bool wait_for_ok __used)
 {
+       if (!perf_gtk__is_active_context(pgctx))
+               return;
        perf_error__unregister(&perf_gtk_eops);
        gtk_main_quit();
 }

Wouldn't it be nicer to rearrange the callers so that perf_gtk__exit() is not called twice?

You mean this?

tools/perf/ui/setup.c +3 -1
index c7820e569660..d25e145e9a89 100644
@@ -2,6 +2,7 @@
 
 #include "../cache.h"
 #include "../debug.h"
+#include "gtk/gtk.h"
 
 
 pthread_mutex_t ui__lock = PTHREAD_MUTEX_INITIALIZER;
@@ -37,7 +38,8 @@ void exit_browser(bool wait_for_ok)
 {
 	switch (use_browser) {
 	case 2:
-		perf_gtk__exit(wait_for_ok);
+		if (perf_gtk__is_active_context(pgctx))
+			perf_gtk__exit(wait_for_ok);
 		break;
 
 	case 1:
author maintainer
#3 lore raw
Quoted 12 lines · Namhyung Kim
Quoted 2 lines · Pekka Enberg

Wouldn't it be nicer to rearrange the callers so that perf_gtk__exit() is not called twice?

You mean this?

tools/perf/ui/setup.c +0 -0
index c7820e569660..d25e145e9a89 100644

tools/perf/ui/setup.c line 5

Quoted 4 lines
tools/perf/ui/setup.c +1 -0
@@ -2,6 +2,7 @@
 
 #include "../cache.h"
 #include "../debug.h"
+#include "gtk/gtk.h"

Oops, it should be

   #ifndef NO_GTK2_SUPPORT
   # include "gtk/gtk.h"
   #endif

Thanks,
Namhyung

Quoted 13 lines
tools/perf/ui/setup.c +2 -1
 pthread_mutex_t ui__lock = PTHREAD_MUTEX_INITIALIZER;
@@ -37,7 +38,8 @@ void exit_browser(bool wait_for_ok)
 {
 	switch (use_browser) {
 	case 2:
-		perf_gtk__exit(wait_for_ok);
+		if (perf_gtk__is_active_context(pgctx))
+			perf_gtk__exit(wait_for_ok);
 		break;
 
 	case 1:
author maintainer
#4 lore raw
Quoted 20 lines · Namhyung Kim
Quoted 12 lines · Namhyung Kim
Quoted 2 lines · Pekka Enberg

Wouldn't it be nicer to rearrange the callers so that perf_gtk__exit() is not called twice?

You mean this?

tools/perf/ui/setup.c +0 -0
index c7820e569660..d25e145e9a89 100644

tools/perf/ui/setup.c line 5

Quoted 4 lines
tools/perf/ui/setup.c +1 -0
@@ -2,6 +2,7 @@
 
 #include "../cache.h"
 #include "../debug.h"
+#include "gtk/gtk.h"

Oops, it should be

Quoted 4 lines
   #ifndef NO_GTK2_SUPPORT
   # include "gtk/gtk.h"
   #endif

Forgot to add the #ifdefery to the below code also. :-/ Anyway, it needs to expose gtk specifics to general code with the #ifdef's. So I'd still prefer the original patch.

Thanks,
Namhyung

Acked-by
#5 lore raw
Quoted 3 lines · Namhyung Kim

Forgot to add the #ifdefery to the below code also. :-/ Anyway, it needs to expose gtk specifics to general code with the #ifdef's. So I'd still prefer the original patch.

Fair enough.

author maintainer
#6 lore raw

[tip:perf/core] perf ui gtk: Ensure not to call gtk_main_quit() twice

In reply to Namhyung Kim
Commit-ID:  2708bf3a30b7bfa02d60a3f03603b6b92d093f1a
Gitweb:     http://git.kernel.org/tip/2708bf3a30b7bfa02d60a3f03603b6b92d093f1a
Author:     Namhyung Kim <[email protected]>
AuthorDate: Sat, 18 Aug 2012 01:56:23 +0900
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Mon, 20 Aug 2012 09:29:12 -0300

perf ui gtk: Ensure not to call gtk_main_quit() twice

Currently the gtk_main_quit() is called twice when perf exits so the following warning is emitted:

  [penberg@tux perf]$ ./perf report --gtk
  ^Cperf: Interrupt

(perf:4048): Gtk-CRITICAL **: IA__gtk_main_quit: assertion `main_loops != NULL' failed

Fix it by not to call it unnecessarily.

---
 tools/perf/ui/gtk/setup.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
tools/perf/ui/gtk/setup.c +2 -0
index ad40b36..ec1ee26 100644
@@ -13,6 +13,8 @@ int perf_gtk__init(void)
 
 void perf_gtk__exit(bool wait_for_ok __used)
 {
+	if (!perf_gtk__is_active_context(pgctx))
+		return;
 	perf_error__unregister(&perf_gtk_eops);
 	gtk_main_quit();
 }