testgtk --bench bokenness
- From: Matthias Clasen <maclas gmx de>
- To: gtk-devel-list gnome org
- Subject: testgtk --bench bokenness
- Date: 19 Nov 2002 01:54:44 +0100
Hi,
testgtk --bench ALL segfaults for me, since it calls the various create
functions without arguments, i.e. the widget argument is garbage. The
segfault occurs in gtk_widget_get_screen(), which seems to be the only
use of the widget argument in most create functions. Here is a patch
which makes --bench ALL work again with a reasonable amount of g_warning
spew. Ok to commit ?
Matthias
Index: testgtk.c
===================================================================
RCS file: /cvs/gnome/gtk+/tests/testgtk.c,v
retrieving revision 1.326
diff -u -b -B -p -r1.326 testgtk.c
--- testgtk.c 13 Nov 2002 12:58:43 -0000 1.326
+++ testgtk.c 19 Nov 2002 00:42:40 -0000
@@ -12271,7 +12327,7 @@ do_exit (GtkWidget *widget, GtkWidget *w
struct {
char *label;
- void (*func) ();
+ void (*func) (GtkWidget *widget);
gboolean do_not_benchmark;
} buttons[] =
{
@@ -12468,16 +12524,16 @@ pad (const char *str, int to)
}
static void
-bench_iteration (void (* fn) ())
+bench_iteration (GtkWidget *widget, void (* fn) (GtkWidget *widget))
{
- fn (); /* on */
+ fn (widget); /* on */
while (g_main_context_iteration (NULL, FALSE));
- fn (); /* off */
+ fn (widget); /* off */
while (g_main_context_iteration (NULL, FALSE));
}
void
-do_real_bench (void (* fn) (), char *name, int num)
+do_real_bench (GtkWidget *widget, void (* fn) (GtkWidget *widget), char *name, int num)
{
GTimeVal tv0, tv1;
double dt_first;
@@ -12492,7 +12548,7 @@ do_real_bench (void (* fn) (), char *nam
}
g_get_current_time (&tv0);
- bench_iteration (fn);
+ bench_iteration (widget, fn);
g_get_current_time (&tv1);
dt_first = ((double)tv1.tv_sec - tv0.tv_sec) * 1000.0
@@ -12500,7 +12556,7 @@ do_real_bench (void (* fn) (), char *nam
g_get_current_time (&tv0);
for (n = 0; n < num - 1; n++)
- bench_iteration (fn);
+ bench_iteration (widget, fn);
g_get_current_time (&tv1);
dt = ((double)tv1.tv_sec - tv0.tv_sec) * 1000.0
+ (tv1.tv_usec - tv0.tv_usec) / 1000.0;
@@ -12516,15 +12572,18 @@ void
do_bench (char* what, int num)
{
int i;
- void (* fn) ();
+ GtkWidget *widget;
+ void (* fn) (GtkWidget *widget);
fn = NULL;
+ widget = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ gtk_widget_show (widget);
if (g_ascii_strcasecmp (what, "ALL") == 0)
{
for (i = 0; i < nbuttons; i++)
{
if (!buttons[i].do_not_benchmark)
- do_real_bench (buttons[i].func, buttons[i].label, num);
+ do_real_bench (widget, buttons[i].func, buttons[i].label, num);
}
return;
@@ -12543,7 +12602,7 @@ do_bench (char* what, int num)
if (!fn)
g_print ("Can't bench: \"%s\" not found.\n", what);
else
- do_real_bench (fn, buttons[i].label, num);
+ do_real_bench (widget, fn, buttons[i].label, num);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]