Possible bug with multiple copies of a window in multiple threads.



I originally put (a slightly less refined version of) this on the
sourceforge page, but I'm not sure that it gets looked at.  Sorry for
the duplication.


When the program given below (demo.pl) is run is should pop up two
windows with a label in each.  However I get the following error
messages:

variable is not of type Gtk2::Container at ./demo.pl line 40.
variable is not of type Gtk2::Widget at ./demo.pl line 41.

Can someone enlighten me on what is going wrong.

Thank you.


------------demo.pl----------------------------
#!/usr/bin/perl -w

use strict;
use warnings;

use Gtk2 -init;

use threads;
use Thread::Queue;

new_win();

new_win();

Gtk2->main;

sub new_win {
    my $queue = Thread::Queue->new;
    my $block = Thread::Queue->new;
    my $win = Gtk2::Window->new('toplevel');
    my $sock = Gtk2::Socket->new;
    $win->add($sock);

    my $thread = threads->new(\&new_inner, $queue, $block);
    $queue->enqueue($sock->get_id);
    
    $block->dequeue;

    $win->show_all;
}

sub new_inner {
    my $queue = shift;
    my $block = shift;
    my $sockid = $queue->dequeue;

    my $plug = Gtk2::Plug->new($sockid);

    my $label = Gtk2::Label->new("Inner label");
    eval {$plug->add($label)}; warn $@ if $@;
    eval {$plug->show_all}; warn $@ if $@;

    $block->enqueue("");


    if (0) {
        Gtk2->main;
    }
}



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