OpenCoverage

qqmldebugservice.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/debugger/qqmldebugservice.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
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 QtQml 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 "qqmldebugservice_p.h"-
41#include "qqmldebugconnector_p.h"-
42#include <private/qqmldata_p.h>-
43#include <private/qqmlcontext_p.h>-
44-
45#include <QtCore/QDebug>-
46#include <QtCore/QStringList>-
47#include <QtCore/QFileInfo>-
48-
49QT_BEGIN_NAMESPACE-
50-
51class QQmlDebugServer;-
52-
53class QQmlDebugServicePrivate : public QObjectPrivate-
54{-
55 Q_DECLARE_PUBLIC(QQmlDebugService)-
56public:-
57 QQmlDebugServicePrivate(const QString &name, float version);-
58-
59 const QString name;-
60 const float version;-
61 QQmlDebugService::State state;-
62};-
63-
64QQmlDebugServicePrivate::QQmlDebugServicePrivate(const QString &name, float version) :-
65 name(name), version(version), state(QQmlDebugService::NotConnected)-
66{-
67}
executed 158 times by 7 tests: end of block
Executed by:
  • tst_qqmldebugclient
  • tst_qqmldebugjs
  • tst_qqmldebuglocal
  • tst_qqmldebugservice
  • tst_qqmlenginedebugservice
  • tst_qqmlnativeconnector
  • tst_qqmlprofilerservice
158
68-
69QQmlDebugService::QQmlDebugService(const QString &name, float version, QObject *parent)-
70 : QObject(*(new QQmlDebugServicePrivate(name, version)), parent)-
71{-
72 Q_D(QQmlDebugService);-
73 QQmlDebugConnector *server = QQmlDebugConnector::instance();-
74-
75 if (!server)
!serverDescription
TRUEnever evaluated
FALSEevaluated 158 times by 7 tests
Evaluated by:
  • tst_qqmldebugclient
  • tst_qqmldebugjs
  • tst_qqmldebuglocal
  • tst_qqmldebugservice
  • tst_qqmlenginedebugservice
  • tst_qqmlnativeconnector
  • tst_qqmlprofilerservice
0-158
76 return;
never executed: return;
0
77-
78 if (server->service(d->name)) {
server->service(d->name)Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qqmldebugservice
FALSEevaluated 154 times by 7 tests
Evaluated by:
  • tst_qqmldebugclient
  • tst_qqmldebugjs
  • tst_qqmldebuglocal
  • tst_qqmldebugservice
  • tst_qqmlenginedebugservice
  • tst_qqmlnativeconnector
  • tst_qqmlprofilerservice
4-154
79 qWarning() << "QQmlDebugService: Conflicting plugin name" << d->name;-
80 } else {
executed 4 times by 1 test: end of block
Executed by:
  • tst_qqmldebugservice
4
81 server->addService(d->name, this);-
82 }
executed 154 times by 7 tests: end of block
Executed by:
  • tst_qqmldebugclient
  • tst_qqmldebugjs
  • tst_qqmldebuglocal
  • tst_qqmldebugservice
  • tst_qqmlenginedebugservice
  • tst_qqmlnativeconnector
  • tst_qqmlprofilerservice
154
83}-
84-
85QQmlDebugService::~QQmlDebugService()-
86{-
87 Q_D(QQmlDebugService);-
88 QQmlDebugConnector *server = QQmlDebugConnector::instance();-
89-
90 if (!server)
!serverDescription
TRUEnever evaluated
FALSEevaluated 152 times by 6 tests
Evaluated by:
  • tst_qqmldebugjs
  • tst_qqmldebuglocal
  • tst_qqmldebugservice
  • tst_qqmlenginedebugservice
  • tst_qqmlnativeconnector
  • tst_qqmlprofilerservice
0-152
91 return;
never executed: return;
0
92-
93 if (server->service(d->name) != this)
server->servic...>name) != thisDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qqmldebugservice
FALSEevaluated 148 times by 5 tests
Evaluated by:
  • tst_qqmldebugjs
  • tst_qqmldebuglocal
  • tst_qqmlenginedebugservice
  • tst_qqmlnativeconnector
  • tst_qqmlprofilerservice
