[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-bindings
Subject:    Re: [Kde-bindings] Qt and Multithread
From:       Albert Cervera Areny <albertca () hotpop ! com>
Date:       2005-10-18 21:52:44
Message-ID: 200510182352.45153.albertca () hotpop ! com
[Download RAW message or body]

Please take a look at http://doc.trolltech.com/3.3/threads.html as some 
concepts will also apply to Ruby. Most important for you will be the 
"Thread-safe Event Posting".

Summarying, you have to run the main Qt loop with the same thread of your 
application. If you run another thread, you can't call GUI operations 
directly from the other thread. You need to postEvent() and reimplement 
customEvent() and make the GUI operations in there.

A Tuesday 18 October 2005 11:04, Stefan Champailler va escriure:
> Now that I'm reading the mail in question again, I see :
>
> "Ruby threads don't know anything about the Qt event loop. "
>
> what does this mean exactly ?
>
>
> stF
>
> > Sorry about this question, I just saw there's on previous post on
> > this ML that deals with the very same kind of issue... There :
> >
> > http://lists.kde.org/?l=kde-bindings&m=112798649226241&w=2
> >
> > stF
> >
> > > Dear all,
> > >
> > >
> > > I'm still developping my robot for konqueror and I've stumbled
> > > on a fundamental issue.
> > >
> > > I want to have a robot that can control konqueror to make GUI
> > > testing (and I have a good reason to do it like that, HttpUnit
> > > won't do it).
> > >
> > > The thing I want to achieve is to have several little functions
> > > that allow me to write scripts like this :
> > >
> > > # this is ruby code...
> > > openURL(google.org")
> > > fillForm("search","what I serach for")
> > > submitForm("search")
> > > assert( link_present("www.mysite.com"))
> > >
> > > To achieve this, ruby must have the control flow. However, if I
> > > use Korundum and a KApplication, the control flow is passed to
> > > Qt. This leads to code like this, with an event handler :
> > >
> > > case scenarioStep
> > >     when 1
> > >         openURL(google.org")
> > >     when 2
> > >         fillForm("search","what I serach for")
> > >     ...
> > > end
> > > scenarioStep++
> > >
> > > this works but it's not nice : having to write down all these
> > > "when" is not nice.
> > >
> > > What I was thinking on is to have two threads. One threads
> > > running the QT stuff (one window with a KHTML part) and another
> > > running my script. This way the application loop control flow is
> > > handled separately of the scenario control flow.
> > >
> > > The problem is that first, if I create a thread beside the
> > > KApplication.exec one, it is run only if events are thrown at
> > > the KApplication.exec.
> > >
> > > Second, if I write :
> > >
> > > a = KDE::Application.new()
> > >
> > > Thread.new {
> > >     a.exec
> > > }
> > >
> > > it crashes miserably.
> > >
> > > Any suggestion ?
> > >
> > > Thank you !
> > >
> > > Stefan
_______________________________________________
Kde-bindings mailing list
Kde-bindings@kde.org
https://mail.kde.org/mailman/listinfo/kde-bindings
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic