perf record: Don't call newt functions when not initialized

When processing events we want to give visual feedback to the user when
using the newt browser, so there are ui_progress calls in
__perf_session__process_events, but those should check if newt is being
used.

Reported-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Tested-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>,
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: Stephane Eranian <eranian@google.com>
Cc: Tom Zanussi <tzanussi@gmail.com>
LKML-Reference: <20100609123530.GB9471@ghostprotocols.net>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

+13 -2
+13 -2
tools/perf/util/newt.c
··· 43 44 if (self != NULL) { 45 int cols; 46 newtGetScreenSize(&cols, NULL); 47 cols -= 4; 48 newtCenteredWindow(cols, 1, title); ··· 70 71 void ui_progress__update(struct ui_progress *self, u64 curr) 72 { 73 newtScaleSet(self->scale, curr); 74 newtRefresh(); 75 } 76 77 void ui_progress__delete(struct ui_progress *self) 78 { 79 - newtFormDestroy(self->form); 80 - newtPopWindow(); 81 free(self); 82 } 83
··· 43 44 if (self != NULL) { 45 int cols; 46 + 47 + if (use_browser <= 0) 48 + return self; 49 newtGetScreenSize(&cols, NULL); 50 cols -= 4; 51 newtCenteredWindow(cols, 1, title); ··· 67 68 void ui_progress__update(struct ui_progress *self, u64 curr) 69 { 70 + /* 71 + * FIXME: We should have a per UI backend way of showing progress, 72 + * stdio will just show a percentage as NN%, etc. 73 + */ 74 + if (use_browser <= 0) 75 + return; 76 newtScaleSet(self->scale, curr); 77 newtRefresh(); 78 } 79 80 void ui_progress__delete(struct ui_progress *self) 81 { 82 + if (use_browser > 0) { 83 + newtFormDestroy(self->form); 84 + newtPopWindow(); 85 + } 86 free(self); 87 } 88