4-148
94 qWarning() << "QQmlDebugService: Plugin" << d->name << "is not registered.";
executed 4 times by 1 test: QMessageLogger(__FILE__, 94, __PRETTY_FUNCTION__).warning() << "QQmlDebugService: Plugin" << d->name << "is not registered.";
Executed by:
  • tst_qqmldebugservice
4
95 else-
96 server->removeService(d->name);
executed 148 times by 5 tests: server->removeService(d->name);
Executed by:
  • tst_qqmldebugjs
  • tst_qqmldebuglocal
  • tst_qqmlenginedebugservice
  • tst_qqmlnativeconnector
  • tst_qqmlprofilerservice
148
97}-
98-
99const QString &QQmlDebugService::name() const-
100{-
101 Q_D(const QQmlDebugService);-
102 return d->name;
executed 732 times by 7 tests: return d->name;
Executed by:
  • tst_qqmldebugclient
  • tst_qqmldebugjs
  • tst_qqmldebuglocal
  • tst_qqmldebugservice
  • tst_qqmlenginedebugservice
  • tst_qqmlnativeconnector
  • tst_qqmlprofilerservice
732
103}-
104-
105float QQmlDebugService::version() const-
106{-
107 Q_D(const QQmlDebugService);-
108 return d->version;
executed 158 times by 6 tests: return d->version;
Executed by:
  • tst_qqmldebugclient
  • tst_qqmldebugjs
  • tst_qqmldebuglocal
  • tst_qqmldebugservice
  • tst_qqmlenginedebugservice
  • tst_qqmlprofilerservice
158
109}-
110-
111QQmlDebugService::State QQmlDebugService::state() const-
112{-
113 Q_D(const QQmlDebugService);-
114 return d->state;
executed 836 times by 7 tests: return d->state;
Executed by:
  • tst_qqmldebugclient
  • tst_qqmldebugjs
  • tst_qqmldebuglocal
  • tst_qqmldebugservice
  • tst_qqmlenginedebugservice
  • tst_qqmlnativeconnector
  • tst_qqmlprofilerservice
836
115}-
116-
117void QQmlDebugService::setState(QQmlDebugService::State newState)-
118{-
119 Q_D(QQmlDebugService);-
120 d->state = newState;-
121}
executed 688 times by 7 tests: end of block
Executed by:
  • tst_qqmldebugclient
  • tst_qqmldebugjs
  • tst_qqmldebuglocal
  • tst_qqmldebugservice
  • tst_qqmlenginedebugservice
  • tst_qqmlnativeconnector
  • tst_qqmlprofilerservice
688
122-
123namespace {-
124class ObjectReferenceHash : public QObject-
125{-
126 Q_OBJECT-
127public:-
128 ObjectReferenceHash() : nextId(0) {}
executed 28 times by 5 tests: end of block
Executed by:
  • tst_qqmldebugjs
  • tst_qqmldebugservice
  • tst_qqmlenginedebugservice
  • tst_qqmlprofilerservice
  • tst_qv4debugger
28
129-
130 QHash<QObject *, int> objects;-
131 QHash<int, QObject *> ids;-
132-
133 int nextId;-
134-
135 void remove(QObject *obj);-
136};-
137}-
138Q_GLOBAL_STATIC(ObjectReferenceHash, objectReferenceHash)
executed 28 times by 5 tests: end of block
Executed by:
  • tst_qqmldebugjs
  • tst_qqmldebugservice
  • tst_qqmlenginedebugservice
  • tst_qqmlprofilerservice
  • tst_qv4debugger
executed 28 times by 5 tests: guard.store(QtGlobalStatic::Destroyed);
Executed by:
  • tst_qqmldebugjs
  • tst_qqmldebugservice
  • tst_qqmlenginedebugservice
  • tst_qqmlprofilerservice
  • tst_qv4debugger
executed 6804 times by 5 tests: return &holder.value;
Executed by:
  • tst_qqmldebugjs
  • tst_qqmldebugservice
  • tst_qqmlenginedebugservice
  • tst_qqmlprofilerservice
  • tst_qv4debugger
guard.load() =...c::InitializedDescription
TRUEevaluated 28 times by 5 tests
Evaluated by:
  • tst_qqmldebugjs
  • tst_qqmldebugservice
  • tst_qqmlenginedebugservice
  • tst_qqmlprofilerservice
  • tst_qv4debugger
