Qt5: Signals and QApplications inside Threads
Boris Mulder
boris.mulder at ...434...
Thu Oct 26 09:35:50 CEST 2017
That looks like a good start. So far I added (among others) the
following lines to my program:
Genode::Entrypoint ep { env, 64*1024, "signal_ep" };
Genode::Signal_handler<MyClass> _status_handler(ep, *this,
&MyClass::_handle_update);
_status_ds.sigh(_status_handler);
However, when the _status_ds ROM dataspace content changed (verified
using verbose=yes in the report_rom), the function _handle_update is not
invoked. I can see that the initial content of the dataspace at
initialization time is correct.
What else do I need to do for my Qt program to be able to receive signals?
On 24-10-17 17:11, Johannes Kliemann wrote:
> 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
>>
>
> ------------------------------------------------------------------------------
>
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> genode-main mailing list
> genode-main at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/genode-main
--
Met vriendelijke groet / kind regards,
Boris Mulder
Cyber Security Labs B.V. | Gooimeer 6-31 | 1411 DD Naarden | The Netherlands
+31 35 631 3253 (office)
More information about the users
mailing list