Re: Notebooks in Gtk+ v1.2.x
- From: Carlos Pereira <carlos pehoe civil ist utl pt>
- To: gtk-app-devel-list gnome org
- Subject: Re: Notebooks in Gtk+ v1.2.x
- Date: Sat, 25 Jan 2003 16:55:17 GMT
Jim,
Perhaps I got something wrong, otherwise, pleaaase...
To start with, when you have a problem is a good
ideia to prepare a test program showing the issue,
but this program should be as small as possible,
say 50-80 lines. Your test program had 1060 lines,
including copyright notices (do you expect them to
help find the problem?)
Anyway, I compiled and run your test program.
When I change to view1, and then press Zoom in
I get this message:
Gtk-CRITICAL **: file gtkwidget.c: line 1833 (gtk_widget_queue_draw): assertion `widget != NULL' failed.
This usually would mean that your glarea widget is pointing to NULL.
A quick text search in vi showed that you have only two lines
gtk_widget_queue_draw(current->glarea) in the whole file, in
the Zoom In and Zoom Out callbacks. I added a printf and run
again your code: definitely you were passing a NULL argument
for gtk_widget_queue_draw, no wonder your app is crashing!
After that I did another text search in vi, looking for
current->glarea: only the two lines above were found.
(a third one, unrelated, is commented) then I confirmed
that indeed current is a global variable. The conclusion is,
current->glarea is never initialized or updated directly.
Then I found that in fact you use the function:
create_glarea_page ( drawing_area.notebook_page,
drawing_area.glarea );
to save the glarea address. The problem here is that,
in C, arguments are passed by value, so you need to
pass &drawing_area.glarea, not drawing_area.glarea,
as two printfs one before and other after can
prove, both glareas will point to NULL, you are
just updating drawing_area.glarea inside the function,
outside, drawing_area.glarea still points to NULL!
(automatic refreshs work because the glarea address
is automatically saved when the connect_signal function
is executed).
Then I tried to understand why everytime I ran your
test, I received this message: Page 0 not found!,
apparently you had some problem with your notebook.
I did another text search in vi, this time looking
for "not found" and I came across the code below:
No wonder your test program was printing "Page number 0 not found",
you have this fprintf outside the if, actually
even outside the for! of course it runs always!
typDrawingArea *
find_notebook_page(GSList *list, gint page_number)
{
int i;
GSList *node;
typDrawingArea *item;
for (i = 0; (node = g_slist_nth (list, i)); i++)
{
item = node->data;
if (item->page_number == page_number)
{
fprintf(stderr,"Page number %d found!\n", item->page_number);
return (item);
}
}
fprintf(stderr,"Page number %d not found !\n", page_number);
return (NULL);
}
Carlos
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]