| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/qtquick2.cpp |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||||||||
| 2 | ** | - | ||||||||||||
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. | - | ||||||||||||
| 4 | ** Contact: https://www.qt.io/licensing/ | - | ||||||||||||
| 5 | ** | - | ||||||||||||
| 6 | ** This file is part of the QtQuick module of the Qt Toolkit. | - | ||||||||||||
| 7 | ** | - | ||||||||||||
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | - | ||||||||||||
| 9 | ** Commercial License Usage | - | ||||||||||||
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||
| 11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further | - | ||||||||||||
| 15 | ** information use the contact form at https://www.qt.io/contact-us. | - | ||||||||||||
| 16 | ** | - | ||||||||||||
| 17 | ** GNU Lesser General Public License Usage | - | ||||||||||||
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||
| 19 | ** General Public License version 3 as published by the Free Software | - | ||||||||||||
| 20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||||||||
| 21 | ** packaging of this file. Please review the following information to | - | ||||||||||||
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||||||||
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||||||||
| 24 | ** | - | ||||||||||||
| 25 | ** GNU General Public License Usage | - | ||||||||||||
| 26 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||||||||
| 27 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||||||||
| 28 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||||||||
| 29 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||||||||
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||||||||
| 31 | ** included in the packaging of this file. Please review the following | - | ||||||||||||
| 32 | ** information to ensure the GNU General Public License requirements will | - | ||||||||||||
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||||||||
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||||||||
| 35 | ** | - | ||||||||||||
| 36 | ** $QT_END_LICENSE$ | - | ||||||||||||
| 37 | ** | - | ||||||||||||
| 38 | ****************************************************************************/ | - | ||||||||||||
| 39 | - | |||||||||||||
| 40 | #include "qtquick2_p.h" | - | ||||||||||||
| 41 | #include <private/qqmlengine_p.h> | - | ||||||||||||
| 42 | #include <private/qquickutilmodule_p.h> | - | ||||||||||||
| 43 | #include <private/qquickvaluetypes_p.h> | - | ||||||||||||
| 44 | #include <private/qquickitemsmodule_p.h> | - | ||||||||||||
| 45 | #include <private/qquickaccessiblefactory_p.h> | - | ||||||||||||
| 46 | - | |||||||||||||
| 47 | #include <private/qqmldebugconnector_p.h> | - | ||||||||||||
| 48 | #include <private/qqmldebugserviceinterfaces_p.h> | - | ||||||||||||
| 49 | #include <private/qqmldebugstatesdelegate_p.h> | - | ||||||||||||
| 50 | #include <private/qqmlbinding_p.h> | - | ||||||||||||
| 51 | #include <private/qqmlcontext_p.h> | - | ||||||||||||
| 52 | #include <private/qquickapplication_p.h> | - | ||||||||||||
| 53 | #include <QtQuick/private/qquickpropertychanges_p.h> | - | ||||||||||||
| 54 | #include <QtQuick/private/qquickstate_p.h> | - | ||||||||||||
| 55 | #include <qqmlproperty.h> | - | ||||||||||||
| 56 | #include <QtCore/QPointer> | - | ||||||||||||
| 57 | - | |||||||||||||
| 58 | static void initResources() | - | ||||||||||||
| 59 | { | - | ||||||||||||
| 60 | Q_INIT_RESOURCE(scenegraph); | - | ||||||||||||
| 61 | } executed 374 times by 132 tests: end of blockExecuted by:
| 374 | ||||||||||||
| 62 | - | |||||||||||||
| 63 | QT_BEGIN_NAMESPACE | - | ||||||||||||
| 64 | - | |||||||||||||
| 65 | #if !QT_CONFIG(qml_debug) | - | ||||||||||||
| 66 | - | |||||||||||||
| 67 | class QQmlQtQuick2DebugStatesDelegate : public QQmlDebugStatesDelegate {}; | - | ||||||||||||
| 68 | - | |||||||||||||
| 69 | #else | - | ||||||||||||
| 70 | - | |||||||||||||
| 71 | class QQmlQtQuick2DebugStatesDelegate : public QQmlDebugStatesDelegate | - | ||||||||||||
| 72 | { | - | ||||||||||||
| 73 | public: | - | ||||||||||||
| 74 | QQmlQtQuick2DebugStatesDelegate(); | - | ||||||||||||
| 75 | ~QQmlQtQuick2DebugStatesDelegate(); | - | ||||||||||||
| 76 | void buildStatesList(bool cleanList, const QList<QPointer<QObject> > &instances) override; | - | ||||||||||||
| 77 | void updateBinding(QQmlContext *context, | - | ||||||||||||
| 78 | const QQmlProperty &property, | - | ||||||||||||
| 79 | const QVariant &expression, bool isLiteralValue, | - | ||||||||||||
| 80 | const QString &fileName, int line, int column, | - | ||||||||||||
| 81 | bool *isBaseState) override; | - | ||||||||||||
| 82 | bool setBindingForInvalidProperty(QObject *object, | - | ||||||||||||
| 83 | const QString &propertyName, | - | ||||||||||||
| 84 | const QVariant &expression, | - | ||||||||||||
| 85 | bool isLiteralValue) override; | - | ||||||||||||
| 86 | void resetBindingForInvalidProperty(QObject *object, | - | ||||||||||||
| 87 | const QString &propertyName) override; | - | ||||||||||||
| 88 | - | |||||||||||||
| 89 | private: | - | ||||||||||||
| 90 | void buildStatesList(QObject *obj); | - | ||||||||||||
| 91 | - | |||||||||||||
| 92 | QList<QPointer<QQuickState> > m_allStates; | - | ||||||||||||
| 93 | }; | - | ||||||||||||
| 94 | - | |||||||||||||
| 95 | QQmlQtQuick2DebugStatesDelegate::QQmlQtQuick2DebugStatesDelegate() | - | ||||||||||||
| 96 | { | - | ||||||||||||
| 97 | } | - | ||||||||||||
| 98 | - | |||||||||||||
| 99 | QQmlQtQuick2DebugStatesDelegate::~QQmlQtQuick2DebugStatesDelegate() | - | ||||||||||||
| 100 | { | - | ||||||||||||
| 101 | } | - | ||||||||||||
| 102 | - | |||||||||||||
| 103 | void QQmlQtQuick2DebugStatesDelegate::buildStatesList(bool cleanList, | - | ||||||||||||
| 104 | const QList<QPointer<QObject> > &instances) | - | ||||||||||||
| 105 | { | - | ||||||||||||
| 106 | if (cleanList)
| 0-102 | ||||||||||||
| 107 | m_allStates.clear(); executed 102 times by 1 test: m_allStates.clear();Executed by:
| 102 | ||||||||||||
| 108 | - | |||||||||||||
| 109 | //only root context has all instances | - | ||||||||||||
| 110 | for (int ii = 0; ii < instances.count(); ++ii) {
| 102-622 | ||||||||||||
| 111 | buildStatesList(instances.at(ii)); | - | ||||||||||||
| 112 | } executed 622 times by 1 test: end of blockExecuted by:
| 622 | ||||||||||||
| 113 | } executed 102 times by 1 test: end of blockExecuted by:
| 102 | ||||||||||||
| 114 | - | |||||||||||||
| 115 | void QQmlQtQuick2DebugStatesDelegate::buildStatesList(QObject *obj) | - | ||||||||||||
| 116 | { | - | ||||||||||||
| 117 | if (QQuickState *state = qobject_cast<QQuickState *>(obj)) {
| 102-1440 | ||||||||||||
| 118 | m_allStates.append(state); | - | ||||||||||||
| 119 | } executed 102 times by 1 test: end of blockExecuted by:
| 102 | ||||||||||||
| 120 | - | |||||||||||||
| 121 | QObjectList children = obj->children(); | - | ||||||||||||
| 122 | for (int ii = 0; ii < children.count(); ++ii) {
| 920-1542 | ||||||||||||
| 123 | buildStatesList(children.at(ii)); | - | ||||||||||||
| 124 | } executed 920 times by 1 test: end of blockExecuted by:
| 920 | ||||||||||||
| 125 | } executed 1542 times by 1 test: end of blockExecuted by:
| 1542 | ||||||||||||
| 126 | - | |||||||||||||
| 127 | void QQmlQtQuick2DebugStatesDelegate::updateBinding(QQmlContext *context, | - | ||||||||||||
| 128 | const QQmlProperty &property, | - | ||||||||||||
| 129 | const QVariant &expression, bool isLiteralValue, | - | ||||||||||||
| 130 | const QString &fileName, int line, int column, | - | ||||||||||||
| 131 | bool *inBaseState) | - | ||||||||||||
| 132 | { | - | ||||||||||||
| 133 | Q_UNUSED(column); | - | ||||||||||||
| 134 | typedef QPointer<QQuickState> QuickStatePointer; | - | ||||||||||||
| 135 | QObject *object = property.object(); | - | ||||||||||||
| 136 | QString propertyName = property.name(); | - | ||||||||||||
| 137 | for (const QuickStatePointer& statePointer : qAsConst(m_allStates)) { | - | ||||||||||||
| 138 | if (QQuickState *state = statePointer.data()) {
| 0-12 | ||||||||||||
| 139 | // here we assume that the revert list on itself defines the base state | - | ||||||||||||
| 140 | if (state->isStateActive() && state->containsPropertyInRevertList(object, propertyName)) {
| 2-8 | ||||||||||||
| 141 | *inBaseState = false; | - | ||||||||||||
| 142 | - | |||||||||||||
| 143 | QQmlBinding *newBinding = nullptr; | - | ||||||||||||
| 144 | if (!isLiteralValue) {
| 0-2 | ||||||||||||
| 145 | newBinding = QQmlBinding::create(&QQmlPropertyPrivate::get(property)->core, | - | ||||||||||||
| 146 | expression.toString(), object, | - | ||||||||||||
| 147 | QQmlContextData::get(context), fileName, | - | ||||||||||||
| 148 | line); | - | ||||||||||||
| 149 | newBinding->setTarget(property); | - | ||||||||||||
| 150 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||
| 151 | - | |||||||||||||
| 152 | state->changeBindingInRevertList(object, propertyName, newBinding); | - | ||||||||||||
| 153 | - | |||||||||||||
| 154 | if (isLiteralValue)
| 0-2 | ||||||||||||
| 155 | state->changeValueInRevertList(object, propertyName, expression); never executed: state->changeValueInRevertList(object, propertyName, expression); | 0 | ||||||||||||
| 156 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||
| 157 | } executed 12 times by 1 test: end of blockExecuted by:
| 12 | ||||||||||||
| 158 | } executed 12 times by 1 test: end of blockExecuted by:
| 12 | ||||||||||||
| 159 | } executed 12 times by 1 test: end of blockExecuted by:
| 12 | ||||||||||||
| 160 | - | |||||||||||||
| 161 | bool QQmlQtQuick2DebugStatesDelegate::setBindingForInvalidProperty(QObject *object, | - | ||||||||||||
| 162 | const QString &propertyName, | - | ||||||||||||
| 163 | const QVariant &expression, | - | ||||||||||||
| 164 | bool isLiteralValue) | - | ||||||||||||
| 165 | { | - | ||||||||||||
| 166 | if (QQuickPropertyChanges *propertyChanges = qobject_cast<QQuickPropertyChanges *>(object)) {
| 0-4 | ||||||||||||
| 167 | if (isLiteralValue)
| 0-4 | ||||||||||||
| 168 | propertyChanges->changeValue(propertyName, expression); executed 4 times by 1 test: propertyChanges->changeValue(propertyName, expression);Executed by:
| 4 | ||||||||||||
| 169 | else | - | ||||||||||||
| 170 | propertyChanges->changeExpression(propertyName, expression.toString()); never executed: propertyChanges->changeExpression(propertyName, expression.toString()); | 0 | ||||||||||||
| 171 | return true; executed 4 times by 1 test: return true;Executed by:
| 4 | ||||||||||||
| 172 | } else { | - | ||||||||||||
| 173 | return false; never executed: return false; | 0 | ||||||||||||
| 174 | } | - | ||||||||||||
| 175 | } | - | ||||||||||||
| 176 | - | |||||||||||||
| 177 | void QQmlQtQuick2DebugStatesDelegate::resetBindingForInvalidProperty(QObject *object, const QString &propertyName) | - | ||||||||||||
| 178 | { | - | ||||||||||||
| 179 | if (QQuickPropertyChanges *propertyChanges = qobject_cast<QQuickPropertyChanges *>(object)) {
| 2 | ||||||||||||
| 180 | propertyChanges->removeProperty(propertyName); | - | ||||||||||||
| 181 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||
| 182 | } executed 4 times by 1 test: end of blockExecuted by:
| 4 | ||||||||||||
| 183 | - | |||||||||||||
| 184 | #endif // QT_CONFIG(qml_debug) | - | ||||||||||||
| 185 | - | |||||||||||||
| 186 | void QQmlQtQuick2Module::defineModule() | - | ||||||||||||
| 187 | { | - | ||||||||||||
| 188 | initResources(); | - | ||||||||||||
| 189 | - | |||||||||||||
| 190 | QQuick_initializeProviders(); | - | ||||||||||||
| 191 | - | |||||||||||||
| 192 | QQuickUtilModule::defineModule(); | - | ||||||||||||
| 193 | QQmlEnginePrivate::defineQtQuick2Module(); | - | ||||||||||||
| 194 | QQuickItemsModule::defineModule(); | - | ||||||||||||
| 195 | - | |||||||||||||
| 196 | qmlRegisterUncreatableType<QQuickApplication>("QtQuick",2,0,"Application", QQuickApplication::tr("Application is an abstract class")); | - | ||||||||||||
| 197 | - | |||||||||||||
| 198 | QQuickValueTypes::registerValueTypes(); | - | ||||||||||||
| 199 | - | |||||||||||||
| 200 | #if QT_CONFIG(accessibility) | - | ||||||||||||
| 201 | QAccessible::installFactory(&qQuickAccessibleFactory); | - | ||||||||||||
| 202 | #endif | - | ||||||||||||
| 203 | - | |||||||||||||
| 204 | QQmlEngineDebugService *debugService = QQmlDebugConnector::service<QQmlEngineDebugService>(); | - | ||||||||||||
| 205 | if (debugService)
| 18-356 | ||||||||||||
| 206 | debugService->setStatesDelegate(new QQmlQtQuick2DebugStatesDelegate); executed 18 times by 2 tests: debugService->setStatesDelegate(new QQmlQtQuick2DebugStatesDelegate);Executed by:
| 18 | ||||||||||||
| 207 | } executed 374 times by 132 tests: end of blockExecuted by:
| 374 | ||||||||||||
| 208 | - | |||||||||||||
| 209 | void QQmlQtQuick2Module::undefineModule() | - | ||||||||||||
| 210 | { | - | ||||||||||||
| 211 | QQuick_deinitializeProviders(); | - | ||||||||||||
| 212 | } executed 88 times by 3 tests: end of blockExecuted by:
| 88 | ||||||||||||
| 213 | - | |||||||||||||
| 214 | QT_END_NAMESPACE | - | ||||||||||||
| 215 | - | |||||||||||||
| Source code | Switch to Preprocessed file |