Timer QML Component event blocks UI?
-
Hi there!
I have Timer component with event onTriggered event connected to a C++ process. The C++ has event loop in it. Somehow, it blocks the UI thread (validated from the busy indicator stops running; please take a look at the code from: http://cl.ly/A1RZ) whenever the timer is triggered. (The process doesn't block the UI when it is connected to a onClicked event of a Button element). I'm on N950 Harmattan device.
The complete code can be downloaded from here: http://cl.ly/A1RZ
Is there a way to not block the UI when I call the C++ process?
To prove that the onClicked doesn't block the UI (whenever it runs the C++ process) you can change the onClicked event from:
@onClicked: loopTimer.start();@
to
@onClicked: dummyLoop.process();@
The C++ process is as follows:
@void DummyProcessWithLocalEventLoop::process()
{
qDebug() << "run local event loop";QEventLoop loop; QTimer timer; timer.setSingleShot(true); connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit())); timer.start(5000); loop.exec(); qDebug() << "local event loop done";
}
@The page asking the process
@import QtQuick 1.1
import com.nokia.meego 1.0
import dummy 1.0Page {
tools: commonToolsid: container DummyLoop{ id: dummyLoop } BusyIndicator{ id: busy anchors.centerIn: parent running: true } Timer{ id: loopTimer interval: 1000 running: false onTriggered: { dummyLoop.process(); } } Button{ anchors { horizontalCenter: parent.horizontalCenter top: busy.bottom topMargin: 10 } text: qsTr("run dummy loop") onClicked: loopTimer.start(); }
}
@