diff options
author | Ulf Hermann <ulf.hermann@digia.com> | 2014-02-06 14:43:26 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-02-10 14:28:17 +0100 |
commit | 4cc230ade4df3919fbb9688b60e6e8f7f3cc8144 (patch) | |
tree | a6240d82988ec658d18be30e2ebf19bed2fc272d /src/qml/debugger/qqmlconfigurabledebugservice.cpp | |
parent | 77686f3b94dfd572778eb8dfa77717114e3abb93 (diff) |
Unify initial waiting of debug services
The debug services generally behave in one of two ways when initializing:
Either they block the initializing thread until some configuration is
passed over the network or they just go on. By introducing a generalized
configurable debug service the various ways of waiting on initialization
are cleaned up. The API defined for it also allows for engine-specific
initialization.
Change-Id: Id5685ef17d2a7eb1222629f7caa5ec53076d47b2
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
Diffstat (limited to 'src/qml/debugger/qqmlconfigurabledebugservice.cpp')
-rw-r--r-- | src/qml/debugger/qqmlconfigurabledebugservice.cpp | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/src/qml/debugger/qqmlconfigurabledebugservice.cpp b/src/qml/debugger/qqmlconfigurabledebugservice.cpp new file mode 100644 index 0000000000..076e12b613 --- /dev/null +++ b/src/qml/debugger/qqmlconfigurabledebugservice.cpp @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlconfigurabledebugservice_p.h" +#include "qqmlconfigurabledebugservice_p_p.h" + +QT_BEGIN_NAMESPACE + +QQmlConfigurableDebugService::QQmlConfigurableDebugService(const QString &name, float version, + QObject *parent) : + QQmlDebugService((*new QQmlConfigurableDebugServicePrivate), name, version, parent) { init(); } + +QQmlConfigurableDebugService::QQmlConfigurableDebugService(QQmlDebugServicePrivate &dd, + const QString &name, float version, + QObject *parent) : + QQmlDebugService(dd, name, version, parent) { init(); } + +QMutex *QQmlConfigurableDebugService::configMutex() +{ + Q_D(QQmlConfigurableDebugService); + return &d->configMutex; +} + +void QQmlConfigurableDebugService::init() +{ + Q_D(QQmlConfigurableDebugService); + QMutexLocker lock(&d->configMutex); + // If we're not enabled or not blocking, don't wait for configuration + d->waitingForConfiguration = (registerService() == Enabled && blockingMode()); +} + +void QQmlConfigurableDebugService::stopWaiting() +{ + Q_D(QQmlConfigurableDebugService); + QMutexLocker lock(&d->configMutex); + d->waitingForConfiguration = false; + foreach (QQmlEngine *engine, d->waitingEngines) + emit attachedToEngine(engine); + d->waitingEngines.clear(); +} + +void QQmlConfigurableDebugService::stateChanged(QQmlDebugService::State newState) +{ + if (newState != Enabled) + stopWaiting(); +} + +void QQmlConfigurableDebugService::engineAboutToBeAdded(QQmlEngine *engine) +{ + Q_D(QQmlConfigurableDebugService); + QMutexLocker lock(&d->configMutex); + if (d->waitingForConfiguration) + d->waitingEngines.append(engine); + else + emit attachedToEngine(engine); +} + +QT_END_NAMESPACE |