Continuing my Gtk2 posting series, I am trying to popup a message dialog window but the script keeps freezing and goes into a loop. I have wrote this simple script that has the same logic ( or lack of) as the large script. can anyone point out my error?
#!/usr/bin/perl -w use strict; use warnings; use Glib qw/TRUE FALSE/; use Gtk2 '-init'; use threads; use threads::shared; my $magic: shared = 0; my $die: shared = 0; my $test = threads->new( \&test); my $window = Gtk2::Window->new( 'toplevel'); $window->set_border_width(20); $window->signal_connect('delete_event' => sub { $die = 1; $test->join; + Gtk2->main_quit; }); my $vbox = Gtk2::VBox->new( FALSE, 2); my $button = Gtk2::Button->new( "start"); $vbox->pack_start($button,FALSE,FALSE,4); $button->signal_connect( 'clicked' => sub { $magic = 1}); my $button1 = Gtk2::Button->new( "go"); $vbox->pack_start($button1,FALSE,FALSE,4); $button->signal_connect( 'clicked' => sub { $magic = 2}); $window->add( $vbox); $window->show_all; my $timer2 = Glib::Timeout->add(100, \&dialog); Gtk2->main; sub dialog { if ( $magic == 2) { # my $messagedialog_verification = Gtk2::MessageDialog->new( un +def, 'destroy-with-parent', 'question', 'yes-no', "Verify waypoints?" +); # my $response = $messagedialog_verification->run; # $messagedialog_verification->destroy; $magic = 1; } } sub test { while (1) { if ( $die == 1) {goto END}; if ($magic == 1) { for (;;) { if ( $magic == 2) { for (;;) { if ( $magic == 1) { last}; } } print "happy\n"; if ( $die == 1) {goto END}; if ( $magic == 0) { last}; } } } END: }

In reply to Gtk2: Message dialog by deadpickle

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.