PerlQt and threads

View: New views
4 Messages — Rating Filter:   Alert me  

PerlQt and threads

by Rafał Grzegorz Sławik :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello

I have some problem: How can I open new window (from thread)?
When I try to do $window->show; I get error "Xlib: unexpected async reply". Is
there any solution to solve this problem?
[I have already opened one window.]

--
Pozdrawiam
Rafał Grzegorz Sławik
http://www.zarabiaj.edu.pl
< allegro: swistakrs >
_______________________________________________
Kde-perl mailing list
Kde-perl@...
https://mail.kde.org/mailman/listinfo/kde-perl

Re: PerlQt and threads

by Joe Carlson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


I ran into a (similar sounding) problem a while back. The problem was
that Perl garbage collection was making the variable go out of scope.
Once the variable destroyed, no more window. So while I don't know if
this is your problem it possibly could be.

I relied on a global list to push the window variable on to prevent
garbage collection:

    my $newWindow = main::ModuleView();
    $newWindow->show();
    push @main::windowsList, $newWindow;

Even using a circular reference works (for now, anyway), just save the
window variable as one of the module variables. This ought to work until
the garbage collection gets smarter.

joe

On Mon, 2007-12-10 at 15:10 -0700, Roy Souther wrote:

> I am the moderator for the PerlQt list. Your message was held back
> because your sending email address is not in the list. This is to
> protect our members from SPAM. Sorry for the delay.
>
> I have not used threads in Perl but I would expect it to be logically
> the same as threads in C++. I would expect that the $window variable
> is out of scope and cannot be access by the thread. I would advice you
> to use a call back from the child thread to the parent thread that
> asks the parent thread that does have $window in scope to show the
> window by proxy.
>
> You will need to lookup how to do callbacks in Perl, I don't have an
> example for that but I am sure it can be done.
>
> On Tue, 2007-12-04 at 15:52 +0100, Rafał Grzegorz Sławik wrote:
> > Hello
> >
> > I have some problem: How can I open new window (from thread)?
> > When I try to do $window->show; I get error "Xlib: unexpected async reply". Is
> > there any solution to solve this problem?
> > [I have already opened one window.]
> >
>
> Royce Souther
> www.SiliconTao.com
> Let Open Source help your business move beyond.
>
> For security this message is digitally authenticated by GnuPG.
>
>
>
>
> _______________________________________________
> Kde-perl mailing list
> Kde-perl@...
> https://mail.kde.org/mailman/listinfo/kde-perl

_______________________________________________
Kde-perl mailing list
Kde-perl@...
https://mail.kde.org/mailman/listinfo/kde-perl

Re: PerlQt and threads

by Roy Souther :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I am the moderator for the PerlQt list. Your message was held back because your sending email address is not in the list. This is to protect our members from SPAM. Sorry for the delay.

I have not used threads in Perl but I would expect it to be logically the same as threads in C++. I would expect that the $window variable is out of scope and cannot be access by the thread. I would advice you to use a call back from the child thread to the parent thread that asks the parent thread that does have $window in scope to show the window by proxy.

You will need to lookup how to do callbacks in Perl, I don't have an example for that but I am sure it can be done.

On Tue, 2007-12-04 at 15:52 +0100, Rafał Grzegorz Sławik wrote:
Hello

I have some problem: How can I open new window (from thread)?
When I try to do $window->show; I get error "Xlib: unexpected async reply". Is 
there any solution to solve this problem?
[I have already opened one window.]


roy@...
www.SiliconTao.com
Let Open Source help your business move beyond.

For security this message is digitally authenticated by GnuPG.





_______________________________________________
Kde-perl mailing list
Kde-perl@...
https://mail.kde.org/mailman/listinfo/kde-perl

signature.asc (196 bytes) Download Attachment

Re: PerlQt and threads

by Gary L. Greene, Jr.-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Monday 10 December 2007 02:10:47 pm Roy Souther wrote:

> I am the moderator for the PerlQt list. Your message was held back
> because your sending email address is not in the list. This is to
> protect our members from SPAM. Sorry for the delay.
>
> I have not used threads in Perl but I would expect it to be logically
> the same as threads in C++. I would expect that the $window variable is
> out of scope and cannot be access by the thread. I would advice you to
> use a call back from the child thread to the parent thread that asks the
> parent thread that does have $window in scope to show the window by
> proxy.

Actually, no. Based off a discussion a while back with Ashley and Gerand,
PerlQt is not perl-thread safe. The main reason for this is that Perl threads
and the native NPTL threads that Qt uses are NOT compatible at all and may
cause some rather unusual and nasty application lockups.

> You will need to lookup how to do callbacks in Perl, I don't have an
> example for that but I am sure it can be done.
>
> On Tue, 2007-12-04 at 15:52 +0100, Rafał Grzegorz Sławik wrote:
> > Hello
> >
> > I have some problem: How can I open new window (from thread)?
> > When I try to do $window->show; I get error "Xlib: unexpected async
> > reply". Is there any solution to solve this problem?
> > [I have already opened one window.]
>
> Royce Souther
> www.SiliconTao.com
> Let Open Source help your business move beyond.
>
> For security this message is digitally authenticated by GnuPG.



--
Gary L. Greene, Jr.
Sent from: peorth.tolharadys.net
 14:18:01 up 11 days, 18:42,  3 users,  load average: 0.12, 0.20, 0.70
==========================================================================
Developer and Project Lead for the AltimatOS open source project
Volunteer Developer for the KDE open source project
See http://www.altimatos.com/ and http://www.kde.org/ for more information
==========================================================================

Please avoid sending me Word or PowerPoint attachments.
_______________________________________________
Kde-perl mailing list
Kde-perl@...
https://mail.kde.org/mailman/listinfo/kde-perl