[Qt-interest] Forcing a signal "emit" to be queued

Mohammed Sameer msameer at foolab.org
Tue Mar 22 19:37:27 CET 2011


On Tue, Mar 22, 2011 at 01:04:58PM +0530, Mandeep Sandhu wrote:
> >>
> >> I think it used to do that but got fixed at some point. Not really sure.
> >> But then, why do you care much ?
> 
> I do because timer creation deletion is not a trivial op, I think.
> Though this point is moot if it isn't involved for 0 sec intervals :)

I don't think it's that expensive but I really have no idea.


> >
> > Just checked the code and QTimer::singleShot() uses QMetaObject::invokeMethod()
> > with a Qt::QueuedConnection if msec is 0
> 
> Ummm...where is this interval check? I'm using Qt 4.6.2 on a unix
> platform and the trace goes like this:
> 
> QTimer::singleShot() > QObject::startTimer() >
> QAbstractEventDispatcher::registerTimer() >
> QEventDispatcherUNIX::registerTimer() >
> QEventDispatcherUNIX::registerTimer() >
> QTimerInfoList::registerTimer() > ...after this I'm kinda lost! :)
> 
> The case you point out, is happening for the win32 platform I think
> (in my 4.6.2 src).
> 
> <snip>
> if (!t->interval)  // optimization for single-shot-zero-timer
>             QCoreApplication::postEvent(q, new QZeroTimerEvent(t->timerId));
> </snip>

Qt 4.7.1 uses QMetaObject::invokeMethod() under Linux too.

Cheers,

-- 
GPG-Key: 0xA3FD0DF7 - 9F73 032E EAC9 F7AD 951F  280E CB66 8E29 A3FD 0DF7
Debian User and Developer.
Homepage: www.foolab.org



More information about the Qt-interest-old mailing list