aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/debugger/qqmldebugserver.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@theqtcompany.com>2015-07-13 16:38:25 +0200
committerUlf Hermann <ulf.hermann@theqtcompany.com>2015-07-30 14:55:19 +0000
commit6557b7118897347ccf7c5915c169cf86c818be83 (patch)
treee7e67d77b5255222edbd620bd6ae77ec50052ee4 /src/qml/debugger/qqmldebugserver.cpp
parent52e782bdc56fb3a62b045f2d1ca71f38bc7ef796 (diff)
Make QQmlDebugService::registerService() private and part of ctor
By forcing all debug services to register before the thread starts we can get rid of the complicated thread synchronization and have a more natural API for the services. We can also better enforce the thread situation when registering services in QQmlDebugServer now. QQmlProfilerService should not moveToThread() in its constructor as the thread has not been started, yet. The thread affinity of QQmlProfilerService doesn't make any difference anyway, as all relevant methods are protected by mutexes and it doesn't have any slots. Change-Id: I57db9e2bf94ec6884ede694715dadf5bfd687334 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'src/qml/debugger/qqmldebugserver.cpp')
-rw-r--r--src/qml/debugger/qqmldebugserver.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/qml/debugger/qqmldebugserver.cpp b/src/qml/debugger/qqmldebugserver.cpp
index 4974bce8d8..da2eac79ed 100644
--- a/src/qml/debugger/qqmldebugserver.cpp
+++ b/src/qml/debugger/qqmldebugserver.cpp
@@ -701,6 +701,9 @@ QQmlDebugService *QQmlDebugServerImpl::service(const QString &name) const
void QQmlDebugServerImpl::addEngine(QQmlEngine *engine)
{
+ // to be executed outside of debugger thread
+ Q_ASSERT(QThread::currentThread() != m_thread);
+
QWriteLocker lock(&m_pluginsLock);
foreach (QQmlDebugService *service, m_plugins)
@@ -714,6 +717,9 @@ void QQmlDebugServerImpl::addEngine(QQmlEngine *engine)
void QQmlDebugServerImpl::removeEngine(QQmlEngine *engine)
{
+ // to be executed outside of debugger thread
+ Q_ASSERT(QThread::currentThread() != m_thread);
+
QWriteLocker lock(&m_pluginsLock);
foreach (QQmlDebugService *service, m_plugins)
@@ -727,8 +733,8 @@ void QQmlDebugServerImpl::removeEngine(QQmlEngine *engine)
bool QQmlDebugServerImpl::addService(QQmlDebugService *service)
{
- // to be executed outside of debugger thread
- Q_ASSERT(!m_thread || QThread::currentThread() != thread());
+ // to be executed before thread starts
+ Q_ASSERT(!m_thread);
connect(service, SIGNAL(attachedToEngine(QQmlEngine*)),
this, SLOT(wakeEngine(QQmlEngine*)), Qt::QueuedConnection);
@@ -750,8 +756,8 @@ bool QQmlDebugServerImpl::addService(QQmlDebugService *service)
bool QQmlDebugServerImpl::removeService(QQmlDebugService *service)
{
- // to be executed outside of debugger thread
- Q_ASSERT(!m_thread || QThread::currentThread() != thread());
+ // to be executed after thread ends
+ Q_ASSERT(!m_thread);
QWriteLocker lock(&m_pluginsLock);
QQmlDebugService::State newState = QQmlDebugService::NotConnected;
@@ -816,9 +822,6 @@ void QQmlDebugServerImpl::wakeEngine(QQmlEngine *engine)
bool QQmlDebugServerImpl::EngineCondition::waitForServices(QReadWriteLock *locked, int num)
{
- // to be executed outside of debugger thread
- Q_ASSERT(QThread::currentThread() != QQmlDebugServer::instance()->thread());
-
Q_ASSERT_X(numServices == 0, Q_FUNC_INFO, "Request to wait again before previous wait finished");
numServices = num;
return numServices > 0 ? condition->wait(locked) : true;