Muskovitz has asked for the wisdom of the Perl Monks concerning the following question:

I've spent an hour to find the bug of this little program i made but whenever i click the the submit button the program ended immediately, In that time i don't know whats wrong with my code until i saw this error message.

[xcb] Unknown sequence number while processing queue [xcb] Most likely this is a multi-threaded client and XInitThreads has + not been called [xcb] Aborting, sorry about that. perl: ../../src/xcb_io.c:274: poll_for_event: Assertion `!xcb_xlib_thr +eads_sequence_lost' failed. Aborted

Here's my program code:

#!/usr/bin/perl use Gtk2 '-init -threads-init'; use Glib qw/TRUE FALSE/; use threads; use threads::shared; use DBI; use DBD::mysql; Glib::Object->set_threadsafe (1); our $type="mysql"; our $database="usr"; our $host="http://www.examplesite.com"; our $port="3306"; our $tablename="username_list"; our $user="username"; our $pwd="***********"; our $dsn="dbi:$type:$database:$host:$port"; our $query; our $queryhandle; my $str:shared=0; my $window=Gtk2::Window->new; $window->signal_connect('delete_event',sub{Gtk2->main_quit;}); $window->set_title("Perl Gtk2 Tutorial"); my $vbox=Gtk2::VBox->new; my $label=Gtk2::Label->new("Username: "); my $button=Gtk2::Button->new("Submit"); my $entry=Gtk2::Entry->new(); $button->signal_connect(clicked=>sub{ $str=$entry->get_text; my $thr=threads->create(\&check_exist); }); $vbox->add($label); $vbox->add($entry); $vbox->add($button); $window->add($vbox); $window->show_all; Gtk2->main; sub check_exist{ our $connect=DBI->connect($dsn,$user,$pwd); $query="SELECT * FROM username_list ORDER BY id DESC"; $queryhandle=$connect->prepare($query); $queryhandle->execute; $queryhandle->bind_columns(undef, \my $username); while ($queryhandle->fetch()) { if("$str" eq "$username"){ $label->set_text("Username already exist"); }else{ &start_thread2; } } } sub start_thread2{ my $thr2=threads->create(\&proceed); sub proceed{ my $mw=Gtk2::Window->new; $mw->signal_connect('delete_event', sub{Gtk2::main_quit}); my $label=Gtk2::Label->new("Hey $str how are you?"); $mw->add($label); $mw->show_all; $mw->show; } }

Thanks in advance

Replies are listed 'Best First'.
Re: xcb Unknown sequence number while processing queue in Perl/Gtk2
by Anonymous Monk on Jan 09, 2015 at 03:41 UTC
    Can you explain in words/pictures how that is supposed to work?

      well ok ill explain it in words, the user will enter a username and click submit, the submit button will start a thread that will connect to mysql server and execute those queries and checks if username already exist if not then it will start another thread, the second thread creates a new Gtk2 window w/ the label

      Hey $str how are you?.

      and then i get errors.

Re: xcb Unknown sequence number while processing queue in Perl/Gtk2
by chacham (Prior) on Jan 09, 2015 at 16:47 UTC

    Side Comment on the SQL. * Should be used only in COUNT(), EXISTS(), and ad-hoc queries. The query above could just as easily list the column it wants, which would help avoid errors when columns are added or reordered. As an added bonus, queries that list the columns they want is self-documenting.