OpenCoverage

qqmlinfo.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/qml/qqmlinfo.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 "qqmlinfo.h"-
41-
42#include "qqmldata_p.h"-
43#include "qqmlcontext.h"-
44#include "qqmlcontext_p.h"-
45#include "qqmlmetatype_p.h"-
46#include "qqmlengine_p.h"-
47-
48#include <QCoreApplication>-
49-
50QT_BEGIN_NAMESPACE-
51-
52/*!-
53 \fn QQmlInfo QtQml::qmlDebug(const QObject *object)-
54 \relates QQmlEngine-
55 \since 5.9-
56-
57 Prints debug messages that include the file and line number for the-
58 specified QML \a object.-
59-
60 When QML types produce logging messages, it improves traceability-
61 if they include the QML file and line number on which the-
62 particular instance was instantiated.-
63-
64 To include the file and line number, an object must be passed. If-
65 the file and line number is not available for that instance-
66 (either it was not instantiated by the QML engine or location-
67 information is disabled), "unknown location" will be used instead.-
68-
69 For example,-
70-
71 \code-
72 qmlDebug(object) << "Internal state: 42";-
73 \endcode-
74-
75 prints-
76-
77 \code-
78 QML MyCustomType (unknown location): Internal state: 42-
79 \endcode-
80-
81 \sa QtQml::qmlInfo, QtQml::qmlWarning-
82*/-
83-
84/*!-
85 \fn QQmlInfo QtQml::qmlInfo(const QObject *object)-
86 \relates QQmlEngine-
87-
88 Prints informational messages that include the file and line number for the-
89 specified QML \a object.-
90-
91 When QML types produce logging messages, it improves traceability-
92 if they include the QML file and line number on which the-
93 particular instance was instantiated.-
94-
95 To include the file and line number, an object must be passed. If-
96 the file and line number is not available for that instance-
97 (either it was not instantiated by the QML engine or location-
98 information is disabled), "unknown location" will be used instead.-
99-
100 For example,-
101-
102 \code-
103 qmlInfo(object) << tr("component property is a write-once property");-
104 \endcode-
105-
106 prints-
107-
108 \code-
109 QML MyCustomType (unknown location): component property is a write-once property-
110 \endcode-
111-
112 \note In versions prior to Qt 5.9, qmlInfo reported messages using a warning-
113 QtMsgType. For Qt 5.9 and above, qmlInfo uses an info QtMsgType. To send-
114 warnings, use qmlWarning.-
115-
116 \sa QtQml::qmlDebug, QtQml::qmlWarning-
117*/-
118-
119-
120/*!-
121 \fn QQmlInfo QtQml::qmlWarning(const QObject *object)-
122 \relates QQmlEngine-
123 \since 5.9-
124-
125 Prints warning messages that include the file and line number for the-
126 specified QML \a object.-
127-
128 When QML types produce logging messages, it improves traceability-
129 if they include the QML file and line number on which the-
130 particular instance was instantiated.-
131-
132 To include the file and line number, an object must be passed. If-
133 the file and line number is not available for that instance-
134 (either it was not instantiated by the QML engine or location-
135 information is disabled), "unknown location" will be used instead.-
136-
137 For example,-
138-
139 \code-
140 qmlInfo(object) << tr("property cannot be set to 0");-
141 \endcode-
142-
143 prints-
144-
145 \code-
146 QML MyCustomType (unknown location): property cannot be set to 0-
147 \endcode-
148-
149 \sa QtQml::qmlDebug, QtQml::qmlInfo-
150*/-
151-
152class QQmlInfoPrivate-
153{-
154public:-
155 QQmlInfoPrivate(QtMsgType type)-
156 : ref (1)-
157 , msgType(type)-
158 , object(nullptr)-
159 {}
executed 976 times by 30 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmlbinding
  • tst_qqmlconnections
  • tst_qqmlconsole
  • tst_qqmlecmascript
  • tst_qqmlinfo
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickanchors
  • tst_qquickanimatedimage
  • tst_qquickanimatedsprite
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquickborderimage
  • tst_qquickdrag
  • tst_qquickflipable
  • tst_qquickfontloader
  • tst_qquickgravity
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_qquickitem2
  • tst_qquicklayouts
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquickpositioners
  • ...
976
160-
161 int ref;-
162 QtMsgType msgType;-
163 const QObject *object;-
164 QString buffer;-
165 QList<QQmlError> errors;-
166};-
167-
168QQmlInfo::QQmlInfo(QQmlInfoPrivate *p)-
169: QDebug(&p->buffer), d(p)-
170{-
171 nospace();-
172}
executed 976 times by 30 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmlbinding
  • tst_qqmlconnections
  • tst_qqmlconsole
  • tst_qqmlecmascript
  • tst_qqmlinfo
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickanchors
  • tst_qquickanimatedimage
  • tst_qquickanimatedsprite
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquickborderimage
  • tst_qquickdrag
  • tst_qquickflipable
  • tst_qquickfontloader
  • tst_qquickgravity
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_qquickitem2
  • tst_qquicklayouts
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquickpositioners
  • ...
