Qt5: Signals and QApplications inside Threads

Johannes Kliemann Johannes.Kliemann at ...250...
Tue Oct 24 17:11:12 CEST 2017


Hi Boris,

I have a similar problem with running a Qt application from a second 
thread. In my case it segfaulted after QApplication::app.

Christian gave me a hint I wasn't able to try yet, but maybe it could be 
helpful for you, too.

> On Mon, Oct 16, 2017 at 01:42:04PM +0200, Johannes Kliemann wrote:
>> I tried to create a provide an input session from a libc (in this case
>> an Qt application). If I just run it from the Main struct it will
>> correctly announce the session but since Main never returns, no client
>> will be able to use it.
>> I tried to circumvent this by putting the application into a separate
>> thread but this led to the following error:
>>
>>> Error: void Libc::Kernel::run(Libc::Application_code&) called from non-kernel context
>>
>> Running this Qt application without wrapping it into with_libc makes it
>> segfault on initialization.
>>
>> What is the correct way to do this? My current main is at [1].
> 
> Unfortunately, there is no "correct" way of implementing tasks like
> the described currently. I must admit that with_libc() is the most
> confusing function in Genode currently and we therefore will remove it
> from the API soon. In fact, I myself did not expect that with_libc()
> is needed in your context but there may be dependencies unknown to me.
> 
> I'd suggest a careful look into libports/src/app/avplay which provides
> an input session too. The approach there is to create a second Genode
> entrypoint for the input service and execute Qt code in the component
> thread. I strongly encourage you not just to copy the avplay code as
> it uses the older, low-level Rpc_entrypoint but use
> Genode::Entrypoint.

Regards,
Johannes

On 10/23/17 15:51, Boris Mulder wrote:
> Dear Genode folks,
> 
> I have built an application with Qt5. I want it to also be able to read
> ROM modules from a report_rom server and to be able to handle updates to
> that ROM using signals.
> 
> When I run QApplication::exec() however, it does not return and the
> entrypoint cannot listen to signals, causing them to be ignored.
> 
> So I created another QThread and run my QApplication in there. Now I get
> the following error:
> 
>      WARNING: QApplication was not created in the main() thread.
> 
> And the application does not do anything and does not react to events.
> 
> What can I do to be able to run both the qt event loop and the genode
> event loop?
> 
> 
> regards,
> 
> Boris
> 




More information about the users mailing list