queued-connection

Invoke slot asynchronously without connecting to it using clear line of code

扶醉桌前 提交于 2019-12-02 08:41:17
问题 I have encountered quite freaky bug - QAction::trigger caused blocking dialog to appear, which caused my server which called trigger to go stuck (eg. not able to process socket signals until dialog was closed). I figured out a workaround. I connect signal void triggerWorkaround() to slot QAction::trigger using Qt::QueuedConnection and I emit it: QObject::connect(this, &HackClass::triggerWorkaround, targetAction_.data(), &QAction::trigger, Qt::QueuedConnection); emit triggerWorkaround();

Invoke slot asynchronously without connecting to it using clear line of code

人盡茶涼 提交于 2019-12-02 04:41:31
I have encountered quite freaky bug - QAction::trigger caused blocking dialog to appear, which caused my server which called trigger to go stuck (eg. not able to process socket signals until dialog was closed). I figured out a workaround. I connect signal void triggerWorkaround() to slot QAction::trigger using Qt::QueuedConnection and I emit it: QObject::connect(this, &HackClass::triggerWorkaround, targetAction_.data(), &QAction::trigger, Qt::QueuedConnection); emit triggerWorkaround(); QObject::disconnect(this, nullptr, targetAction_.data(), nullptr); But that's three lines of confusing code.