Re: Goo::Canvas deadlock on Gtk2::Gdk::Threads->enter
- From: muppet <scott asofyet org>
- To: Xi Yang <jiandingzhe msn com>
- Cc: gtk-perl-list gnome org
- Subject: Re: Goo::Canvas deadlock on Gtk2::Gdk::Threads->enter
- Date: Fri, 7 May 2010 20:42:43 -0400
On May 7, 2010, at 3:07 AM, Xi Yang wrote:
The following app has a GooCanvas, and has a button which will add a rect on canvas after clicked. It
deadlocks while click on "Add" button.
##################################################
#!/usr/bin/perl
use strict;
use threads;
use threads::shared;
use Glib qw/TRUE FALSE/;
use Gtk2 qw/-init -threads-init/;
use Goo::Canvas;
Glib::Object->set_threadsafe(TRUE);
# create window
my $win = Gtk2::Window->new;
$win->signal_connect( destroy => sub { Gtk2->main_quit; } );
$win->set_title('children rendering test');
my $vbox = Gtk2::VBox->new( FALSE, 6 );
$win->add($vbox);
# create Add button
my $hbox = Gtk2::HBox->new(FALSE,6);
$vbox->pack_start($hbox,FALSE,FALSE,0);
my $but_add_node = Gtk2::Button->new('Add');
$hbox->pack_start($but_add_node,FALSE,FALSE,0);
$but_add_node->signal_connect('clicked'=>\&on_add);
# create the c anvas
my $canvas = Goo::Canvas->new();
my $root = $canvas->get_root_item;
$canvas->set_size_request( 800, 500 );
$vbox->pack_start( $canvas, FALSE, FALSE, 0 );
# enter mainloop
$win->show_all;
Gtk2::Gdk::Threads->enter;
Gtk2->main;
Gtk2::Gtk::Threads->leave;
If you're going to use gdk_threads_enter() and gdk_threads_leave() to protect your callbacks, then you need
to call gdk_threads_enter() before calling Gtk2->main. The main loop will release the lock before it starts
each iteration.
http://mail.gnome.org/archives/gtk-devel-list/2007-January/msg00137.html
http://blogs.operationaldynamics.com/andrew/software/gnome-desktop/gtk-thread-awareness.html
sub on_add {
Gtk2::Gdk::Threads->enter;
Goo::Canvas::Rect->new(
$root,100,100,50,120
);
Gtk2::Gdk::Threads->leave;
}
##################################################
Hotmail: Trusted email with powerful SPAM protection. Sign up
now._______________________________________________
gtk-perl-list mailing list
gtk-perl-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-perl-list
--
Well done, Android. Aperture Science reminds you that Android Hell is a real place, and you will be sent
there at the first sign of defiance.
-- GlaDOS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]