hi monks im having trouble with this problem, this little example code will check the username if it's existing on mysql server.

#!/usr/bin/perl use Gtk2 '-init'; use Glib qw/TRUE FALSE/; use threads; use threads::shared; use DBI; use DBD::mysql; our $type="mysql"; our $database="username"; our $host="http://mysite.com"; our $port="3306"; our $tablename="login"; 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("Check"); my $entry=Gtk2::Entry->new(); $button->signal_connect(clicked=>sub{ $str=$entry->get_text; my $thr=threads->create(\&continue_checking); }); $vbox->add($label); $vbox->add($entry); $vbox->add($button); $window->add($vbox); $window->show_all; Gtk2->main; sub continue_checking{ our $connect=DBI->connect($dsn,$user,$pwd)or die &mysql_Err; $query="SELECT username FROM login WHERE username=\"$str\""; $queryhandle=$connect->prepare($query); $queryhandle->execute; $queryhandle->bind_columns(undef, \my $user_name); while ($queryhandle->fetch()) { if("$str" eq "$user_name"){ &main; } } } sub main{ my $mw=Gtk2::Window->new; $mw->set_default_size(250, 250); my $label=Gtk2::Label->new("username $str is already exist"); $mw->add($label); $mw->show_all; $mw->show; } ->Error Result<- GLib-GObject-WARNING **: cannot register existing type `GConnectFlags' + at /usr/lib/perl/5.14/DynaLoader.pm line 207. Pango-WARNING **: shaping failure, expect ugly output. shape-engine='B +asicEngineFc', font='DejaVu Sans 9.9990234375', text='' at server.pl +line 40. Segmentation fault

is this like Tk problem that you cant execute a thread inside Gtk2 codes?


In reply to segmentation fault while using thread and gtk2 by Muskovitz

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.