Re: how to use set_threadsafe



Hi,
I think these problems are relative to perl-Gtk2 itself, as I also get a lof of
warnings when I use a filechooser button, these warnings vary with the Gtk
version used.
I used threads quite recently, with a glade interface loaded. The syntax was
something like

sub callback {
   my $thread = threads->create("action", parameters);
}

sub action {
   Gtk2::Gdk::Threads->enter;
   ... statements, global variables like the pointer to my glade interface are
still defined ...
   ...If you do something to the interface, refresh it :
Gtk2->main_iteration_do(0) (non blocking call)...
   Gtk2::Gdk::Threads->leave;
}

I don't remeber if I entered the threads mode before calling Gtk2->main;

Madcat

Selon zentara <zentara zentara net>:

Hi,
I'm looking at the thread_usage example from the latest
gtk+-2.8.7 and the perl GTK2-1.111 and I'm already
stymied. :-)

The thread_usage example provided works fine, but
the example is an object-oriented one, and it differs
from the one from earlier versions, which was more
of a functional style.

Anyways..... I have an example which was working under
the older libraries I had, and wanted to see how far I could
"push" the thread-safety capabilities.

So my first step was just to ue the standard init statements
used in the example.

So I put the lines in the script below and the die statement
causes a non-fatal warning:

use Gtk2 qw/-init -threads-init/;
die "Glib::Object thread safetly failed"
        unless Glib::Object->set_threadsafe (TRUE);

The warning I get is:
GLib-CRITICAL **: g_hash_table_foreach: assertion `hash_table != NULL' failed
at ./basic-thread-test line 23.

If I comment out the die statement, I don't get the error.

The script runs fine either way. So what is set_threadsafe complaining
about?
Also, if anyone can give tips on how far the thread-safety mechanism
can be pushed, it would be appreciated. Can you directly access widgets
in the main thread from a worker thread?

Thanks.



--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html





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