Re: Warnings/Errors during Threaded Execution



I'm guessing that you're accessing some widgets in a separate thread (or in your callbacks).  Whenever you do this, you need to lock the widgets so that you're not modifying them while they are trying to be drawn.  So in a callback, you need
gdk_threads_leave();
// the code that is needed for the callback
gdk_threads_enter();
 
or, when you're in the thread that you started, you need to do the same thing anytime that you're accessing widgets.
 
One last thing, in your main program, make sure that you do the following...
gdk_threads_enter();
gtk_main();
gdk_threads_leave();
 
This way, the main loop runs correctly with threads.
 
I can't promise that this is the textbook example of how to work with multithreads, but it's what I got working after many hours of trial & error.

Christopher Bland <themanatuf juno com> wrote:
From: "Christopher Bland" <themanatuf juno com>
Date: Thu, 30 Nov 2006 17:17:39 GMT
To: gtk-devel-list gnome org
Subject: Warnings/Errors during Threaded Execution

I've searched these lists as well as Google but am unable to find
anything to point me in the right direction...

I created a GTK+ app in C with all commands running sequentially. The
app behaved perfectly and I never received any errors/warnings. I have
started to make the app multi-threaded and followed the docs at:

http://developer.gnome.org/doc/API/2.0/gdk/gdk-Threads.html

The messages:

(aurora:14553): GLib-GObject-WARNING **: IA__g_object_thaw_notify:
property-changed notification for GtkLabel(0x80c5d20) is not frozen

(aurora:30975): GLib-GObject-CRITICAL **: g_object_unref: assertion
`object->ref_count > 0' failed

The code is kind of large and I could attempt to "dumb" it down if
needed. Basically it is a window with a few labels, textboxes and 3
buttons. One button starts the app's processing, the other stops the
processing, and the third just clears the textboxes.

Clicking the first button fires the 'clicked' event where I make the
following calls:

g_thread_init(NULL);
gdk_threads_init();

A few lines later I create my threads and go:

if ((t_g1 = g_thread_create((GThreadFunc)process, NULL, TRUE, &err1))
== NULL)
g_error_free(err1);

Those lines are the only ones I added (other than
gdk_threads_enter()/gdk_threads_leave() in my timer and callbacks).

If anyone has seen these messages before and can point me in a
direction to fix it I would greatly appreciate it. Thank you very much!


________________________________________________________________________
Try Juno Platinum for Free! Then, only $9.95/month!
Unlimited Internet Access with 1GB of Email Storage.
Visit http://www.juno.com/value to sign up today!


_______________________________________________
gtk-devel-list mailing list
gtk-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-devel-list


Cheap Talk? Check out Yahoo! Messenger's low PC-to-Phone call rates.

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