aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/util/qquickprofiler.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@digia.com>2014-02-21 17:37:40 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-02-25 11:05:22 +0100
commita22d5fdad7987534ddc825728e23ec5177de64d7 (patch)
tree1c4810355161099a3ec76f44ece906588e63737b /src/quick/util/qquickprofiler.cpp
parent481e5257c9de4c76a8255eb033d5782aae9812e0 (diff)
Register the QML profiler's animation callback from the GUI thread
QUnifiedTimer is thread-local, so that a different object is returned from instance() for each thread. This patch makes sure we register to the one that performs the animations. Task-number: QTCREATORBUG-11536 Change-Id: I23c3ff49f94668517b9894298a4d770a8c30e705 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com> Reviewed-by: Kai Koehne <kai.koehne@digia.com>
Diffstat (limited to 'src/quick/util/qquickprofiler.cpp')
-rw-r--r--src/quick/util/qquickprofiler.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/quick/util/qquickprofiler.cpp b/src/quick/util/qquickprofiler.cpp
index a706fb1e77..0bd22d1d25 100644
--- a/src/quick/util/qquickprofiler.cpp
+++ b/src/quick/util/qquickprofiler.cpp
@@ -40,6 +40,7 @@
****************************************************************************/
#include "qquickprofiler_p.h"
+#include <QCoreApplication>
#include <private/qqmldebugservice_p.h>
#include <private/qqmlprofilerservice_p.h>
@@ -139,6 +140,18 @@ void animationTimerCallback(qint64 delta)
Q_QUICK_PROFILE(animationFrame(delta));
}
+class CallbackRegistrationHelper : public QObject {
+ Q_OBJECT
+public slots:
+ void registerAnimationTimerCallback()
+ {
+ QUnifiedTimer::instance()->registerProfilerCallback(&animationTimerCallback);
+ delete this;
+ }
+};
+
+#include "qquickprofiler.moc"
+
QQuickProfiler::QQuickProfiler(QQmlProfilerService *service) :
QQmlAbstractProfilerAdapter(service), next(0)
{
@@ -159,7 +172,9 @@ QQuickProfiler::QQuickProfiler(QQmlProfilerService *service) :
connect(this, SIGNAL(dataRequested()), this, SLOT(reportDataImpl()),
Qt::DirectConnection);
- QUnifiedTimer::instance()->registerProfilerCallback(&animationTimerCallback);
+ CallbackRegistrationHelper *helper = new CallbackRegistrationHelper; // will delete itself
+ helper->moveToThread(QCoreApplication::instance()->thread());
+ QMetaObject::invokeMethod(helper, "registerAnimationTimerCallback", Qt::QueuedConnection);
}
QQuickProfiler::~QQuickProfiler()