976
173-
174QQmlInfo::QQmlInfo(const QQmlInfo &other)-
175: QDebug(other), d(other.d)-
176{-
177 d->ref++;-
178}
never executed: end of block
0
179-
180QQmlInfo::~QQmlInfo()-
181{-
182 if (0 == --d->ref) {
0 == --d->refDescription
TRUEevaluated 976 times by 30 tests
Evaluated by:
  • tst_examples
  • tst_qqmlbinding
  • tst_qqmlconnections
  • tst_qqmlconsole
  • tst_qqmlecmascript
  • tst_qqmlinfo
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickanchors
  • tst_qquickanimatedimage
  • tst_qquickanimatedsprite
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquickborderimage
  • tst_qquickdrag
  • tst_qquickflipable
  • tst_qquickfontloader
  • tst_qquickgravity
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_qquickitem2
  • tst_qquicklayouts
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquickpositioners
  • ...
FALSEnever evaluated
0-976
183 QList<QQmlError> errors = d->errors;-
184-
185 QQmlEngine *engine = nullptr;-
186-
187 if (!d->buffer.isEmpty()) {
!d->buffer.isEmpty()Description
TRUEevaluated 976 times by 30 tests
Evaluated by:
  • tst_examples
  • tst_qqmlbinding
  • tst_qqmlconnections
  • tst_qqmlconsole
  • tst_qqmlecmascript
  • tst_qqmlinfo
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickanchors
  • tst_qquickanimatedimage
  • tst_qquickanimatedsprite
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquickborderimage
  • tst_qquickdrag
  • tst_qquickflipable
  • tst_qquickfontloader
  • tst_qquickgravity
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_qquickitem2
  • tst_qquicklayouts
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquickpositioners
  • ...
FALSEnever evaluated
0-976
188 QQmlError error;-
189 error.setMessageType(d->msgType);-
190-
191 QObject *object = const_cast<QObject *>(d->object);-
192-
193 if (object) {
objectDescription
TRUEevaluated 924 times by 30 tests
Evaluated by:
  • tst_examples
  • tst_qqmlbinding
  • tst_qqmlconnections
  • tst_qqmlconsole
  • tst_qqmlecmascript
  • tst_qqmlinfo
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickanchors
  • tst_qquickanimatedimage
  • tst_qquickanimatedsprite
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquickborderimage
  • tst_qquickdrag
  • tst_qquickflipable
  • tst_qquickfontloader
  • tst_qquickgravity
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_qquickitem2
  • tst_qquicklayouts
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquickpositioners
  • ...
FALSEevaluated 52 times by 3 tests
Evaluated by:
  • tst_qqmlinfo
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
52-924
194 engine = qmlEngine(d->object);-
195-
196 d->buffer.prepend(QLatin1String("QML ") + QQmlMetaType::prettyTypeName(object) + QLatin1String(": "));-
197-
198 QQmlData *ddata = QQmlData::get(object, false);-
199 if (ddata && ddata->outerContext) {
ddataDescription
TRUEevaluated 720 times by 28 tests
Evaluated by:
  • tst_examples
  • tst_qqmlbinding
  • tst_qqmlconnections
  • tst_qqmlconsole
  • tst_qqmlecmascript
  • tst_qqmlinfo
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickanchors
  • tst_qquickanimatedimage
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquickborderimage
  • tst_qquickdrag
  • tst_qquickflipable
  • tst_qquickfontloader
  • tst_qquickgravity
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_qquickitem2
  • tst_qquicklayouts
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquickpositioners
  • tst_qquickstates
  • ...
FALSEevaluated 204 times by 8 tests
Evaluated by:
  • tst_qqmlinfo
  • tst_qqmllistmodelworkerscript
  • tst_qquickanchors
  • tst_qquickanimatedsprite
  • tst_qquickanimations
  • tst_qquickstates
  • tst_qquicktextedit
  • tst_qquicktextinput
ddata->outerContextDescription
TRUEevaluated 506 times by 27 tests
Evaluated by:
  • tst_examples
  • tst_qqmlbinding
  • tst_qqmlconnections
  • tst_qqmlconsole
  • tst_qqmlecmascript
  • tst_qqmlinfo
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickanchors
  • tst_qquickanimatedimage
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquickborderimage
  • tst_qquickflipable
  • tst_qquickfontloader
  • tst_qquickgravity
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_qquickitem2
  • tst_qquicklayouts
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquickpositioners
  • tst_qquickstates
  • tst_qquicktext
  • ...
FALSEevaluated 214 times by 2 tests
Evaluated by:
  • tst_qquickdrag
  • tst_qquickvisualdatamodel
204-720
200 error.setUrl(ddata->outerContext->url());-
201 error.setLine(ddata->lineNumber);-
202 error.setColumn(ddata->columnNumber);-
203 }
executed 506 times by 27 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmlbinding
  • tst_qqmlconnections
  • tst_qqmlconsole
  • tst_qqmlecmascript
  • tst_qqmlinfo
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickanchors
  • tst_qquickanimatedimage
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquickborderimage
  • tst_qquickflipable
  • tst_qquickfontloader
  • tst_qquickgravity
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_qquickitem2
  • tst_qquicklayouts
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquickpositioners
  • tst_qquickstates
  • tst_qquicktext
  • ...
506
204 }
executed 924 times by 30 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmlbinding
  • tst_qqmlconnections
  • tst_qqmlconsole
  • tst_qqmlecmascript
  • tst_qqmlinfo
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickanchors
  • tst_qquickanimatedimage
  • tst_qquickanimatedsprite
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquickborderimage
  • tst_qquickdrag
  • tst_qquickflipable
  • tst_qquickfontloader
  • tst_qquickgravity
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_qquickitem2
  • tst_qquicklayouts
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquickpositioners
  • ...
924
205-
206 error.setDescription(d->buffer);-
207-
208 errors.prepend(error);-
209 }
executed 976 times by 30 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmlbinding
  • tst_qqmlconnections
  • tst_qqmlconsole
  • tst_qqmlecmascript
  • tst_qqmlinfo
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickanchors
  • tst_qquickanimatedimage
  • tst_qquickanimatedsprite
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquickborderimage
  • tst_qquickdrag
  • tst_qquickflipable
  • tst_qquickfontloader
  • tst_qquickgravity
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_qquickitem2
  • tst_qquicklayouts
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquickpositioners
  • ...
976
210-
211 QQmlEnginePrivate::warning(engine, errors);-
212-
213 delete d;-
214 }
executed 976 times by 30 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmlbinding
  • tst_qqmlconnections
  • tst_qqmlconsole
  • tst_qqmlecmascript
  • tst_qqmlinfo
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickanchors
  • tst_qquickanimatedimage
  • tst_qquickanimatedsprite
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquickborderimage
  • tst_qquickdrag
  • tst_qquickflipable
  • tst_qquickfontloader
  • tst_qquickgravity
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_qquickitem2
  • tst_qquicklayouts
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquickpositioners
  • ...
976
215}
executed 976 times by 30 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmlbinding
  • tst_qqmlconnections
  • tst_qqmlconsole
  • tst_qqmlecmascript
  • tst_qqmlinfo
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickanchors
  • tst_qquickanimatedimage
  • tst_qquickanimatedsprite
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquickborderimage
  • tst_qquickdrag
  • tst_qquickflipable
  • tst_qquickfontloader
  • tst_qquickgravity
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_qquickitem2
  • tst_qquicklayouts
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquickpositioners
  • ...