FALSEnever evaluated
0-6804
139-
140void ObjectReferenceHash::remove(QObject *obj)-
141{-
142 QHash<QObject *, int>::Iterator iter = objects.find(obj);-
143 if (iter != objects.end()) {
iter != objects.end()Description
TRUEevaluated 106 times by 5 tests
Evaluated by:
  • tst_qqmldebugjs
  • tst_qqmldebugservice
  • tst_qqmlenginedebugservice
  • tst_qqmlprofilerservice
  • tst_qv4debugger
FALSEnever evaluated
0-106
144 ids.remove(iter.value());-
145 objects.erase(iter);-
146 }
executed 106 times by 5 tests: end of block
Executed by:
  • tst_qqmldebugjs
  • tst_qqmldebugservice
  • tst_qqmlenginedebugservice
  • tst_qqmlprofilerservice
  • tst_qv4debugger
106
147}
executed 106 times by 5 tests: end of block
Executed by:
  • tst_qqmldebugjs
  • tst_qqmldebugservice
  • tst_qqmlenginedebugservice
  • tst_qqmlprofilerservice
  • tst_qv4debugger
106
148-
149/*!-
150 Returns a unique id for \a object. Calling this method multiple times-
151 for the same object will return the same id.-
152*/-
153int QQmlDebugService::idForObject(QObject *object)-
154{-
155 if (!object)
!objectDescription
TRUEevaluated 840 times by 3 tests
Evaluated by:
  • tst_qqmldebugjs
  • tst_qqmldebugservice
  • tst_qqmlenginedebugservice
FALSEevaluated 6436 times by 5 tests
Evaluated by:
  • tst_qqmldebugjs
  • tst_qqmldebugservice
  • tst_qqmlenginedebugservice
  • tst_qqmlprofilerservice
  • tst_qv4debugger
840-6436
156 return -1;
executed 840 times by 3 tests: return -1;
Executed by:
  • tst_qqmldebugjs
  • tst_qqmldebugservice
  • tst_qqmlenginedebugservice
840
157-
158 ObjectReferenceHash *hash = objectReferenceHash();-
159 QHash<QObject *, int>::Iterator iter = hash->objects.find(object);-
160-
161 if (iter == hash->objects.end()) {
iter == hash->objects.end()Description
TRUEevaluated 124 times by 5 tests
Evaluated by:
  • tst_qqmldebugjs
  • tst_qqmldebugservice
  • tst_qqmlenginedebugservice
  • tst_qqmlprofilerservice
  • tst_qv4debugger
FALSEevaluated 6312 times by 4 tests
Evaluated by:
  • tst_qqmldebugjs
  • tst_qqmldebugservice
  • tst_qqmlenginedebugservice
  • tst_qqmlprofilerservice
124-6312
162 int id = hash->nextId++;-
163 hash->ids.insert(id, object);-
164 iter = hash->objects.insert(object, id);-
165 connect(object, &QObject::destroyed, hash, &ObjectReferenceHash::remove);-
166 }
executed 124 times by 5 tests: end of block
Executed by:
  • tst_qqmldebugjs
  • tst_qqmldebugservice
  • tst_qqmlenginedebugservice
  • tst_qqmlprofilerservice
  • tst_qv4debugger
124
167 return iter.value();
executed 6436 times by 5 tests: return iter.value();
Executed by:
  • tst_qqmldebugjs
  • tst_qqmldebugservice
  • tst_qqmlenginedebugservice
  • tst_qqmlprofilerservice
  • tst_qv4debugger
6436
168}-
169-
170/*!-
171 Returns the mapping of objects to unique \a ids, created through calls to idForObject().-
172*/-
173const QHash<int, QObject *> &QQmlDebugService::objectsForIds()-
174{-
175 return objectReferenceHash()->ids;
executed 368 times by 4 tests: return objectReferenceHash()->ids;
Executed by:
  • tst_qqmldebugservice
  • tst_qqmlenginedebugservice
  • tst_qqmlprofilerservice
  • tst_qv4debugger
368
176}-
177-
178QT_END_NAMESPACE-
179-
180#include "qqmldebugservice.moc"-
181#include "moc_qqmldebugservice_p.cpp"-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.0