Hi,

I am writing a multi-threaded GUI in perl TK. Beside the main thread, the object of new thread is to monitor a server event queue and when ever there is a new event add it to a scrolled widget. At the same time the main thread might also add data to the scrolled widget as the scrolled widget is used for logging/status window.
When ever I try to add any event to the scrolled object from the child thread, my application dies with the following err:
Attempt to free non-existent shared string '_TK_RESULT_', Perl interpreter: 0x267d22c at C:/Perl/site/lib/Tk/Widget.pm

I would like to know if i can pass the object of scrolled widget or as a matter any hash reference to another thread in perl 5.10?

# Code to create scrolled widget my @CreateOptions = ['ROText', -label=>"Phone $Id", -labelPack => [-side => 'top', -expand + => 0, -anchor => 'w', -fill => 'y'], -wrap => 'none', -relief => 'gr +oove', -width=>$Width, -fg=>'white',-background=>"black", -scrollbars + => 'se']; @PackOptions = [-row=>0, -column=>0, -sticky=>"news", -columnspan=>7, +-rowspan=>19] $AFScroller->{LogScroller} = MW->Scrolled(@CreateOptions);# this is th +e object to scrolled widget $AFScroller->{LogScroller}->grid(@PackOptions); # code where new thread is created and scrolled widget object is used +to add event sub Activate { my $EventQueueTread = Thread->new(\&MonitorEventQueue, ($self, $Id) +); $EventQueueTread->detach; $AFScroller->{'LogScroller'}->insert('end',"xxx yyyyy"); $AFScroller->{'LogScroller'}->see('end'); $AFScroller->{'LogScroller'}->update; # do other stuff return 1; } sub MonitorEventQueue { START: $newevent = Checkeventqueue(); if ($newevent){ $AFScroller->{'LogScroller'}->insert('end',"$newevent");# this is w +hen application dies $AFScroller->{'LogScroller'}->see('end'); $AFScroller->{'LogScroller'}->update; } sleep 1; goto START; }
Your help is very much appreciated
Thanks,
Jai!

In reply to How to pass scrolled object to another thread by himanshujain_60

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.