[Development] [fix]: Assistant (and others) burning CPU because of #f27d1ccbb24ec2fd4098f2976503478831006cc8 ?

Jean-Michaël Celerier jeanmichael.celerier at gmail.com
Wed Aug 30 11:34:58 CEST 2017


> Today, that QObject::schedule is achieved by (ab)using
QTimer::singleShot(0, func).

There have been interesting discussions on StackOverflow about this :

https://stackoverflow.com/questions/21646467/how-to-execute-a-functor-or-a-lambda-in-a-given-thread-in-qt-gcd-style
https://stackoverflow.com/questions/24142450/qtimersingleshot-and-qmetamethodinvoke

Best
Jean-Michaël



-------
Jean-Michaël Celerier
http://www.jcelerier.name

On Wed, Aug 30, 2017 at 11:31 AM, Giuseppe D'Angelo <
giuseppe.dangelo at kdab.com> wrote:

> Il 30/08/2017 11:28, Morten Sørvig ha scritto:
>
>> There is also the option of creating new API that better covers the use
>> case of
>> running a pice of code once when control returns to the event loop. In
>> use this
>> could look something like this:
>>
>> QCocoaMenu::scheduleUpdate()
>> {
>>      if (m_updateScheduled)
>>         return;
>>      m_updateScheduled = true;
>>
>>      this->QObject::schedule([&m_updateScheduled, m_nativeMenu](){
>>         m_updateScheduled = false;
>>          [m_nativeMenu update];
>>      });
>> }
>>
>
> Today, that QObject::schedule is achieved by (ab)using
> QTimer::singleShot(0, func). I'd encourage a better named API.
>
> My 2 c,
> --
> Giuseppe D'Angelo | giuseppe.dangelo at kdab.com | Senior Software Engineer
> KDAB (UK) Ltd., a KDAB Group company | Tel: UK +44-1625-809908
> KDAB - Qt, C++ and OpenGL Experts
>
>
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20170830/5854844b/attachment.html>


More information about the Development mailing list