976
216-
217namespace QtQml {-
218-
219#define MESSAGE_FUNCS(FuncName, MessageLevel) \-
220 QQmlInfo FuncName(const QObject *me) \-
221 { \-
222 QQmlInfoPrivate *d = new QQmlInfoPrivate(MessageLevel); \-
223 d->object = me; \-
224 return QQmlInfo(d); \-
225 } \-
226 QQmlInfo FuncName(const QObject *me, const QQmlError &error) \-
227 { \-
228 QQmlInfoPrivate *d = new QQmlInfoPrivate(MessageLevel); \-
229 d->object = me; \-
230 d->errors << error; \-
231 return QQmlInfo(d); \-
232 } \-
233 QQmlInfo FuncName(const QObject *me, const QList<QQmlError> &errors) \-
234 { \-
235 QQmlInfoPrivate *d = new QQmlInfoPrivate(MessageLevel); \-
236 d->object = me; \-
237 d->errors = errors; \-
238 return QQmlInfo(d); \-
239 }-
240-
241MESSAGE_FUNCS(qmlDebug, QtMsgType::QtDebugMsg)
executed 2 times by 1 test: return QQmlInfo(d);
Executed by:
  • tst_qqmlinfo
never executed: return QQmlInfo(d);
never executed: return QQmlInfo(d);
0-2
242MESSAGE_FUNCS(qmlInfo, QtMsgType::QtInfoMsg)
executed 48 times by 1 test: return QQmlInfo(d);
Executed by:
  • tst_qqmlinfo
never executed: return QQmlInfo(d);
never executed: return QQmlInfo(d);
0-48
243MESSAGE_FUNCS(qmlWarning, QtMsgType::QtWarningMsg)
executed 926 times by 30 tests: return QQmlInfo(d);
Executed by:
  • tst_examples
  • tst_qqmlbinding
  • tst_qqmlconnections
  • tst_qqmlconsole
  • tst_qqmlecmascript
  • tst_qqmlinfo
  • tst_qqmllistmodel
  • tst_qqmllistmodelworkerscript
  • tst_qquickanchors
  • tst_qquickanimatedimage
  • tst_qquickanimatedsprite
  • tst_qquickanimations
  • tst_qquickbehaviors
  • tst_qquickborderimage
  • tst_qquickdrag
  • tst_qquickflipable
  • tst_qquickfontloader
  • tst_qquickgravity
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_qquickitem2
  • tst_qquicklayouts
  • tst_qquicklistview
  • tst_qquickloader
  • tst_qquickpositioners
  • ...
never executed: return QQmlInfo(d);
never executed: return QQmlInfo(d);
0-926
244-
245-
246} // namespace QtQml-
247-
248#if QT_DEPRECATED_SINCE(5, 1)-
249-
250// Also define symbols outside namespace to keep binary compatibility with Qt 5.0-
251-
252QQmlInfo qmlInfo(const QObject *me)-
253{-
254 return QtQml::qmlInfo(me);
never executed: return QtQml::qmlInfo(me);
0
255}-
256-
257QQmlInfo qmlInfo(const QObject *me, const QQmlError &error)-
258{-
259 return QtQml::qmlInfo(me, error);
never executed: return QtQml::qmlInfo(me, error);
0
260}-
261-
262QQmlInfo qmlInfo(const QObject *me, const QList<QQmlError> &errors)-
263{-
264 return QtQml::qmlInfo(me, errors);
never executed: return QtQml::qmlInfo(me, errors);
0
265}-
266-
267#endif // QT_DEPRECATED_SINCE(5, 1)-
268-
269QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.0