Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/tools/qmlscene/main.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||
2 | - | |||||||||||||
3 | - | |||||||||||||
4 | - | |||||||||||||
5 | - | |||||||||||||
6 | - | |||||||||||||
7 | - | |||||||||||||
8 | - | |||||||||||||
9 | - | |||||||||||||
10 | - | |||||||||||||
11 | class RenderStatistics | - | ||||||||||||
12 | { | - | ||||||||||||
13 | public: | - | ||||||||||||
14 | static void updateStats(); | - | ||||||||||||
15 | static void printTotalStats(); | - | ||||||||||||
16 | private: | - | ||||||||||||
17 | static QVector<qreal> timePerFrame; | - | ||||||||||||
18 | static QVector<int> timesPerFrames; | - | ||||||||||||
19 | }; | - | ||||||||||||
20 | - | |||||||||||||
21 | QVector<qreal> RenderStatistics::timePerFrame; | - | ||||||||||||
22 | QVector<int> RenderStatistics::timesPerFrames; | - | ||||||||||||
23 | - | |||||||||||||
24 | void RenderStatistics::updateStats() | - | ||||||||||||
25 | { | - | ||||||||||||
26 | static QTime time; | - | ||||||||||||
27 | static int frames; | - | ||||||||||||
28 | static int lastTime; | - | ||||||||||||
29 | - | |||||||||||||
30 | if (frames == 0
| 0 | ||||||||||||
31 | time.start(); | - | ||||||||||||
32 | } never executed: else {end of block | 0 | ||||||||||||
33 | int elapsed = time.elapsed(); | - | ||||||||||||
34 | timesPerFrames.append(elapsed - lastTime); | - | ||||||||||||
35 | lastTime = elapsed; | - | ||||||||||||
36 | - | |||||||||||||
37 | if (elapsed > 5000
| 0 | ||||||||||||
38 | qreal avgtime = elapsed / (qreal) frames; | - | ||||||||||||
39 | qreal var = 0; | - | ||||||||||||
40 | for (int i = 0; i < timesPerFrames.size()
| 0 | ||||||||||||
41 | qreal diff = timesPerFrames.at(i) - avgtime; | - | ||||||||||||
42 | var += diff * diff; | - | ||||||||||||
43 | } never executed: end of block | 0 | ||||||||||||
44 | var /= timesPerFrames.size(); | - | ||||||||||||
45 | - | |||||||||||||
46 | printf("Average time per frame: %f ms (%i fps), std.dev: %f ms\n", avgtime, qRound(1000. / avgtime), qSqrt(var)); | - | ||||||||||||
47 | - | |||||||||||||
48 | timePerFrame.append(avgtime); | - | ||||||||||||
49 | timesPerFrames.clear(); | - | ||||||||||||
50 | time.start(); | - | ||||||||||||
51 | lastTime = 0; | - | ||||||||||||
52 | frames = 0; | - | ||||||||||||
53 | } never executed: end of block | 0 | ||||||||||||
54 | } never executed: end of block | 0 | ||||||||||||
55 | ++frames; | - | ||||||||||||
56 | } never executed: end of block | 0 | ||||||||||||
57 | - | |||||||||||||
58 | void RenderStatistics::printTotalStats() | - | ||||||||||||
59 | { | - | ||||||||||||
60 | int count = timePerFrame.count(); | - | ||||||||||||
61 | if (count == 0
| 0-14 | ||||||||||||
62 | return; executed 14 times by 2 tests: return; Executed by:
| 14 | ||||||||||||
63 | - | |||||||||||||
64 | qreal minTime = 0; | - | ||||||||||||
65 | qreal maxTime = 0; | - | ||||||||||||
66 | qreal avg = 0; | - | ||||||||||||
67 | for (int i = 0; i < count
| 0 | ||||||||||||
68 | minTime = minTime == 0
| 0 | ||||||||||||
69 | maxTime = qMax(maxTime, timePerFrame.at(i)); | - | ||||||||||||
70 | avg += timePerFrame.at(i); | - | ||||||||||||
71 | } never executed: end of block | 0 | ||||||||||||
72 | avg /= count; | - | ||||||||||||
73 | - | |||||||||||||
74 | puts(" "); | - | ||||||||||||
75 | puts("----- Statistics -----"); | - | ||||||||||||
76 | printf("Average time per frame: %f ms (%i fps)\n", avg, qRound(1000. / avg)); | - | ||||||||||||
77 | printf("Best time per frame: %f ms (%i fps)\n", minTime, int(1000 / minTime)); | - | ||||||||||||
78 | printf("Worst time per frame: %f ms (%i fps)\n", maxTime, int(1000 / maxTime)); | - | ||||||||||||
79 | puts("----------------------"); | - | ||||||||||||
80 | puts(" "); | - | ||||||||||||
81 | } never executed: end of block | 0 | ||||||||||||
82 | - | |||||||||||||
83 | - | |||||||||||||
84 | struct Options | - | ||||||||||||
85 | { | - | ||||||||||||
86 | enum QmlApplicationType | - | ||||||||||||
87 | { | - | ||||||||||||
88 | QmlApplicationTypeGui, | - | ||||||||||||
89 | QmlApplicationTypeWidget, | - | ||||||||||||
90 | - | |||||||||||||
91 | DefaultQmlApplicationType = QmlApplicationTypeWidget | - | ||||||||||||
92 | - | |||||||||||||
93 | - | |||||||||||||
94 | - | |||||||||||||
95 | }; | - | ||||||||||||
96 | - | |||||||||||||
97 | Options() | - | ||||||||||||
98 | : textRenderType(QQuickWindow::textRenderType()) | - | ||||||||||||
99 | { | - | ||||||||||||
100 | - | |||||||||||||
101 | - | |||||||||||||
102 | applicationAttributes.append(Qt::AA_ShareOpenGLContexts); | - | ||||||||||||
103 | } executed 14 times by 2 tests: end of block Executed by:
| 14 | ||||||||||||
104 | - | |||||||||||||
105 | QUrl url; | - | ||||||||||||
106 | bool originalQml = false; | - | ||||||||||||
107 | bool originalQmlRaster = false; | - | ||||||||||||
108 | bool maximized = false; | - | ||||||||||||
109 | bool fullscreen = false; | - | ||||||||||||
110 | bool transparent = false; | - | ||||||||||||
111 | bool clip = false; | - | ||||||||||||
112 | bool versionDetection = true; | - | ||||||||||||
113 | bool slowAnimations = false; | - | ||||||||||||
114 | bool quitImmediately = false; | - | ||||||||||||
115 | bool resizeViewToRootItem = false; | - | ||||||||||||
116 | bool multisample = false; | - | ||||||||||||
117 | bool coreProfile = false; | - | ||||||||||||
118 | bool verbose = false; | - | ||||||||||||
119 | QVector<Qt::ApplicationAttribute> applicationAttributes; | - | ||||||||||||
120 | QString translationFile; | - | ||||||||||||
121 | QmlApplicationType applicationType = DefaultQmlApplicationType; | - | ||||||||||||
122 | QQuickWindow::TextRenderType textRenderType; | - | ||||||||||||
123 | }; | - | ||||||||||||
124 | static bool checkVersion(const QUrl &url) | - | ||||||||||||
125 | { | - | ||||||||||||
126 | if (!qgetenv("QMLSCENE_IMPORT_NAME").isEmpty()
| 0-14 | ||||||||||||
127 | fprintf( never executed: fprintf( stderr , "QMLSCENE_IMPORT_NAME is no longer supported.\n"); | 0 | ||||||||||||
128 | stderr never executed: fprintf( stderr , "QMLSCENE_IMPORT_NAME is no longer supported.\n"); | 0 | ||||||||||||
129 | , "QMLSCENE_IMPORT_NAME is no longer supported.\n"); never executed: fprintf( stderr , "QMLSCENE_IMPORT_NAME is no longer supported.\n"); | 0 | ||||||||||||
130 | - | |||||||||||||
131 | if (!url.isLocalFile()
| 0-14 | ||||||||||||
132 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||
133 | - | |||||||||||||
134 | const QString fileName = url.toLocalFile(); | - | ||||||||||||
135 | QFile f(fileName); | - | ||||||||||||
136 | if (!f.open(QFile::ReadOnly | QFile::Text)
| 0-14 | ||||||||||||
137 | fprintf( | - | ||||||||||||
138 | stderr | - | ||||||||||||
139 | , "qmlscene: failed to check version of file '%s', could not open...\n", | - | ||||||||||||
140 | QtPrivate::asString(fileName).toLocal8Bit().constData()); | - | ||||||||||||
141 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
142 | } | - | ||||||||||||
143 | - | |||||||||||||
144 | QRegularExpression quick1("^\\s*import +QtQuick +1\\.\\w*"); | - | ||||||||||||
145 | QRegularExpression qt47("^\\s*import +Qt +4\\.7"); | - | ||||||||||||
146 | - | |||||||||||||
147 | QTextStream stream(&f); | - | ||||||||||||
148 | bool codeFound= false; | - | ||||||||||||
149 | while (!codeFound
| 14-282 | ||||||||||||
150 | QString line = stream.readLine(); | - | ||||||||||||
151 | if (line.contains(QLatin1Char('{'))
| 14-268 | ||||||||||||
152 | codeFound = true; | - | ||||||||||||
153 | } executed 14 times by 2 tests: else {end of block Executed by:
| 14 | ||||||||||||
154 | QString import; | - | ||||||||||||
155 | QRegularExpressionMatch match = quick1.match(line); | - | ||||||||||||
156 | if (match.hasMatch()
| 0-268 | ||||||||||||
157 | import = match.captured(0).trimmed(); never executed: import = match.captured(0).trimmed(); | 0 | ||||||||||||
158 | else if ((
| 0-268 | ||||||||||||
159 | import = match.captured(0).trimmed(); never executed: import = match.captured(0).trimmed(); | 0 | ||||||||||||
160 | - | |||||||||||||
161 | if (!import.isNull()
| 0-268 | ||||||||||||
162 | fprintf( | - | ||||||||||||
163 | stderr | - | ||||||||||||
164 | , "qmlscene: '%s' is no longer supported.\n" | - | ||||||||||||
165 | "Use qmlviewer to load file '%s'.\n", | - | ||||||||||||
166 | QtPrivate::asString(import).toLocal8Bit().constData(), | - | ||||||||||||
167 | QtPrivate::asString(fileName).toLocal8Bit().constData()); | - | ||||||||||||
168 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
169 | } | - | ||||||||||||
170 | } executed 268 times by 2 tests: end of block Executed by:
| 268 | ||||||||||||
171 | } | - | ||||||||||||
172 | - | |||||||||||||
173 | return executed 14 times by 2 tests: true;return true; Executed by:
executed 14 times by 2 tests: return true; Executed by:
| 14 | ||||||||||||
174 | } | - | ||||||||||||
175 | - | |||||||||||||
176 | static void displayFileDialog(Options *options) | - | ||||||||||||
177 | { | - | ||||||||||||
178 | - | |||||||||||||
179 | if (options->applicationType == Options::QmlApplicationTypeWidget
| 0 | ||||||||||||
180 | QString fileName = QFileDialog::getOpenFileName(nullptr, "Open QML file", QString(), "QML Files (*.qml)"); | - | ||||||||||||
181 | if (!fileName.isEmpty()
| 0 | ||||||||||||
182 | QFileInfo fi(fileName); | - | ||||||||||||
183 | options->url = QUrl::fromLocalFile(fi.canonicalFilePath()); | - | ||||||||||||
184 | } never executed: end of block | 0 | ||||||||||||
185 | return; never executed: return; | 0 | ||||||||||||
186 | } | - | ||||||||||||
187 | - | |||||||||||||
188 | (void)options;; | - | ||||||||||||
189 | puts("No filename specified..."); | - | ||||||||||||
190 | } never executed: end of block | 0 | ||||||||||||
191 | - | |||||||||||||
192 | - | |||||||||||||
193 | static void loadTranslationFile(QTranslator &translator, const QString& directory) | - | ||||||||||||
194 | { | - | ||||||||||||
195 | translator.load(QLatin1String("qml_" )+QLocale::system().name(), directory + QLatin1String("/i18n")); | - | ||||||||||||
196 | QCoreApplication::installTranslator(&translator); | - | ||||||||||||
197 | } executed 14 times by 2 tests: end of block Executed by:
| 14 | ||||||||||||
198 | - | |||||||||||||
199 | - | |||||||||||||
200 | static void loadDummyDataFiles(QQmlEngine &engine, const QString& directory) | - | ||||||||||||
201 | { | - | ||||||||||||
202 | QDir dir(directory+"/dummydata", "*.qml"); | - | ||||||||||||
203 | QStringList list = dir.entryList(); | - | ||||||||||||
204 | for (int i = 0; i < list.size()
| 0-14 | ||||||||||||
205 | QString qml = list.at(i); | - | ||||||||||||
206 | QQmlComponent comp(&engine, dir.filePath(qml)); | - | ||||||||||||
207 | QObject *dummyData = comp.create(); | - | ||||||||||||
208 | - | |||||||||||||
209 | if(comp.isError()
| 0 | ||||||||||||
210 | const QList<QQmlError> errors = comp.errors(); | - | ||||||||||||
211 | for (const QQmlError &error : errors) | - | ||||||||||||
212 | fprintf( never executed: fprintf( stderr , "%s\n", QtPrivate::asString(error.toString()).toLocal8Bit().constData()); | 0 | ||||||||||||
213 | stderr never executed: fprintf( stderr , "%s\n", QtPrivate::asString(error.toString()).toLocal8Bit().constData()); | 0 | ||||||||||||
214 | , "%s\n", QtPrivate::asString(error.toString()).toLocal8Bit().constData()); never executed: fprintf( stderr , "%s\n", QtPrivate::asString(error.toString()).toLocal8Bit().constData()); | 0 | ||||||||||||
215 | } never executed: end of block | 0 | ||||||||||||
216 | - | |||||||||||||
217 | if (dummyData
| 0 | ||||||||||||
218 | fprintf( | - | ||||||||||||
219 | stderr | - | ||||||||||||
220 | , "Loaded dummy data: %s\n", QtPrivate::asString(dir.filePath(qml)).toLocal8Bit().constData()); | - | ||||||||||||
221 | qml.truncate(qml.length()-4); | - | ||||||||||||
222 | engine.rootContext()->setContextProperty(qml, dummyData); | - | ||||||||||||
223 | dummyData->setParent(&engine); | - | ||||||||||||
224 | } never executed: end of block | 0 | ||||||||||||
225 | } never executed: end of block | 0 | ||||||||||||
226 | } executed 14 times by 2 tests: end of block Executed by:
| 14 | ||||||||||||
227 | - | |||||||||||||
228 | static void usage() | - | ||||||||||||
229 | { | - | ||||||||||||
230 | puts("Usage: qmlscene [options] <filename>"); | - | ||||||||||||
231 | puts(" "); | - | ||||||||||||
232 | puts(" Options:"); | - | ||||||||||||
233 | puts(" --maximized ...................... Run maximized"); | - | ||||||||||||
234 | puts(" --fullscreen ..................... Run fullscreen"); | - | ||||||||||||
235 | puts(" --transparent .................... Make the window transparent"); | - | ||||||||||||
236 | puts(" --multisample .................... Enable multisampling (OpenGL anti-aliasing)"); | - | ||||||||||||
237 | puts(" --core-profile ................... Request a core profile OpenGL context"); | - | ||||||||||||
238 | puts(" --no-version-detection ........... Do not try to detect the version of the .qml file"); | - | ||||||||||||
239 | puts(" --slow-animations ................ Run all animations in slow motion"); | - | ||||||||||||
240 | puts(" --resize-to-root ................. Resize the window to the size of the root item"); | - | ||||||||||||
241 | puts(" --quit ........................... Quit immediately after starting"); | - | ||||||||||||
242 | puts(" --disable-context-sharing ........ Disable the use of a shared GL context for QtQuick Windows\n" | - | ||||||||||||
243 | " .........(remove AA_ShareOpenGLContexts)"); | - | ||||||||||||
244 | puts(" --desktop..........................Force use of desktop GL (AA_UseDesktopOpenGL)"); | - | ||||||||||||
245 | puts(" --gles.............................Force use of GLES (AA_UseOpenGLES)"); | - | ||||||||||||
246 | puts(" --software.........................Force use of software rendering (AA_UseOpenGLES)"); | - | ||||||||||||
247 | puts(" --scaling..........................Enable High DPI scaling (AA_EnableHighDpiScaling)"); | - | ||||||||||||
248 | puts(" --no-scaling.......................Disable High DPI scaling (AA_DisableHighDpiScaling)"); | - | ||||||||||||
249 | puts(" --verbose..........................Print version and graphical diagnostics for the run-time"); | - | ||||||||||||
250 | - | |||||||||||||
251 | puts(" --apptype [gui|widgets] ...........Select which application class to use. Default is widgets."); | - | ||||||||||||
252 | - | |||||||||||||
253 | puts(" --textrendertype [qt|native].......Select the default render type for text-like elements."); | - | ||||||||||||
254 | puts(" -I <path> ........................ Add <path> to the list of import paths"); | - | ||||||||||||
255 | puts(" -P <path> ........................ Add <path> to the list of plugin paths"); | - | ||||||||||||
256 | puts(" -translation <translationfile> ... Set the language to run in"); | - | ||||||||||||
257 | - | |||||||||||||
258 | puts(" "); | - | ||||||||||||
259 | exit(1); never executed: exit(1); | 0 | ||||||||||||
260 | } | - | ||||||||||||
261 | - | |||||||||||||
262 | - | |||||||||||||
263 | class DiagnosticGlContextCreationListener : public QObject { | - | ||||||||||||
264 | public: | - | ||||||||||||
265 | #pragma GCC diagnostic push | - | ||||||||||||
266 | - | |||||||||||||
267 | #pragma GCC diagnostic ignored "-Wsuggest-override" | - | ||||||||||||
268 | static const QMetaObject staticMetaObject; virtual const QMetaObject *metaObject() const; virtual void *qt_metacast(const char *); virtual int qt_metacall(QMetaObject::Call, int, void **); static inline QString tr(const char *s, const char *c = nullptr, int n = -1) { return staticMetaObject.tr(s, c, n); } static inline QString trUtf8(const char *s, const char *c = nullptr, int n = -1) { return staticMetaObject.tr(s, c, n); } private: | - | ||||||||||||
269 | #pragma GCC diagnostic ignored "-Wattributes" | - | ||||||||||||
270 | __attribute__((visibility("hidden"))) static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); | - | ||||||||||||
271 | #pragma GCC diagnostic pop | - | ||||||||||||
272 | struct QPrivateSignal {}; | - | ||||||||||||
273 | public: | - | ||||||||||||
274 | explicit DiagnosticGlContextCreationListener(QQuickWindow *window) : QObject(window) | - | ||||||||||||
275 | { | - | ||||||||||||
276 | connect(window, &QQuickWindow::openglContextCreated, | - | ||||||||||||
277 | this, &DiagnosticGlContextCreationListener::onOpenGlContextCreated); | - | ||||||||||||
278 | } never executed: end of block | 0 | ||||||||||||
279 | - | |||||||||||||
280 | private : | - | ||||||||||||
281 | void onOpenGlContextCreated(QOpenGLContext *context) | - | ||||||||||||
282 | { | - | ||||||||||||
283 | context->makeCurrent(qobject_cast<QQuickWindow *>(parent())); | - | ||||||||||||
284 | QOpenGLFunctions functions(context); | - | ||||||||||||
285 | QByteArray output = "Vendor : "; | - | ||||||||||||
286 | output += reinterpret_cast<const char *>(functions.glGetString( | - | ||||||||||||
287 | 0x1F00 | - | ||||||||||||
288 | )); | - | ||||||||||||
289 | output += "\nRenderer: "; | - | ||||||||||||
290 | output += reinterpret_cast<const char *>(functions.glGetString( | - | ||||||||||||
291 | 0x1F01 | - | ||||||||||||
292 | )); | - | ||||||||||||
293 | output += "\nVersion : "; | - | ||||||||||||
294 | output += reinterpret_cast<const char *>(functions.glGetString( | - | ||||||||||||
295 | 0x1F02 | - | ||||||||||||
296 | )); | - | ||||||||||||
297 | output += "\nLanguage: "; | - | ||||||||||||
298 | output += reinterpret_cast<const char *>(functions.glGetString(0x8B8C)); | - | ||||||||||||
299 | puts(output.constData()); | - | ||||||||||||
300 | context->doneCurrent(); | - | ||||||||||||
301 | deleteLater(); | - | ||||||||||||
302 | } never executed: end of block | 0 | ||||||||||||
303 | - | |||||||||||||
304 | }; | - | ||||||||||||
305 | - | |||||||||||||
306 | - | |||||||||||||
307 | static void setWindowTitle(bool verbose, const QObject *topLevel, QWindow *window) | - | ||||||||||||
308 | { | - | ||||||||||||
309 | const QString oldTitle = window->title(); | - | ||||||||||||
310 | QString newTitle = oldTitle; | - | ||||||||||||
311 | if (newTitle.isEmpty()
| 0-8 | ||||||||||||
312 | newTitle = QLatin1String("qmlscene"); | - | ||||||||||||
313 | if (!qobject_cast<const QWindow *>(topLevel)
| 0-8 | ||||||||||||
314 | newTitle += QLatin1String(": ") + topLevel->objectName(); never executed: newTitle += QLatin1String(": ") + topLevel->objectName(); | 0 | ||||||||||||
315 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||
316 | if (verbose
| 0-8 | ||||||||||||
317 | newTitle += QLatin1String(" [Qt ") + QLatin1String("5.12.0") + QLatin1Char(' ') | - | ||||||||||||
318 | + QGuiApplication::platformName() + QLatin1Char(' '); | - | ||||||||||||
319 | - | |||||||||||||
320 | newTitle += QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL
| 0 | ||||||||||||
321 | ? QLatin1String("GL") : QLatin1String("GLES"); | - | ||||||||||||
322 | - | |||||||||||||
323 | newTitle += QLatin1Char(']'); | - | ||||||||||||
324 | } never executed: end of block | 0 | ||||||||||||
325 | if (oldTitle != newTitle
| 0-8 | ||||||||||||
326 | window->setTitle(newTitle); executed 8 times by 1 test: window->setTitle(newTitle); Executed by:
| 8 | ||||||||||||
327 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||
328 | - | |||||||||||||
329 | static QUrl parseUrlArgument(const QString &arg) | - | ||||||||||||
330 | { | - | ||||||||||||
331 | const QUrl url = QUrl::fromUserInput(arg, QDir::currentPath(), QUrl::AssumeLocalFile); | - | ||||||||||||
332 | if (!url.isValid()
| 0-14 | ||||||||||||
333 | fprintf( | - | ||||||||||||
334 | stderr | - | ||||||||||||
335 | , "Invalid URL: \"%s\"\n", QtPrivate::asString(arg).toLocal8Bit().constData()); | - | ||||||||||||
336 | return never executed: QUrl();return QUrl(); never executed: return QUrl(); | 0 | ||||||||||||
337 | } | - | ||||||||||||
338 | if (url.isLocalFile()
| 0-14 | ||||||||||||
339 | const QFileInfo fi(url.toLocalFile()); | - | ||||||||||||
340 | if (!fi.exists()
| 0-14 | ||||||||||||
341 | fprintf( | - | ||||||||||||
342 | stderr | - | ||||||||||||
343 | , "\"%s\" does not exist.\n", | - | ||||||||||||
344 | QtPrivate::asString(QDir::toNativeSeparators(fi.absoluteFilePath())).toLocal8Bit().constData()); | - | ||||||||||||
345 | return never executed: QUrl();return QUrl(); never executed: return QUrl(); | 0 | ||||||||||||
346 | } | - | ||||||||||||
347 | } executed 14 times by 2 tests: end of block Executed by:
| 14 | ||||||||||||
348 | return executed 14 times by 2 tests: url;return url; Executed by:
executed 14 times by 2 tests: return url; Executed by:
| 14 | ||||||||||||
349 | } | - | ||||||||||||
350 | - | |||||||||||||
351 | static QQuickWindow::TextRenderType parseTextRenderType(const QString &renderType) | - | ||||||||||||
352 | { | - | ||||||||||||
353 | if (renderType == QLatin1String("qt")
| 0 | ||||||||||||
354 | return never executed: QQuickWindow::QtTextRendering;return QQuickWindow::QtTextRendering; never executed: return QQuickWindow::QtTextRendering; | 0 | ||||||||||||
355 | else if (renderType == QLatin1String("native")
| 0 | ||||||||||||
356 | return never executed: QQuickWindow::NativeTextRendering;return QQuickWindow::NativeTextRendering; never executed: return QQuickWindow::NativeTextRendering; | 0 | ||||||||||||
357 | - | |||||||||||||
358 | usage(); | - | ||||||||||||
359 | - | |||||||||||||
360 | do { ((false) ? static_cast<void>(0) : qt_assert_x("Q_UNREACHABLE()", "Q_UNREACHABLE was reached", __FILE__, 457)); __builtin_unreachable(); } while (false); | - | ||||||||||||
361 | return never executed: QQuickWindow::QtTextRendering;return QQuickWindow::QtTextRendering; never executed: return QQuickWindow::QtTextRendering; | 0 | ||||||||||||
362 | } | - | ||||||||||||
363 | - | |||||||||||||
364 | int main(int argc, char ** argv) | - | ||||||||||||
365 | { | - | ||||||||||||
366 | Options options; | - | ||||||||||||
367 | - | |||||||||||||
368 | QStringList imports; | - | ||||||||||||
369 | QStringList pluginPaths; | - | ||||||||||||
370 | - | |||||||||||||
371 | - | |||||||||||||
372 | for (int i = 1; i < argc
| 14-28 | ||||||||||||
373 | const char *arg = argv[i]; | - | ||||||||||||
374 | if (!qstrcmp(arg, "--disable-context-sharing")
| 0-28 | ||||||||||||
375 | options.applicationAttributes.removeAll(Qt::AA_ShareOpenGLContexts); | - | ||||||||||||
376 | } never executed: else if (!qstrcmp(arg, "--gles")end of block
| 0-28 | ||||||||||||
377 | options.applicationAttributes.append(Qt::AA_UseOpenGLES); | - | ||||||||||||
378 | } never executed: else if (!qstrcmp(arg, "--software")end of block
| 0-28 | ||||||||||||
379 | options.applicationAttributes.append(Qt::AA_UseSoftwareOpenGL); | - | ||||||||||||
380 | } never executed: else if (!qstrcmp(arg, "--desktop")end of block
| 0-28 | ||||||||||||
381 | options.applicationAttributes.append(Qt::AA_UseDesktopOpenGL); | - | ||||||||||||
382 | } never executed: else if (!qstrcmp(arg, "--scaling")end of block
| 0-28 | ||||||||||||
383 | options.applicationAttributes.append(Qt::AA_EnableHighDpiScaling); | - | ||||||||||||
384 | } never executed: else if (!qstrcmp(arg, "--no-scaling")end of block
| 0-28 | ||||||||||||
385 | options.applicationAttributes.append(Qt::AA_DisableHighDpiScaling); | - | ||||||||||||
386 | } never executed: else if (!qstrcmp(arg, "--apptype")end of block
| 0-28 | ||||||||||||
387 | if (++
| 0 | ||||||||||||
388 | usage(); never executed: usage(); | 0 | ||||||||||||
389 | if (!qstrcmp(argv[i], "gui")
| 0 | ||||||||||||
390 | options.applicationType = Options::QmlApplicationTypeGui; never executed: options.applicationType = Options::QmlApplicationTypeGui; | 0 | ||||||||||||
391 | } never executed: end of block | 0 | ||||||||||||
392 | } executed 28 times by 2 tests: end of block Executed by:
| 28 | ||||||||||||
393 | - | |||||||||||||
394 | for (Qt::ApplicationAttribute a : qAsConst(options.applicationAttributes)) | - | ||||||||||||
395 | QCoreApplication::setAttribute(a); executed 14 times by 2 tests: QCoreApplication::setAttribute(a); Executed by:
| 14 | ||||||||||||
396 | QScopedPointer<QGuiApplication> app; | - | ||||||||||||
397 | - | |||||||||||||
398 | if (options.applicationType == Options::QmlApplicationTypeWidget
| 0-14 | ||||||||||||
399 | app.reset(new QApplication(argc, argv)); executed 14 times by 2 tests: app.reset(new QApplication(argc, argv)); Executed by:
| 14 | ||||||||||||
400 | - | |||||||||||||
401 | if (app.isNull()
| 0-14 | ||||||||||||
402 | app.reset(new QGuiApplication(argc, argv)); never executed: app.reset(new QGuiApplication(argc, argv)); | 0 | ||||||||||||
403 | QCoreApplication::setApplicationName(([]() noexcept -> QString { enum { Size = sizeof(u"" "QtQmlViewer")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "QtQmlViewer" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 14 times by 2 tests: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 14 times by 2 tests: }()));return qstring_literal_temp; Executed by:
| 14 | ||||||||||||
404 | QCoreApplication::setOrganizationName(([]() noexcept -> QString { enum { Size = sizeof(u"" "QtProject")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "QtProject" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 14 times by 2 tests: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 14 times by 2 tests: }()));return qstring_literal_temp; Executed by:
| 14 | ||||||||||||
405 | QCoreApplication::setOrganizationDomain(([]() noexcept -> QString { enum { Size = sizeof(u"" "qt-project.org")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "qt-project.org" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 14 times by 2 tests: qstring_literal_temp;return qstring_literal_temp; Executed by:
executed 14 times by 2 tests: }()));return qstring_literal_temp; Executed by:
| 14 | ||||||||||||
406 | QCoreApplication::setApplicationVersion(QLatin1String("5.12.0")); | - | ||||||||||||
407 | - | |||||||||||||
408 | const QStringList arguments = QCoreApplication::arguments(); | - | ||||||||||||
409 | for (int i = 1, size = arguments.size(); i < size
| 14 | ||||||||||||
410 | if (!arguments.at(i).startsWith(QLatin1Char('-'))
| 0-14 | ||||||||||||
411 | options.url = parseUrlArgument(arguments.at(i)); | - | ||||||||||||
412 | } executed 14 times by 2 tests: else {end of block Executed by:
| 14 | ||||||||||||
413 | const QString lowerArgument = arguments.at(i).toLower(); | - | ||||||||||||
414 | if (lowerArgument == QLatin1String("--maximized")
| 0 | ||||||||||||
415 | options.maximized = true; never executed: options.maximized = true; | 0 | ||||||||||||
416 | else if (lowerArgument == QLatin1String("--fullscreen")
| 0 | ||||||||||||
417 | options.fullscreen = true; never executed: options.fullscreen = true; | 0 | ||||||||||||
418 | else if (lowerArgument == QLatin1String("--transparent")
| 0 | ||||||||||||
419 | options.transparent = true; never executed: options.transparent = true; | 0 | ||||||||||||
420 | else if (lowerArgument == QLatin1String("--clip")
| 0 | ||||||||||||
421 | options.clip = true; never executed: options.clip = true; | 0 | ||||||||||||
422 | else if (lowerArgument == QLatin1String("--no-version-detection")
| 0 | ||||||||||||
423 | options.versionDetection = false; never executed: options.versionDetection = false; | 0 | ||||||||||||
424 | else if (lowerArgument == QLatin1String("--slow-animations")
| 0 | ||||||||||||
425 | options.slowAnimations = true; never executed: options.slowAnimations = true; | 0 | ||||||||||||
426 | else if (lowerArgument == QLatin1String("--quit")
| 0 | ||||||||||||
427 | options.quitImmediately = true; never executed: options.quitImmediately = true; | 0 | ||||||||||||
428 | else if (lowerArgument == QLatin1String("-translation")
| 0 | ||||||||||||
429 | options.translationFile = QLatin1String(argv[++i]); never executed: options.translationFile = QLatin1String(argv[++i]); | 0 | ||||||||||||
430 | else if (lowerArgument == QLatin1String("--resize-to-root")
| 0 | ||||||||||||
431 | options.resizeViewToRootItem = true; never executed: options.resizeViewToRootItem = true; | 0 | ||||||||||||
432 | else if (lowerArgument == QLatin1String("--multisample")
| 0 | ||||||||||||
433 | options.multisample = true; never executed: options.multisample = true; | 0 | ||||||||||||
434 | else if (lowerArgument == QLatin1String("--core-profile")
| 0 | ||||||||||||
435 | options.coreProfile = true; never executed: options.coreProfile = true; | 0 | ||||||||||||
436 | else if (lowerArgument == QLatin1String("--verbose")
| 0 | ||||||||||||
437 | options.verbose = true; never executed: options.verbose = true; | 0 | ||||||||||||
438 | else if (lowerArgument == QLatin1String("-i")
| 0 | ||||||||||||
439 | imports.append(arguments.at(++i)); never executed: imports.append(arguments.at(++i)); | 0 | ||||||||||||
440 | else if (lowerArgument == QLatin1String("-p")
| 0 | ||||||||||||
441 | pluginPaths.append(arguments.at(++i)); never executed: pluginPaths.append(arguments.at(++i)); | 0 | ||||||||||||
442 | else if (lowerArgument == QLatin1String("--apptype")
| 0 | ||||||||||||
443 | ++ never executed: i;++i; never executed: ++i; | 0 | ||||||||||||
444 | else if (lowerArgument == QLatin1String("--textrendertype")
| 0 | ||||||||||||
445 | options.textRenderType = parseTextRenderType(arguments.at(++i)); never executed: options.textRenderType = parseTextRenderType(arguments.at(++i)); | 0 | ||||||||||||
446 | else if (lowerArgument == QLatin1String("--help")
| 0 | ||||||||||||
447 | || lowerArgument == QLatin1String("-help")
| 0 | ||||||||||||
448 | || lowerArgument == QLatin1String("--h")
| 0 | ||||||||||||
449 | || lowerArgument == QLatin1String("-h")
| 0 | ||||||||||||
450 | usage(); never executed: usage(); | 0 | ||||||||||||
451 | } never executed: end of block | 0 | ||||||||||||
452 | } | - | ||||||||||||
453 | - | |||||||||||||
454 | - | |||||||||||||
455 | QTranslator translator; | - | ||||||||||||
456 | QTranslator qtTranslator; | - | ||||||||||||
457 | QString sysLocale = QLocale::system().name(); | - | ||||||||||||
458 | if (qtTranslator.load(QLatin1String("qt_") + sysLocale, QLibraryInfo::location(QLibraryInfo::TranslationsPath))
| 0-14 | ||||||||||||
459 | app->installTranslator(&qtTranslator); never executed: app->installTranslator(&qtTranslator); | 0 | ||||||||||||
460 | if (translator.load(QLatin1String("qmlscene_") + sysLocale, QLibraryInfo::location(QLibraryInfo::TranslationsPath))
| 0-14 | ||||||||||||
461 | app->installTranslator(&translator); never executed: app->installTranslator(&translator); | 0 | ||||||||||||
462 | - | |||||||||||||
463 | QTranslator qmlTranslator; | - | ||||||||||||
464 | if (!options.translationFile.isEmpty()
| 0-14 | ||||||||||||
465 | if (qmlTranslator.load(options.translationFile)
| 0 | ||||||||||||
466 | app->installTranslator(&qmlTranslator); | - | ||||||||||||
467 | } never executed: else {end of block | 0 | ||||||||||||
468 | fprintf( | - | ||||||||||||
469 | stderr | - | ||||||||||||
470 | , "Could not load the translation file \"%s\"\n", | - | ||||||||||||
471 | QtPrivate::asString(options.translationFile).toLocal8Bit().constData()); | - | ||||||||||||
472 | } never executed: end of block | 0 | ||||||||||||
473 | } | - | ||||||||||||
474 | - | |||||||||||||
475 | - | |||||||||||||
476 | QQuickWindow::setTextRenderType(options.textRenderType); | - | ||||||||||||
477 | - | |||||||||||||
478 | QUnifiedTimer::instance()->setSlowModeEnabled(options.slowAnimations); | - | ||||||||||||
479 | - | |||||||||||||
480 | if (options.url.isEmpty()
| 0-14 | ||||||||||||
481 | - | |||||||||||||
482 | - | |||||||||||||
483 | - | |||||||||||||
484 | displayFileDialog(&options); never executed: displayFileDialog(&options); | 0 | ||||||||||||
485 | - | |||||||||||||
486 | - | |||||||||||||
487 | int exitCode = 0; | - | ||||||||||||
488 | - | |||||||||||||
489 | if (options.verbose
| 0-14 | ||||||||||||
490 | puts(QLibraryInfo::build()); never executed: puts(QLibraryInfo::build()); | 0 | ||||||||||||
491 | - | |||||||||||||
492 | if (!options.url.isEmpty()
| 0-14 | ||||||||||||
493 | if (!options.versionDetection
| 0-14 | ||||||||||||
494 | - | |||||||||||||
495 | QTranslator translator; | - | ||||||||||||
496 | - | |||||||||||||
497 | - | |||||||||||||
498 | - | |||||||||||||
499 | - | |||||||||||||
500 | QQmlEngine engine; | - | ||||||||||||
501 | QPointer<QQmlComponent> component = new QQmlComponent(&engine); | - | ||||||||||||
502 | for (int i = 0; i < imports.size()
| 0-14 | ||||||||||||
503 | engine.addImportPath(imports.at(i)); never executed: engine.addImportPath(imports.at(i)); | 0 | ||||||||||||
504 | for (int i = 0; i < pluginPaths.size()
| 0-14 | ||||||||||||
505 | engine.addPluginPath(pluginPaths.at(i)); never executed: engine.addPluginPath(pluginPaths.at(i)); | 0 | ||||||||||||
506 | if (options.url.isLocalFile()
| 0-14 | ||||||||||||
507 | QFileInfo fi(options.url.toLocalFile()); | - | ||||||||||||
508 | - | |||||||||||||
509 | loadTranslationFile(translator, fi.path()); | - | ||||||||||||
510 | - | |||||||||||||
511 | loadDummyDataFiles(engine, fi.path()); | - | ||||||||||||
512 | } executed 14 times by 2 tests: end of block Executed by:
| 14 | ||||||||||||
513 | QObject::connect(&engine, qFlagLocation("2""quit()" "\0" __FILE__ ":" "608"), QCoreApplication::instance(), qFlagLocation("1""quit()" "\0" __FILE__ ":" "608")); | - | ||||||||||||
514 | QObject::connect(&engine, &QQmlEngine::exit, QCoreApplication::instance(), &QCoreApplication::exit); | - | ||||||||||||
515 | component->loadUrl(options.url); | - | ||||||||||||
516 | while (component->isLoading()
| 0-14 | ||||||||||||
517 | QCoreApplication::processEvents(); never executed: QCoreApplication::processEvents(); | 0 | ||||||||||||
518 | if ( !component->isReady()
| 0-14 | ||||||||||||
519 | fprintf( | - | ||||||||||||
520 | stderr | - | ||||||||||||
521 | , "%s\n", QtPrivate::asString(component->errorString()).toLocal8Bit().constData()); | - | ||||||||||||
522 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||
523 | } | - | ||||||||||||
524 | - | |||||||||||||
525 | QObject *topLevel = component->create(); | - | ||||||||||||
526 | if (!topLevel
| 0-14 | ||||||||||||
527 | fprintf( | - | ||||||||||||
528 | stderr | - | ||||||||||||
529 | , "%s\n", QtPrivate::asString(component->errorString()).toLocal8Bit().constData()); | - | ||||||||||||
530 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||
531 | } | - | ||||||||||||
532 | QScopedPointer<QQuickWindow> window(qobject_cast<QQuickWindow *>(topLevel)); | - | ||||||||||||
533 | if (window
| 0-14 | ||||||||||||
534 | engine.setIncubationController(window->incubationController()); | - | ||||||||||||
535 | } never executed: else {end of block | 0 | ||||||||||||
536 | QQuickItem *contentItem = qobject_cast<QQuickItem *>(topLevel); | - | ||||||||||||
537 | if (contentItem
| 6-8 | ||||||||||||
538 | QQuickView* qxView = new QQuickView(&engine, nullptr); | - | ||||||||||||
539 | window.reset(qxView); | - | ||||||||||||
540 | - | |||||||||||||
541 | if (options.resizeViewToRootItem
| 0-8 | ||||||||||||
542 | qxView->setResizeMode(QQuickView::SizeViewToRootObject); never executed: qxView->setResizeMode(QQuickView::SizeViewToRootObject); | 0 | ||||||||||||
543 | else | - | ||||||||||||
544 | qxView->setResizeMode(QQuickView::SizeRootObjectToView); executed 8 times by 1 test: qxView->setResizeMode(QQuickView::SizeRootObjectToView); Executed by:
| 8 | ||||||||||||
545 | qxView->setContent(options.url, component, contentItem); | - | ||||||||||||
546 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||
547 | } executed 14 times by 2 tests: end of block Executed by:
| 14 | ||||||||||||
548 | - | |||||||||||||
549 | if (window
| 6-8 | ||||||||||||
550 | setWindowTitle(options.verbose, topLevel, window.data()); | - | ||||||||||||
551 | - | |||||||||||||
552 | if (options.verbose
| 0-8 | ||||||||||||
553 | new never executed: DiagnosticGlContextCreationListener(window.data());new DiagnosticGlContextCreationListener(window.data()); never executed: new DiagnosticGlContextCreationListener(window.data()); | 0 | ||||||||||||
554 | - | |||||||||||||
555 | QSurfaceFormat surfaceFormat = window->requestedFormat(); | - | ||||||||||||
556 | if (options.multisample
| 0-8 | ||||||||||||
557 | surfaceFormat.setSamples(16); never executed: surfaceFormat.setSamples(16); | 0 | ||||||||||||
558 | if (options.transparent
| 0-8 | ||||||||||||
559 | surfaceFormat.setAlphaBufferSize(8); | - | ||||||||||||
560 | window->setClearBeforeRendering(true); | - | ||||||||||||
561 | window->setColor(QColor(Qt::transparent)); | - | ||||||||||||
562 | window->setFlags(Qt::FramelessWindowHint); | - | ||||||||||||
563 | } never executed: end of block | 0 | ||||||||||||
564 | if (options.coreProfile
| 0-8 | ||||||||||||
565 | surfaceFormat.setVersion(4, 1); | - | ||||||||||||
566 | surfaceFormat.setProfile(QSurfaceFormat::CoreProfile); | - | ||||||||||||
567 | } never executed: end of block | 0 | ||||||||||||
568 | window->setFormat(surfaceFormat); | - | ||||||||||||
569 | - | |||||||||||||
570 | if (window->flags() == Qt::Window
| 0-8 | ||||||||||||
571 | window->setFlags(Qt::Window | Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint | Qt::WindowFullscreenButtonHint); executed 8 times by 1 test: window->setFlags(Qt::Window | Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint | Qt::WindowFullscreenButtonHint); Executed by:
| 8 | ||||||||||||
572 | - | |||||||||||||
573 | if (options.fullscreen
| 0-8 | ||||||||||||
574 | window->showFullScreen(); never executed: window->showFullScreen(); | 0 | ||||||||||||
575 | else if (options.maximized
| 0-8 | ||||||||||||
576 | window->showMaximized(); never executed: window->showMaximized(); | 0 | ||||||||||||
577 | else if (!window->isVisible()
| 0-8 | ||||||||||||
578 | window->show(); executed 8 times by 1 test: window->show(); Executed by:
| 8 | ||||||||||||
579 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||
580 | - | |||||||||||||
581 | if (options.quitImmediately
| 0-14 | ||||||||||||
582 | QMetaObject::invokeMethod(QCoreApplication::instance(), "quit", Qt::QueuedConnection); never executed: QMetaObject::invokeMethod(QCoreApplication::instance(), "quit", Qt::QueuedConnection); | 0 | ||||||||||||
583 | - | |||||||||||||
584 | - | |||||||||||||
585 | - | |||||||||||||
586 | exitCode = app->exec(); | - | ||||||||||||
587 | - | |||||||||||||
588 | - | |||||||||||||
589 | RenderStatistics::printTotalStats(); | - | ||||||||||||
590 | - | |||||||||||||
591 | - | |||||||||||||
592 | - | |||||||||||||
593 | - | |||||||||||||
594 | delete component; | - | ||||||||||||
595 | } executed 14 times by 2 tests: end of block Executed by:
| 14 | ||||||||||||
596 | } executed 14 times by 2 tests: end of block Executed by:
| 14 | ||||||||||||
597 | - | |||||||||||||
598 | return executed 14 times by 2 tests: exitCode;return exitCode; Executed by:
executed 14 times by 2 tests: return exitCode; Executed by:
| 14 | ||||||||||||
599 | } | - | ||||||||||||
600 | - | |||||||||||||
Switch to Source code | Preprocessed file |