Re: Threads and gtk_widget_show (code should not be reached?)



BTW, g_main_context_invoke() will be erratic if you do not have the main
context loop running. This is common at startup, when you do all sort of
gtk_xx before entering the main loop. Solution: start the loop as soon as
possible in the main thread, and anything else the main thread needs to do,
put in a g_idle function.

2013/1/30 Edscott Wilson <edscott wilson garcia gmail com>

The current method for calling gtk_xx instructions is from the main thread
only (i.e., that which owns the main loop context). You can do this by
means of g_main_context_invoke(). Otherwise you must use the deprecated
gdk_threads_enter/gdk_threads_leave mutex method. The deprecated method is
slower.

If you do not do the above, you will get all sort of errors just like the
one you describe.

HTH


2013/1/30 Ferdinand Ramirez <ramirez ferdinand yahoo com>

I have encountered a strange error followed by a crash when I add the
following object to a GtkTextView by creating a child anchor and call
gtk_widget_show_all.

The object that is added

The object that is added to the child anchor is a GtkFrame inside which
is a GtkTable and each cell of the table contains another GtkFrame each of
which contains a GtkTextView.

The error

This works fine if it is all done from the main program. However, when I
create the hierarchy described above in another thread and call
gtk_widget_show_all on the GtkFrame that is added, I get an error in paint
saying code should not be reached. Before this error, there is a warning
that the iterator in text view has changed. I am not sure if the warning
and error are related.

Source of the error

I replaced gtk_widget_show_all by gtk_widget_show in a loop going down
the tree and calling it for each object. The source of the error was the
gtk_widget_show on the leaf level view objects in the frames contained in
each cell of the table.

Situations under which it works

When the leaf level GtkTextView objects are not part of the hierarchy of
widgets I create or they are replaced by GtkEntry objects, everything works
fine. Again, note that it also works fine if I do not have another thread
and call everything from the main program on startup but I need to have
another thread as this object will be created during the course of the
program. I've tried both g_idle_add as well as using the
gdk_threads_enter/leave pair.

Any help will be appreciated.

-Ferdinand
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]