| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/qml/qqmlapplicationengine.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||
| 2 | - | |||||||||||||
| 3 | - | |||||||||||||
| 4 | QQmlApplicationEnginePrivate::QQmlApplicationEnginePrivate(QQmlEngine *e) | - | ||||||||||||
| 5 | : QQmlEnginePrivate(e) | - | ||||||||||||
| 6 | { | - | ||||||||||||
| 7 | } executed 148 times by 7 tests: end of blockExecuted by:
| 148 | ||||||||||||
| 8 | - | |||||||||||||
| 9 | QQmlApplicationEnginePrivate::~QQmlApplicationEnginePrivate() | - | ||||||||||||
| 10 | { | - | ||||||||||||
| 11 | } | - | ||||||||||||
| 12 | - | |||||||||||||
| 13 | void QQmlApplicationEnginePrivate::cleanUp() | - | ||||||||||||
| 14 | { | - | ||||||||||||
| 15 | QQmlApplicationEngine * const q = q_func(); | - | ||||||||||||
| 16 | for (auto obj : qAsConst(objects)) | - | ||||||||||||
| 17 | obj->disconnect(q); executed 178 times by 5 tests: obj->disconnect(q);Executed by:
| 178 | ||||||||||||
| 18 | - | |||||||||||||
| 19 | qDeleteAll(objects); | - | ||||||||||||
| 20 | - | |||||||||||||
| 21 | qDeleteAll(translators); | - | ||||||||||||
| 22 | - | |||||||||||||
| 23 | } executed 148 times by 7 tests: end of blockExecuted by:
| 148 | ||||||||||||
| 24 | - | |||||||||||||
| 25 | void QQmlApplicationEnginePrivate::init() | - | ||||||||||||
| 26 | { | - | ||||||||||||
| 27 | QQmlApplicationEngine * const q = q_func(); | - | ||||||||||||
| 28 | q->connect(q, qFlagLocation("2""quit()" "\0" __FILE__ ":" "73"), QCoreApplication::instance(), qFlagLocation("1""quit()" "\0" __FILE__ ":" "73")); | - | ||||||||||||
| 29 | q->connect(q, &QQmlApplicationEngine::exit, QCoreApplication::instance(), &QCoreApplication::exit); | - | ||||||||||||
| 30 | - | |||||||||||||
| 31 | QTranslator* qtTranslator = new QTranslator; | - | ||||||||||||
| 32 | if (qtTranslator->load(QLatin1String("qt_") + QLocale::system().name(), QLibraryInfo::location(QLibraryInfo::TranslationsPath))
| 0-148 | ||||||||||||
| 33 | QCoreApplication::installTranslator(qtTranslator); never executed: QCoreApplication::installTranslator(qtTranslator); | 0 | ||||||||||||
| 34 | translators << qtTranslator; | - | ||||||||||||
| 35 | - | |||||||||||||
| 36 | new QQmlFileSelector(q,q); | - | ||||||||||||
| 37 | QCoreApplication::instance()->setProperty("__qml_using_qqmlapplicationengine", QVariant(true)); | - | ||||||||||||
| 38 | } executed 148 times by 7 tests: end of blockExecuted by:
| 148 | ||||||||||||
| 39 | - | |||||||||||||
| 40 | void QQmlApplicationEnginePrivate::loadTranslations(const QUrl &rootFile) | - | ||||||||||||
| 41 | { | - | ||||||||||||
| 42 | - | |||||||||||||
| 43 | if (rootFile.scheme() != QLatin1String("file")
| 2-162 | ||||||||||||
| 44 | return; executed 16 times by 1 test: return;Executed by:
| 16 | ||||||||||||
| 45 | - | |||||||||||||
| 46 | QFileInfo fi(rootFile.toLocalFile()); | - | ||||||||||||
| 47 | - | |||||||||||||
| 48 | QTranslator *translator = new QTranslator; | - | ||||||||||||
| 49 | if (translator->load(QLatin1String("qml_") + QLocale::system().name(), fi.path() + QLatin1String("/i18n"))
| 0-164 | ||||||||||||
| 50 | QCoreApplication::installTranslator(translator); | - | ||||||||||||
| 51 | translators << translator; | - | ||||||||||||
| 52 | } never executed: else {end of block | 0 | ||||||||||||
| 53 | delete translator; | - | ||||||||||||
| 54 | } executed 164 times by 4 tests: end of blockExecuted by:
| 164 | ||||||||||||
| 55 | - | |||||||||||||
| 56 | - | |||||||||||||
| 57 | - | |||||||||||||
| 58 | } | - | ||||||||||||
| 59 | - | |||||||||||||
| 60 | void QQmlApplicationEnginePrivate::startLoad(const QUrl &url, const QByteArray &data, bool dataFlag) | - | ||||||||||||
| 61 | { | - | ||||||||||||
| 62 | QQmlApplicationEngine * const q = q_func(); | - | ||||||||||||
| 63 | - | |||||||||||||
| 64 | loadTranslations(url); | - | ||||||||||||
| 65 | QQmlComponent *c = new QQmlComponent(q, q); | - | ||||||||||||
| 66 | - | |||||||||||||
| 67 | if (dataFlag
| 20-160 | ||||||||||||
| 68 | c->setData(data,url); executed 20 times by 3 tests: c->setData(data,url);Executed by:
| 20 | ||||||||||||
| 69 | else | - | ||||||||||||
| 70 | c->loadUrl(url); executed 160 times by 4 tests: c->loadUrl(url);Executed by:
| 160 | ||||||||||||
| 71 | - | |||||||||||||
| 72 | if (!c->isLoading()
| 0-180 | ||||||||||||
| 73 | finishLoad(c); | - | ||||||||||||
| 74 | return; executed 180 times by 5 tests: return;Executed by:
| 180 | ||||||||||||
| 75 | } | - | ||||||||||||
| 76 | QObject::connect(c, &QQmlComponent::statusChanged, q, [this, c] { this->finishLoad(c); } never executed: );end of block | 0 | ||||||||||||
| 77 | } never executed: end of block | 0 | ||||||||||||
| 78 | - | |||||||||||||
| 79 | void QQmlApplicationEnginePrivate::finishLoad(QQmlComponent *c) | - | ||||||||||||
| 80 | { | - | ||||||||||||
| 81 | QQmlApplicationEngine * const q = q_func(); | - | ||||||||||||
| 82 | switch (c->status()) { | - | ||||||||||||
| 83 | case never executed: QQmlComponent::Error:case QQmlComponent::Error:never executed: case QQmlComponent::Error: | 0 | ||||||||||||
| 84 | QMessageLogger(__FILE__, 129, __PRETTY_FUNCTION__).warning() << "QQmlApplicationEngine failed to load component"; | - | ||||||||||||
| 85 | QMessageLogger(__FILE__, 130, __PRETTY_FUNCTION__).warning() << QtPrivate::asString(c->errorString()).toLocal8Bit().constData(); | - | ||||||||||||
| 86 | q->objectCreated(nullptr, c->url()); | - | ||||||||||||
| 87 | break; never executed: break; | 0 | ||||||||||||
| 88 | case executed 180 times by 5 tests: QQmlComponent::Ready:case QQmlComponent::Ready:Executed by:
executed 180 times by 5 tests: {case QQmlComponent::Ready:Executed by:
| 180 | ||||||||||||
| 89 | auto newObj = c->create(); | - | ||||||||||||
| 90 | objects << newObj; | - | ||||||||||||
| 91 | QObject::connect(newObj, &QObject::destroyed, q, [&](QObject *obj) { objects.removeAll(obj); } executed 2 times by 1 test: );end of blockExecuted by:
| 2 | ||||||||||||
| 92 | q->objectCreated(objects.constLast(), c->url()); | - | ||||||||||||
| 93 | } | - | ||||||||||||
| 94 | break; executed 180 times by 5 tests: break;Executed by:
| 180 | ||||||||||||
| 95 | case never executed: QQmlComponent::Loading:case QQmlComponent::Loading:never executed: case QQmlComponent::Loading: | 0 | ||||||||||||
| 96 | case never executed: QQmlComponent::Null:case QQmlComponent::Null:never executed: case QQmlComponent::Null: | 0 | ||||||||||||
| 97 | return; never executed: return; | 0 | ||||||||||||
| 98 | } | - | ||||||||||||
| 99 | - | |||||||||||||
| 100 | c->deleteLater(); | - | ||||||||||||
| 101 | } executed 180 times by 5 tests: end of blockExecuted by:
| 180 | ||||||||||||
| 102 | QQmlApplicationEngine::QQmlApplicationEngine(QObject *parent) | - | ||||||||||||
| 103 | : QQmlEngine(*(new QQmlApplicationEnginePrivate(this)), parent) | - | ||||||||||||
| 104 | { | - | ||||||||||||
| 105 | QQmlApplicationEnginePrivate * const d = d_func(); | - | ||||||||||||
| 106 | d->init(); | - | ||||||||||||
| 107 | QJSEnginePrivate::addToDebugServer(this); | - | ||||||||||||
| 108 | } executed 148 times by 7 tests: end of blockExecuted by:
| 148 | ||||||||||||
| 109 | - | |||||||||||||
| 110 | - | |||||||||||||
| 111 | - | |||||||||||||
| 112 | - | |||||||||||||
| 113 | - | |||||||||||||
| 114 | QQmlApplicationEngine::QQmlApplicationEngine(const QUrl &url, QObject *parent) | - | ||||||||||||
| 115 | : QQmlApplicationEngine(parent) | - | ||||||||||||
| 116 | { | - | ||||||||||||
| 117 | load(url); | - | ||||||||||||
| 118 | } executed 14 times by 3 tests: end of blockExecuted by:
| 14 | ||||||||||||
| 119 | QQmlApplicationEngine::QQmlApplicationEngine(const QString &filePath, QObject *parent) | - | ||||||||||||
| 120 | : QQmlApplicationEngine(QUrl::fromUserInput(filePath, QLatin1String("."), QUrl::AssumeLocalFile), parent) | - | ||||||||||||
| 121 | { | - | ||||||||||||
| 122 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||
| 123 | - | |||||||||||||
| 124 | - | |||||||||||||
| 125 | - | |||||||||||||
| 126 | - | |||||||||||||
| 127 | QQmlApplicationEngine::~QQmlApplicationEngine() | - | ||||||||||||
| 128 | { | - | ||||||||||||
| 129 | QQmlApplicationEnginePrivate * const d = d_func(); | - | ||||||||||||
| 130 | QJSEnginePrivate::removeFromDebugServer(this); | - | ||||||||||||
| 131 | d->cleanUp(); | - | ||||||||||||
| 132 | } executed 148 times by 7 tests: end of blockExecuted by:
| 148 | ||||||||||||
| 133 | void QQmlApplicationEngine::load(const QUrl &url) | - | ||||||||||||
| 134 | { | - | ||||||||||||
| 135 | QQmlApplicationEnginePrivate * const d = d_func(); | - | ||||||||||||
| 136 | d->startLoad(url); | - | ||||||||||||
| 137 | } executed 158 times by 4 tests: end of blockExecuted by:
| 158 | ||||||||||||
| 138 | void QQmlApplicationEngine::load(const QString &filePath) | - | ||||||||||||
| 139 | { | - | ||||||||||||
| 140 | QQmlApplicationEnginePrivate * const d = d_func(); | - | ||||||||||||
| 141 | d->startLoad(QUrl::fromUserInput(filePath, QLatin1String("."), QUrl::AssumeLocalFile)); | - | ||||||||||||
| 142 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||
| 143 | void QQmlApplicationEngine::loadData(const QByteArray &data, const QUrl &url) | - | ||||||||||||
| 144 | { | - | ||||||||||||
| 145 | QQmlApplicationEnginePrivate * const d = d_func(); | - | ||||||||||||
| 146 | d->startLoad(url, data, true); | - | ||||||||||||
| 147 | } executed 20 times by 3 tests: end of blockExecuted by:
| 20 | ||||||||||||
| 148 | QList<QObject *> QQmlApplicationEngine::rootObjects() const | - | ||||||||||||
| 149 | { | - | ||||||||||||
| 150 | const QQmlApplicationEnginePrivate * const d = d_func(); | - | ||||||||||||
| 151 | return executed 232 times by 4 tests: d->objects;return d->objects;Executed by:
executed 232 times by 4 tests: return d->objects;Executed by:
| 232 | ||||||||||||
| 152 | } | - | ||||||||||||
| 153 | - | |||||||||||||
| 154 | - | |||||||||||||
| 155 | - | |||||||||||||
| 156 | - | |||||||||||||
| 157 | - | |||||||||||||
| 158 | - | |||||||||||||
| 159 | QList<QObject *> QQmlApplicationEngine::rootObjects() | - | ||||||||||||
| 160 | { | - | ||||||||||||
| 161 | return executed 232 times by 4 tests: qAsConst(*this).rootObjects();return qAsConst(*this).rootObjects();Executed by:
executed 232 times by 4 tests: return qAsConst(*this).rootObjects();Executed by:
| 232 | ||||||||||||
| 162 | } | - | ||||||||||||
| 163 | - | |||||||||||||
| 164 | - | |||||||||||||
| 165 | - | |||||||||||||
| 166 | - | |||||||||||||
| Switch to Source code | Preprocessed file |