kernel/qcoreapplication.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
1/**************************************************************************** -
2** -
3** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -
4** Contact: http://www.qt-project.org/legal -
5** -
6** This file is part of the QtCore 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 Digia. For licensing terms and -
14** conditions see http://qt.digia.com/licensing. For further information -
15** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software -
20** Foundation and appearing in the file LICENSE.LGPL included in the -
21** packaging of this file. Please review the following information to -
22** ensure the GNU Lesser General Public License version 2.1 requirements -
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -
24** -
25** In addition, as a special exception, Digia gives you certain additional -
26** rights. These rights are described in the Digia Qt LGPL Exception -
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -
28** -
29** GNU General Public License Usage -
30** Alternatively, this file may be used under the terms of the GNU -
31** General Public License version 3.0 as published by the Free Software -
32** Foundation and appearing in the file LICENSE.GPL included in the -
33** packaging of this file. Please review the following information to -
34** ensure the GNU General Public License version 3.0 requirements will be -
35** met: http://www.gnu.org/copyleft/gpl.html. -
36** -
37** -
38** $QT_END_LICENSE$ -
39** -
40****************************************************************************/ -
41 -
42#include "qcoreapplication.h" -
43#include "qcoreapplication_p.h" -
44 -
45#include "qabstracteventdispatcher.h" -
46#include "qcoreevent.h" -
47#include "qeventloop.h" -
48#include "qcorecmdlineargs_p.h" -
49#include <qdatastream.h> -
50#include <qdebug.h> -
51#include <qdir.h> -
52#include <qfile.h> -
53#include <qfileinfo.h> -
54#include <qhash.h> -
55#include <private/qprocess_p.h> -
56#include <qstandardpaths.h> -
57#include <qtextcodec.h> -
58#include <qthread.h> -
59#include <qthreadpool.h> -
60#include <qthreadstorage.h> -
61#include <private/qthread_p.h> -
62#include <qelapsedtimer.h> -
63#include <qlibraryinfo.h> -
64#include <qvarlengtharray.h> -
65#include <private/qfactoryloader_p.h> -
66#include <private/qfunctions_p.h> -
67#include <private/qlocale_p.h> -
68 -
69#if defined(Q_OS_UNIX) -
70# if defined(Q_OS_BLACKBERRY) -
71# include "qeventdispatcher_blackberry_p.h" -
72# include <process.h> -
73# include <unistd.h> -
74# else -
75# if !defined(QT_NO_GLIB) -
76# include "qeventdispatcher_glib_p.h" -
77# endif -
78# include "qeventdispatcher_unix_p.h" -
79# endif -
80#endif -
81 -
82#ifdef Q_OS_WIN -
83# include "qeventdispatcher_win_p.h" -
84#endif -
85 -
86#ifdef Q_OS_MAC -
87# include "qcore_mac_p.h" -
88#endif -
89 -
90#include <stdlib.h> -
91 -
92#ifdef Q_OS_UNIX -
93# include <locale.h> -
94#endif -
95 -
96#ifdef Q_OS_VXWORKS -
97# include <taskLib.h> -
98#endif -
99 -
100QT_BEGIN_NAMESPACE -
101 -
102class QMutexUnlocker -
103{ -
104public: -
105 inline explicit QMutexUnlocker(QMutex *m) -
106 : mtx(m) -
107 { }
executed: }
Execution Count:476519
476519
108 inline ~QMutexUnlocker() { unlock(); }
executed: }
Execution Count:476518
476518
109 inline void unlock() { if (mtx) mtx->unlock(); mtx = 0; }
executed: mtx->unlock();
Execution Count:476517
executed: }
Execution Count:944666
evaluated: mtx
TRUEFALSE
yes
Evaluation Count:476517
yes
Evaluation Count:468151
468151-944666
110 -
111private: -
112 Q_DISABLE_COPY(QMutexUnlocker) -
113 -
114 QMutex *mtx; -
115}; -
116 -
117#if defined(Q_OS_WIN) || defined(Q_OS_MAC) -
118extern QString qAppFileName(); -
119#endif -
120 -
121#if QT_VERSION >= 0x060000 -
122# error "Bump QCoreApplicatoinPrivate::app_compile_version to 0x060000" -
123#endif -
124int QCoreApplicationPrivate::app_compile_version = 0x050000; //we don't know exactly, but it's at least 5.0.0 -
125 -
126#if !defined(Q_OS_WIN) -
127#ifdef Q_OS_MAC -
128QString QCoreApplicationPrivate::macMenuBarName() -
129{ -
130 QString bundleName; -
131 CFTypeRef string = CFBundleGetValueForInfoDictionaryKey(CFBundleGetMainBundle(), CFSTR("CFBundleName")); -
132 if (string) -
133 bundleName = QCFString::toQString(static_cast<CFStringRef>(string)); -
134 return bundleName; -
135} -
136#endif -
137QString QCoreApplicationPrivate::appName() const -
138{ -
139 static QString applName; -
140#ifdef Q_OS_MAC -
141 applName = macMenuBarName(); -
142#endif -
143 if (applName.isEmpty() && argv[0]) {
evaluated: applName.isEmpty()
TRUEFALSE
yes
Evaluation Count:111
yes
Evaluation Count:5328
partially evaluated: argv[0]
TRUEFALSE
yes
Evaluation Count:111
no
Evaluation Count:0
0-5328
144 char *p = strrchr(argv[0], '/');
executed (the execution status of this line is deduced): char *p = strrchr(argv[0], '/');
-
145 applName = QString::fromLocal8Bit(p ? p + 1 : argv[0]);
executed (the execution status of this line is deduced): applName = QString::fromLocal8Bit(p ? p + 1 : argv[0]);
-
146 }
executed: }
Execution Count:111
111
147 return applName;
executed: return applName;
Execution Count:5439
5439
148} -
149#endif -
150 -
151bool QCoreApplicationPrivate::checkInstance(const char *function) -
152{ -
153 bool b = (QCoreApplication::self != 0);
executed (the execution status of this line is deduced): bool b = (QCoreApplication::self != 0);
-
154 if (!b)
partially evaluated: !b
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:142
0-142
155 qWarning("QApplication::%s: Please instantiate the QApplication object first", function);
never executed: QMessageLogger("kernel/qcoreapplication.cpp", 155, __PRETTY_FUNCTION__).warning("QApplication::%s: Please instantiate the QApplication object first", function);
0
156 return b;
executed: return b;
Execution Count:142
142
157} -
158 -
159void QCoreApplicationPrivate::processCommandLineArguments() -
160{ -
161 int j = argc ? 1 : 0;
evaluated: argc
TRUEFALSE
yes
Evaluation Count:53
yes
Evaluation Count:92
53-92
162 for (int i = 1; i < argc; ++i) {
evaluated: i < argc
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:145
12-145
163 if (argv[i] && *argv[i] != '-') {
partially evaluated: argv[i]
TRUEFALSE
yes
Evaluation Count:12
no
Evaluation Count:0
evaluated: *argv[i] != '-'
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:6
0-12
164 argv[j++] = argv[i];
executed (the execution status of this line is deduced): argv[j++] = argv[i];
-
165 continue;
executed: continue;
Execution Count:6
6
166 } -
167 QByteArray arg = argv[i];
executed (the execution status of this line is deduced): QByteArray arg = argv[i];
-
168 if (arg.startsWith("-qmljsdebugger=")) {
evaluated: arg.startsWith("-qmljsdebugger=")
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:5
1-5
169 qmljs_debug_arguments = QString::fromLocal8Bit(arg.right(arg.length() - 15));
executed (the execution status of this line is deduced): qmljs_debug_arguments = QString::fromLocal8Bit(arg.right(arg.length() - 15));
-
170 } else if (arg == "-qmljsdebugger" && i < argc - 1) {
executed: }
Execution Count:1
partially evaluated: arg == "-qmljsdebugger"
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
never evaluated: i < argc - 1
0-5
171 ++i;
never executed (the execution status of this line is deduced): ++i;
-
172 qmljs_debug_arguments = QString::fromLocal8Bit(argv[i]);
never executed (the execution status of this line is deduced): qmljs_debug_arguments = QString::fromLocal8Bit(argv[i]);
-
173 } else {
never executed: }
0
174 argv[j++] = argv[i];
executed (the execution status of this line is deduced): argv[j++] = argv[i];
-
175 }
executed: }
Execution Count:5
5
176 } -
177 -
178 if (j < argc) {
evaluated: j < argc
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:144
1-144
179 argv[j] = 0;
executed (the execution status of this line is deduced): argv[j] = 0;
-
180 argc = j;
executed (the execution status of this line is deduced): argc = j;
-
181 }
executed: }
Execution Count:1
1
182}
executed: }
Execution Count:145
145
183 -
184// Support for introspection -
185 -
186QSignalSpyCallbackSet Q_CORE_EXPORT qt_signal_spy_callback_set = { 0, 0, 0, 0 }; -
187 -
188void qt_register_signal_spy_callbacks(const QSignalSpyCallbackSet &callback_set) -
189{ -
190 qt_signal_spy_callback_set = callback_set;
executed (the execution status of this line is deduced): qt_signal_spy_callback_set = callback_set;
-
191}
executed: }
Execution Count:394
394
192 -
193extern "C" void Q_CORE_EXPORT qt_startup_hook() -
194{ -
195} -
196 -
197typedef QList<QtCleanUpFunction> QVFuncList; -
198Q_GLOBAL_STATIC(QVFuncList, postRList)
never executed: delete x;
executed: return thisGlobalStatic.pointer.load();
Execution Count:819
partially evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:160
evaluated: !thisGlobalStatic.pointer.load()
TRUEFALSE
yes
Evaluation Count:160
yes
Evaluation Count:659
partially evaluated: !thisGlobalStatic.destroyed
TRUEFALSE
yes
Evaluation Count:160
no
Evaluation Count:0
0-819
199 -
200void qAddPostRoutine(QtCleanUpFunction p) -
201{ -
202 QVFuncList *list = postRList();
executed (the execution status of this line is deduced): QVFuncList *list = postRList();
-
203 if (!list)
partially evaluated: !list
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:123
0-123
204 return;
never executed: return;
0
205 list->prepend(p);
executed (the execution status of this line is deduced): list->prepend(p);
-
206}
executed: }
Execution Count:123
123
207 -
208void qRemovePostRoutine(QtCleanUpFunction p) -
209{ -
210 QVFuncList *list = postRList();
never executed (the execution status of this line is deduced): QVFuncList *list = postRList();
-
211 if (!list)
never evaluated: !list
0
212 return;
never executed: return;
0
213 list->removeAll(p);
never executed (the execution status of this line is deduced): list->removeAll(p);
-
214}
never executed: }
0
215 -
216void Q_CORE_EXPORT qt_call_post_routines() -
217{ -
218 QVFuncList *list = 0;
executed (the execution status of this line is deduced): QVFuncList *list = 0;
-
219 QT_TRY { -
220 list = postRList();
executed (the execution status of this line is deduced): list = postRList();
-
221 } QT_CATCH(const std::bad_alloc &) {
executed: }
Execution Count:696
696
222 // ignore - if we can't allocate a post routine list, -
223 // there's a high probability that there's no post -
224 // routine to be executed :) -
225 }
never executed: }
0
226 if (!list)
partially evaluated: !list
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:696
0-696
227 return;
never executed: return;
0
228 while (!list->isEmpty())
evaluated: !list->isEmpty()
TRUEFALSE
yes
Evaluation Count:309
yes
Evaluation Count:696
309-696
229 (list->takeFirst())();
executed: (list->takeFirst())();
Execution Count:309
309
230}
executed: }
Execution Count:696
696
231 -
232 -
233// app starting up if false -
234bool QCoreApplicationPrivate::is_app_running = false; -
235 // app closing down if true -
236bool QCoreApplicationPrivate::is_app_closing = false; -
237// initialized in qcoreapplication and in qtextstream autotest when setlocale is called. -
238static bool qt_locale_initialized = false; -
239 -
240Q_CORE_EXPORT uint qGlobalPostedEventsCount() -
241{ -
242 QThreadData *currentThreadData = QThreadData::current();
executed (the execution status of this line is deduced): QThreadData *currentThreadData = QThreadData::current();
-
243 return currentThreadData->postEventList.size() - currentThreadData->postEventList.startOffset;
executed: return currentThreadData->postEventList.size() - currentThreadData->postEventList.startOffset;
Execution Count:8
8
244} -
245 -
246QCoreApplication *QCoreApplication::self = 0; -
247QAbstractEventDispatcher *QCoreApplicationPrivate::eventDispatcher = 0; -
248uint QCoreApplicationPrivate::attribs = (1 << Qt::AA_SynthesizeMouseForUnhandledTouchEvents); -
249 -
250#ifdef Q_OS_UNIX -
251Qt::HANDLE qt_application_thread_id = 0; -
252#endif -
253 -
254struct QCoreApplicationData { -
255 QCoreApplicationData() { -
256#ifndef QT_NO_LIBRARY -
257 app_libpaths = 0;
executed (the execution status of this line is deduced): app_libpaths = 0;
-
258#endif -
259 }
executed: }
Execution Count:6
6
260 ~QCoreApplicationData() { -
261#ifndef QT_NO_LIBRARY -
262 delete app_libpaths;
executed (the execution status of this line is deduced): delete app_libpaths;
-
263#endif -
264 -
265 // cleanup the QAdoptedThread created for the main() thread -
266 if (QCoreApplicationPrivate::theMainThread) {
partially evaluated: QCoreApplicationPrivate::theMainThread
TRUEFALSE
yes
Evaluation Count:346
no
Evaluation Count:0
0-346
267 QThreadData *data = QThreadData::get2(QCoreApplicationPrivate::theMainThread);
executed (the execution status of this line is deduced): QThreadData *data = QThreadData::get2(QCoreApplicationPrivate::theMainThread);
-
268 QCoreApplicationPrivate::theMainThread = 0;
executed (the execution status of this line is deduced): QCoreApplicationPrivate::theMainThread = 0;
-
269 data->deref(); // deletes the data and the adopted thread
executed (the execution status of this line is deduced): data->deref();
-
270 }
executed: }
Execution Count:346
346
271 }
executed: }
Execution Count:346
346
272 -
273#ifdef Q_OS_BLACKBERRY -
274 //The QCoreApplicationData struct is only populated on demand, because it is rarely needed and would -
275 //affect startup time -
276 void loadManifest() { -
277 static bool manifestLoadAttempt = false; -
278 if (manifestLoadAttempt) -
279 return; -
280 -
281 manifestLoadAttempt = true; -
282 -
283 QFile metafile(QStringLiteral("app/META-INF/MANIFEST.MF")); -
284 if (!metafile.open(QIODevice::ReadOnly)) { -
285 qWarning() << Q_FUNC_INFO << "Could not open application metafile for reading"; -
286 } else { -
287 while (!metafile.atEnd() && (application.isEmpty() || applicationVersion.isEmpty() || orgName.isEmpty())) { -
288 QByteArray line = metafile.readLine(); -
289 if (line.startsWith("Application-Name:")) -
290 application = QString::fromUtf8(line.mid(18).trimmed()); -
291 else if (line.startsWith("Application-Version:")) -
292 applicationVersion = QString::fromUtf8(line.mid(21).trimmed()); -
293 else if (line.startsWith("Package-Author:")) -
294 orgName = QString::fromUtf8(line.mid(16).trimmed()); -
295 } -
296 metafile.close(); -
297 } -
298 } -
299#endif -
300 -
301 QString orgName, orgDomain, application; -
302 QString applicationVersion; -
303 -
304#ifndef QT_NO_LIBRARY -
305 QStringList *app_libpaths; -
306#endif -
307 -
308}; -
309 -
310Q_GLOBAL_STATIC(QCoreApplicationData, coreappdata)
never executed: delete x;
executed: return thisGlobalStatic.pointer.load();
Execution Count:16666
partially evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
evaluated: !thisGlobalStatic.pointer.load()
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:16660
partially evaluated: !thisGlobalStatic.destroyed
TRUEFALSE
yes
Evaluation Count:6
no
Evaluation Count:0
0-16666
311 -
312static bool quitLockRefEnabled = true; -
313 -
314QCoreApplicationPrivate::QCoreApplicationPrivate(int &aargc, char **aargv, uint flags) -
315 : QObjectPrivate() -
316 , argc(aargc) -
317 , argv(aargv) -
318#ifdef Q_OS_WIN -
319 , origArgc(aargc) -
320 , origArgv(new char *[aargc]) -
321#endif -
322 , application_type(0) -
323 , in_exec(false) -
324 , aboutToQuitEmitted(false) -
325 , threadData_clean(false) -
326{ -
327 app_compile_version = flags & 0xffffff;
executed (the execution status of this line is deduced): app_compile_version = flags & 0xffffff;
-
328 static const char *const empty = ""; -
329 if (argc == 0 || argv == 0) {
evaluated: argc == 0
TRUEFALSE
yes
Evaluation Count:92
yes
Evaluation Count:53
partially evaluated: argv == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:53
0-92
330 argc = 0;
executed (the execution status of this line is deduced): argc = 0;
-
331 argv = (char **)&empty; // ouch! careful with QCoreApplication::argv()!
executed (the execution status of this line is deduced): argv = (char **)&empty;
-
332 }
executed: }
Execution Count:92
92
333 QCoreApplicationPrivate::is_app_closing = false;
executed (the execution status of this line is deduced): QCoreApplicationPrivate::is_app_closing = false;
-
334 -
335#if defined(Q_OS_UNIX) -
336 qt_application_thread_id = QThread::currentThreadId();
executed (the execution status of this line is deduced): qt_application_thread_id = QThread::currentThreadId();
-
337#elif defined(Q_OS_WIN) -
338 qCopy(argv, argv + argc, origArgv); -
339#endif -
340 -
341 // note: this call to QThread::currentThread() may end up setting theMainThread! -
342 if (QThread::currentThread() != theMainThread)
partially evaluated: QThread::currentThread() != theMainThread
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:145
0-145
343 qWarning("WARNING: QApplication was not created in the main() thread.");
never executed: QMessageLogger("kernel/qcoreapplication.cpp", 343, __PRETTY_FUNCTION__).warning("WARNING: QApplication was not created in the main() thread.");
0
344}
executed: }
Execution Count:145
145
345 -
346QCoreApplicationPrivate::~QCoreApplicationPrivate() -
347{ -
348 cleanupThreadData();
executed (the execution status of this line is deduced): cleanupThreadData();
-
349#ifdef Q_OS_WIN -
350 delete [] origArgv; -
351#endif -
352}
executed: }
Execution Count:483
483
353 -
354void QCoreApplicationPrivate::cleanupThreadData() -
355{ -
356 if (threadData && !threadData_clean) {
partially evaluated: threadData
TRUEFALSE
yes
Evaluation Count:770
no
Evaluation Count:0
evaluated: !threadData_clean
TRUEFALSE
yes
Evaluation Count:483
yes
Evaluation Count:287
0-770
357#ifndef QT_NO_THREAD -
358 void *data = &threadData->tls;
executed (the execution status of this line is deduced): void *data = &threadData->tls;
-
359 QThreadStorageData::finish((void **)data);
executed (the execution status of this line is deduced): QThreadStorageData::finish((void **)data);
-
360#endif -
361 -
362 // need to clear the state of the mainData, just in case a new QCoreApplication comes along. -
363 QMutexLocker locker(&threadData->postEventList.mutex);
executed (the execution status of this line is deduced): QMutexLocker locker(&threadData->postEventList.mutex);
-
364 for (int i = 0; i < threadData->postEventList.size(); ++i) {
evaluated: i < threadData->postEventList.size()
TRUEFALSE
yes
Evaluation Count:5904
yes
Evaluation Count:483
483-5904
365 const QPostEvent &pe = threadData->postEventList.at(i);
executed (the execution status of this line is deduced): const QPostEvent &pe = threadData->postEventList.at(i);
-
366 if (pe.event) {
evaluated: pe.event
TRUEFALSE
yes
Evaluation Count:5892
yes
Evaluation Count:12
12-5892
367 --pe.receiver->d_func()->postedEvents;
executed (the execution status of this line is deduced): --pe.receiver->d_func()->postedEvents;
-
368 pe.event->posted = false;
executed (the execution status of this line is deduced): pe.event->posted = false;
-
369 delete pe.event;
executed (the execution status of this line is deduced): delete pe.event;
-
370 }
executed: }
Execution Count:5892
5892
371 }
executed: }
Execution Count:5904
5904
372 threadData->postEventList.clear();
executed (the execution status of this line is deduced): threadData->postEventList.clear();
-
373 threadData->postEventList.recursion = 0;
executed (the execution status of this line is deduced): threadData->postEventList.recursion = 0;
-
374 threadData->quitNow = false;
executed (the execution status of this line is deduced): threadData->quitNow = false;
-
375 threadData_clean = true;
executed (the execution status of this line is deduced): threadData_clean = true;
-
376 }
executed: }
Execution Count:483
483
377}
executed: }
Execution Count:770
770
378 -
379void QCoreApplicationPrivate::createEventDispatcher() -
380{ -
381 Q_Q(QCoreApplication);
executed (the execution status of this line is deduced): QCoreApplication * const q = q_func();
-
382#if defined(Q_OS_UNIX) -
383# if defined(Q_OS_BLACKBERRY) -
384 eventDispatcher = new QEventDispatcherBlackberry(q); -
385# else -
386# if !defined(QT_NO_GLIB) -
387 if (qEnvironmentVariableIsEmpty("QT_NO_GLIB") && QEventDispatcherGlib::versionSupported())
partially evaluated: qEnvironmentVariableIsEmpty("QT_NO_GLIB")
TRUEFALSE
yes
Evaluation Count:39
no
Evaluation Count:0
partially evaluated: QEventDispatcherGlib::versionSupported()
TRUEFALSE
yes
Evaluation Count:39
no
Evaluation Count:0
0-39
388 eventDispatcher = new QEventDispatcherGlib(q);
executed: eventDispatcher = new QEventDispatcherGlib(q);
Execution Count:39
39
389 else -
390# endif -
391 eventDispatcher = new QEventDispatcherUNIX(q);
never executed: eventDispatcher = new QEventDispatcherUNIX(q);
0
392# endif -
393#elif defined(Q_OS_WIN) -
394 eventDispatcher = new QEventDispatcherWin32(q); -
395#else -
396# error "QEventDispatcher not yet ported to this platform" -
397#endif -
398} -
399 -
400QThread *QCoreApplicationPrivate::theMainThread = 0; -
401QThread *QCoreApplicationPrivate::mainThread() -
402{ -
403 Q_ASSERT(theMainThread != 0);
executed (the execution status of this line is deduced): qt_noop();
-
404 return theMainThread;
executed: return theMainThread;
Execution Count:8888
8888
405} -
406 -
407#if !defined (QT_NO_DEBUG) || defined (QT_MAC_FRAMEWORK_BUILD) -
408void QCoreApplicationPrivate::checkReceiverThread(QObject *receiver) -
409{ -
410 QThread *currentThread = QThread::currentThread(); -
411 QThread *thr = receiver->thread(); -
412 Q_ASSERT_X(currentThread == thr || !thr, -
413 "QCoreApplication::sendEvent", -
414 QString::fromLatin1("Cannot send events to objects owned by a different thread. " -
415 "Current thread %1. Receiver '%2' (of type '%3') was created in thread %4") -
416 .arg(QString::number((quintptr) currentThread, 16)) -
417 .arg(receiver->objectName()) -
418 .arg(QLatin1String(receiver->metaObject()->className())) -
419 .arg(QString::number((quintptr) thr, 16)) -
420 .toLocal8Bit().data()); -
421 Q_UNUSED(currentThread); -
422 Q_UNUSED(thr); -
423} -
424#endif -
425 -
426void QCoreApplicationPrivate::appendApplicationPathToLibraryPaths() -
427{ -
428#ifndef QT_NO_LIBRARY -
429 QStringList *app_libpaths = coreappdata()->app_libpaths;
executed (the execution status of this line is deduced): QStringList *app_libpaths = coreappdata()->app_libpaths;
-
430 if (!app_libpaths)
partially evaluated: !app_libpaths
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:34
0-34
431 coreappdata()->app_libpaths = app_libpaths = new QStringList;
never executed: coreappdata()->app_libpaths = app_libpaths = new QStringList;
0
432 QString app_location = QCoreApplication::applicationFilePath();
executed (the execution status of this line is deduced): QString app_location = QCoreApplication::applicationFilePath();
-
433 app_location.truncate(app_location.lastIndexOf(QLatin1Char('/')));
executed (the execution status of this line is deduced): app_location.truncate(app_location.lastIndexOf(QLatin1Char('/')));
-
434 app_location = QDir(app_location).canonicalPath();
executed (the execution status of this line is deduced): app_location = QDir(app_location).canonicalPath();
-
435 if (QFile::exists(app_location) && !app_libpaths->contains(app_location))
partially evaluated: QFile::exists(app_location)
TRUEFALSE
yes
Evaluation Count:34
no
Evaluation Count:0
evaluated: !app_libpaths->contains(app_location)
TRUEFALSE
yes
Evaluation Count:31
yes
Evaluation Count:3
0-34
436 app_libpaths->append(app_location);
executed: app_libpaths->append(app_location);
Execution Count:31
31
437#endif -
438}
executed: }
Execution Count:34
34
439 -
440QString qAppName() -
441{ -
442 if (!QCoreApplicationPrivate::checkInstance("qAppName"))
partially evaluated: !QCoreApplicationPrivate::checkInstance("qAppName")
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
443 return QString();
never executed: return QString();
0
444 return QCoreApplication::instance()->d_func()->appName();
executed: return QCoreApplication::instance()->d_func()->appName();
Execution Count:3
3
445} -
446 -
447void QCoreApplicationPrivate::initLocale() -
448{ -
449 if (qt_locale_initialized)
evaluated: qt_locale_initialized
TRUEFALSE
yes
Evaluation Count:139
yes
Evaluation Count:6
6-139
450 return;
executed: return;
Execution Count:139
139
451 qt_locale_initialized = true;
executed (the execution status of this line is deduced): qt_locale_initialized = true;
-
452#ifdef Q_OS_UNIX -
453 setlocale(LC_ALL, "");
executed (the execution status of this line is deduced): setlocale(__LC_ALL, "");
-
454#endif -
455}
executed: }
Execution Count:6
6
456 -
457 -
458/*! -
459 \class QCoreApplication -
460 \inmodule QtCore -
461 \brief The QCoreApplication class provides an event loop for console Qt -
462 applications. -
463 -
464 This class is used by non-GUI applications to provide their event -
465 loop. For non-GUI application that uses Qt, there should be exactly -
466 one QCoreApplication object. For GUI applications, see -
467 QApplication. -
468 -
469 QCoreApplication contains the main event loop, where all events -
470 from the operating system (e.g., timer and network events) and -
471 other sources are processed and dispatched. It also handles the -
472 application's initialization and finalization, as well as -
473 system-wide and application-wide settings. -
474 -
475 \section1 The Event Loop and Event Handling -
476 -
477 The event loop is started with a call to exec(). Long running -
478 operations can call processEvents() to keep the application -
479 responsive. -
480 -
481 In general, we recommend that you create a QCoreApplication or a -
482 QApplication object in your \c main() function as early as -
483 possible. exec() will not return until the event loop exits; e.g., -
484 when quit() is called. -
485 -
486 Several static convenience functions are also provided. The -
487 QCoreApplication object is available from instance(). Events can -
488 be sent or posted using sendEvent(), postEvent(), and -
489 sendPostedEvents(). Pending events can be removed with -
490 removePostedEvents() or flushed with flush(). -
491 -
492 The class provides a quit() slot and an aboutToQuit() signal. -
493 -
494 \section1 Application and Library Paths -
495 -
496 An application has an applicationDirPath() and an -
497 applicationFilePath(). Library paths (see QLibrary) can be retrieved -
498 with libraryPaths() and manipulated by setLibraryPaths(), addLibraryPath(), -
499 and removeLibraryPath(). -
500 -
501 \section1 Internationalization and Translations -
502 -
503 Translation files can be added or removed -
504 using installTranslator() and removeTranslator(). Application -
505 strings can be translated using translate(). The QObject::tr() -
506 and QObject::trUtf8() functions are implemented in terms of -
507 translate(). -
508 -
509 \section1 Accessing Command Line Arguments -
510 -
511 The command line arguments which are passed to QCoreApplication's -
512 constructor should be accessed using the arguments() function. -
513 Note that some arguments supplied by the user may have been -
514 processed and removed by QCoreApplication. -
515 -
516 In cases where command line arguments need to be obtained using the -
517 argv() function, you must convert them from the local string encoding -
518 using QString::fromLocal8Bit(). -
519 -
520 \section1 Locale Settings -
521 -
522 On Unix/Linux Qt is configured to use the system locale settings by -
523 default. This can cause a conflict when using POSIX functions, for -
524 instance, when converting between data types such as floats and -
525 strings, since the notation may differ between locales. To get -
526 around this problem, call the POSIX function \c{setlocale(LC_NUMERIC,"C")} -
527 right after initializing QApplication or QCoreApplication to reset -
528 the locale that is used for number formatting to "C"-locale. -
529 -
530 \sa QGuiApplication, QAbstractEventDispatcher, QEventLoop, -
531 {Semaphores Example}, {Wait Conditions Example} -
532*/ -
533 -
534/*! -
535 \fn static QCoreApplication *QCoreApplication::instance() -
536 -
537 Returns a pointer to the application's QCoreApplication (or -
538 QApplication) instance. -
539 -
540 If no instance has been allocated, \c null is returned. -
541*/ -
542 -
543/*! -
544 \internal -
545 */ -
546QCoreApplication::QCoreApplication(QCoreApplicationPrivate &p) -
547 : QObject(p, 0) -
548{ -
549 init();
executed (the execution status of this line is deduced): init();
-
550 // note: it is the subclasses' job to call -
551 // QCoreApplicationPrivate::eventDispatcher->startingUp(); -
552}
executed: }
Execution Count:105
105
553 -
554/*! -
555 Flushes the platform specific event queues. -
556 -
557 If you are doing graphical changes inside a loop that does not -
558 return to the event loop on asynchronous window systems like X11 -
559 or double buffered window systems like Mac OS X, and you want to -
560 visualize these changes immediately (e.g. Splash Screens), call -
561 this function. -
562 -
563 \sa sendPostedEvents() -
564*/ -
565void QCoreApplication::flush() -
566{ -
567 if (self && self->d_func()->eventDispatcher)
partially evaluated: self
TRUEFALSE
yes
Evaluation Count:270
no
Evaluation Count:0
partially evaluated: self->d_func()->eventDispatcher
TRUEFALSE
yes
Evaluation Count:270
no
Evaluation Count:0
0-270
568 self->d_func()->eventDispatcher->flush();
executed: self->d_func()->eventDispatcher->flush();
Execution Count:270
270
569}
executed: }
Execution Count:270
270
570 -
571/*! -
572 Constructs a Qt kernel application. Kernel applications are -
573 applications without a graphical user interface. These type of -
574 applications are used at the console or as server processes. -
575 -
576 The \a argc and \a argv arguments are processed by the application, -
577 and made available in a more convenient form by the arguments() -
578 function. -
579 -
580 \warning The data referred to by \a argc and \a argv must stay valid -
581 for the entire lifetime of the QCoreApplication object. In addition, -
582 \a argc must be greater than zero and \a argv must contain at least -
583 one valid character string. -
584*/ -
585QCoreApplication::QCoreApplication(int &argc, char **argv -
586#ifndef Q_QDOC -
587 , int _internal -
588#endif -
589 ) -
590 : QObject(*new QCoreApplicationPrivate(argc, argv, _internal)) -
591{ -
592 init();
executed (the execution status of this line is deduced): init();
-
593 QCoreApplicationPrivate::eventDispatcher->startingUp();
executed (the execution status of this line is deduced): QCoreApplicationPrivate::eventDispatcher->startingUp();
-
594}
executed: }
Execution Count:40
40
595 -
596 -
597// ### move to QCoreApplicationPrivate constructor? -
598void QCoreApplication::init() -
599{ -
600 Q_D(QCoreApplication);
executed (the execution status of this line is deduced): QCoreApplicationPrivate * const d = d_func();
-
601 -
602 QCoreApplicationPrivate::initLocale();
executed (the execution status of this line is deduced): QCoreApplicationPrivate::initLocale();
-
603 -
604 Q_ASSERT_X(!self, "QCoreApplication", "there should be only one application object");
executed (the execution status of this line is deduced): qt_noop();
-
605 QCoreApplication::self = this;
executed (the execution status of this line is deduced): QCoreApplication::self = this;
-
606 -
607 // use the event dispatcher created by the app programmer (if any) -
608 if (!QCoreApplicationPrivate::eventDispatcher)
partially evaluated: !QCoreApplicationPrivate::eventDispatcher
TRUEFALSE
yes
Evaluation Count:145
no
Evaluation Count:0
0-145
609 QCoreApplicationPrivate::eventDispatcher = d->threadData->eventDispatcher;
executed: QCoreApplicationPrivate::eventDispatcher = d->threadData->eventDispatcher;
Execution Count:145
145
610 // otherwise we create one -
611 if (!QCoreApplicationPrivate::eventDispatcher)
evaluated: !QCoreApplicationPrivate::eventDispatcher
TRUEFALSE
yes
Evaluation Count:144
yes
Evaluation Count:1
1-144
612 d->createEventDispatcher();
executed: d->createEventDispatcher();
Execution Count:144
144
613 Q_ASSERT(QCoreApplicationPrivate::eventDispatcher != 0);
executed (the execution status of this line is deduced): qt_noop();
-
614 -
615 if (!QCoreApplicationPrivate::eventDispatcher->parent()) {
evaluated: !QCoreApplicationPrivate::eventDispatcher->parent()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:144
1-144
616 QCoreApplicationPrivate::eventDispatcher->moveToThread(d->threadData->thread);
executed (the execution status of this line is deduced): QCoreApplicationPrivate::eventDispatcher->moveToThread(d->threadData->thread);
-
617 QCoreApplicationPrivate::eventDispatcher->setParent(this);
executed (the execution status of this line is deduced): QCoreApplicationPrivate::eventDispatcher->setParent(this);
-
618 }
executed: }
Execution Count:1
1
619 -
620 d->threadData->eventDispatcher = QCoreApplicationPrivate::eventDispatcher;
executed (the execution status of this line is deduced): d->threadData->eventDispatcher = QCoreApplicationPrivate::eventDispatcher;
-
621 -
622#ifndef QT_NO_LIBRARY -
623 if (coreappdata()->app_libpaths)
evaluated: coreappdata()->app_libpaths
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:140
5-140
624 d->appendApplicationPathToLibraryPaths();
executed: d->appendApplicationPathToLibraryPaths();
Execution Count:5
5
625#endif -
626 -
627#if defined(Q_OS_UNIX) && !(defined(QT_NO_PROCESS)) -
628 // Make sure the process manager thread object is created in the main -
629 // thread. -
630 QProcessPrivate::initializeProcessManager();
executed (the execution status of this line is deduced): QProcessPrivate::initializeProcessManager();
-
631#endif -
632 -
633#ifdef QT_EVAL -
634 extern void qt_core_eval_init(uint); -
635 qt_core_eval_init(d->application_type); -
636#endif -
637 -
638 d->processCommandLineArguments();
executed (the execution status of this line is deduced): d->processCommandLineArguments();
-
639 -
640 qt_startup_hook();
executed (the execution status of this line is deduced): qt_startup_hook();
-
641}
executed: }
Execution Count:145
145
642 -
643/*! -
644 Destroys the QCoreApplication object. -
645*/ -
646QCoreApplication::~QCoreApplication() -
647{ -
648 qt_call_post_routines();
executed (the execution status of this line is deduced): qt_call_post_routines();
-
649 -
650 self = 0;
executed (the execution status of this line is deduced): self = 0;
-
651 QCoreApplicationPrivate::is_app_closing = true;
executed (the execution status of this line is deduced): QCoreApplicationPrivate::is_app_closing = true;
-
652 QCoreApplicationPrivate::is_app_running = false;
executed (the execution status of this line is deduced): QCoreApplicationPrivate::is_app_running = false;
-
653 -
654#if !defined(QT_NO_THREAD) -
655 // Synchronize and stop the global thread pool threads. -
656 QThreadPool *globalThreadPool = 0;
executed (the execution status of this line is deduced): QThreadPool *globalThreadPool = 0;
-
657 QT_TRY { -
658 globalThreadPool = QThreadPool::globalInstance();
executed (the execution status of this line is deduced): globalThreadPool = QThreadPool::globalInstance();
-
659 } QT_CATCH (...) {
executed: }
Execution Count:483
483
660 // swallow the exception, since destructors shouldn't throw -
661 }
never executed: }
0
662 if (globalThreadPool)
partially evaluated: globalThreadPool
TRUEFALSE
yes
Evaluation Count:483
no
Evaluation Count:0
0-483
663 globalThreadPool->waitForDone();
executed: globalThreadPool->waitForDone();
Execution Count:483
483
664#endif -
665 -
666 d_func()->threadData->eventDispatcher = 0;
executed (the execution status of this line is deduced): d_func()->threadData->eventDispatcher = 0;
-
667 if (QCoreApplicationPrivate::eventDispatcher)
evaluated: QCoreApplicationPrivate::eventDispatcher
TRUEFALSE
yes
Evaluation Count:196
yes
Evaluation Count:287
196-287
668 QCoreApplicationPrivate::eventDispatcher->closingDown();
executed: QCoreApplicationPrivate::eventDispatcher->closingDown();
Execution Count:196
196
669 QCoreApplicationPrivate::eventDispatcher = 0;
executed (the execution status of this line is deduced): QCoreApplicationPrivate::eventDispatcher = 0;
-
670 -
671#ifndef QT_NO_LIBRARY -
672 delete coreappdata()->app_libpaths;
executed (the execution status of this line is deduced): delete coreappdata()->app_libpaths;
-
673 coreappdata()->app_libpaths = 0;
executed (the execution status of this line is deduced): coreappdata()->app_libpaths = 0;
-
674#endif -
675}
executed: }
Execution Count:483
483
676 -
677 -
678/*! -
679 Sets the attribute \a attribute if \a on is true; -
680 otherwise clears the attribute. -
681 -
682 One of the attributes that can be set with this method is -
683 Qt::AA_ImmediateWidgetCreation. It tells Qt to create toplevel -
684 windows immediately. Normally, resources for widgets are allocated -
685 on demand to improve efficiency and minimize resource usage. -
686 Therefore, if it is important to minimize resource consumption, do -
687 not set this attribute. -
688 -
689 \sa testAttribute() -
690*/ -
691void QCoreApplication::setAttribute(Qt::ApplicationAttribute attribute, bool on) -
692{ -
693 if (on)
evaluated: on
TRUEFALSE
yes
Evaluation Count:113
yes
Evaluation Count:6
6-113
694 QCoreApplicationPrivate::attribs |= 1 << attribute;
executed: QCoreApplicationPrivate::attribs |= 1 << attribute;
Execution Count:113
113
695 else -
696 QCoreApplicationPrivate::attribs &= ~(1 << attribute);
executed: QCoreApplicationPrivate::attribs &= ~(1 << attribute);
Execution Count:6
6
697} -
698 -
699/*! -
700 Returns true if attribute \a attribute is set; -
701 otherwise returns false. -
702 -
703 \sa setAttribute() -
704 */ -
705bool QCoreApplication::testAttribute(Qt::ApplicationAttribute attribute) -
706{ -
707 return QCoreApplicationPrivate::testAttribute(attribute);
executed: return QCoreApplicationPrivate::testAttribute(attribute);
Execution Count:439800
439800
708} -
709 -
710 -
711/*! -
712 \property QCoreApplication::quitLockEnabled -
713 -
714 Returns true if the use of the QEventLoopLocker feature can cause the -
715 application to quit, otherwise returns false. -
716 -
717 \sa QEventLoopLocker -
718*/ -
719 -
720/*! -
721 Returns true if the use of the QEventLoopLocker feature can cause the -
722 application to quit, otherwise returns false. -
723 -
724 \sa QEventLoopLocker -
725 */ -
726bool QCoreApplication::isQuitLockEnabled() -
727{ -
728 return quitLockRefEnabled;
executed: return quitLockRefEnabled;
Execution Count:12
12
729} -
730 -
731/*! -
732 Enables the ability of the QEventLoopLocker feature to quit -
733 the application. -
734 -
735 If disabled, the use of QEventLoopLocker will not quit the application. -
736 -
737 \sa QEventLoopLocker -
738 */ -
739void QCoreApplication::setQuitLockEnabled(bool enabled) -
740{ -
741 quitLockRefEnabled = enabled;
never executed (the execution status of this line is deduced): quitLockRefEnabled = enabled;
-
742}
never executed: }
0
743 -
744/*! -
745 \internal -
746 -
747 This function is here to make it possible for Qt extensions to -
748 hook into event notification without subclassing QApplication -
749*/ -
750bool QCoreApplication::notifyInternal(QObject *receiver, QEvent *event) -
751{ -
752 // Make it possible for Qt Script to hook into events even -
753 // though QApplication is subclassed... -
754 bool result = false;
executed (the execution status of this line is deduced): bool result = false;
-
755 void *cbdata[] = { receiver, event, &result };
executed (the execution status of this line is deduced): void *cbdata[] = { receiver, event, &result };
-
756 if (QInternal::activateCallbacks(QInternal::EventNotifyCallback, cbdata)) {
partially evaluated: QInternal::activateCallbacks(QInternal::EventNotifyCallback, cbdata)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1194751
0-1194751
757 return result;
never executed: return result;
0
758 } -
759 -
760 // Qt enforces the rule that events can only be sent to objects in -
761 // the current thread, so receiver->d_func()->threadData is -
762 // equivalent to QThreadData::current(), just without the function -
763 // call overhead. -
764 QObjectPrivate *d = receiver->d_func();
executed (the execution status of this line is deduced): QObjectPrivate *d = receiver->d_func();
-
765 QThreadData *threadData = d->threadData;
executed (the execution status of this line is deduced): QThreadData *threadData = d->threadData;
-
766 QScopedLoopLevelCounter loopLevelCounter(threadData);
executed (the execution status of this line is deduced): QScopedLoopLevelCounter loopLevelCounter(threadData);
-
767 return notify(receiver, event);
executed: return notify(receiver, event);
Execution Count:1194737
1194737
768} -
769 -
770 -
771/*! -
772 Sends \a event to \a receiver: \a {receiver}->event(\a event). -
773 Returns the value that is returned from the receiver's event -
774 handler. Note that this function is called for all events sent to -
775 any object in any thread. -
776 -
777 For certain types of events (e.g. mouse and key events), -
778 the event will be propagated to the receiver's parent and so on up to -
779 the top-level object if the receiver is not interested in the event -
780 (i.e., it returns false). -
781 -
782 There are five different ways that events can be processed; -
783 reimplementing this virtual function is just one of them. All five -
784 approaches are listed below: -
785 \list 1 -
786 \li Reimplementing paintEvent(), mousePressEvent() and so -
787 on. This is the commonest, easiest and least powerful way. -
788 -
789 \li Reimplementing this function. This is very powerful, providing -
790 complete control; but only one subclass can be active at a time. -
791 -
792 \li Installing an event filter on QCoreApplication::instance(). Such -
793 an event filter is able to process all events for all widgets, so -
794 it's just as powerful as reimplementing notify(); furthermore, it's -
795 possible to have more than one application-global event filter. -
796 Global event filters even see mouse events for -
797 \l{QWidget::isEnabled()}{disabled widgets}. Note that application -
798 event filters are only called for objects that live in the main -
799 thread. -
800 -
801 \li Reimplementing QObject::event() (as QWidget does). If you do -
802 this you get Tab key presses, and you get to see the events before -
803 any widget-specific event filters. -
804 -
805 \li Installing an event filter on the object. Such an event filter gets all -
806 the events, including Tab and Shift+Tab key press events, as long as they -
807 do not change the focus widget. -
808 \endlist -
809 -
810 \sa QObject::event(), installNativeEventFilter() -
811*/ -
812 -
813bool QCoreApplication::notify(QObject *receiver, QEvent *event) -
814{ -
815 Q_D(QCoreApplication);
executed (the execution status of this line is deduced): QCoreApplicationPrivate * const d = d_func();
-
816 // no events are delivered after ~QCoreApplication() has started -
817 if (QCoreApplicationPrivate::is_app_closing)
evaluated: QCoreApplicationPrivate::is_app_closing
TRUEFALSE
yes
Evaluation Count:213
yes
Evaluation Count:495119
213-495119
818 return true;
executed: return true;
Execution Count:213
213
819 -
820 if (receiver == 0) { // serious error
partially evaluated: receiver == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:495119
0-495119
821 qWarning("QCoreApplication::notify: Unexpected null receiver");
never executed (the execution status of this line is deduced): QMessageLogger("kernel/qcoreapplication.cpp", 821, __PRETTY_FUNCTION__).warning("QCoreApplication::notify: Unexpected null receiver");
-
822 return true;
never executed: return true;
0
823 } -
824 -
825#ifndef QT_NO_DEBUG -
826 d->checkReceiverThread(receiver); -
827#endif -
828 -
829 return receiver->isWidgetType() ? false : d->notify_helper(receiver, event);
executed: return receiver->isWidgetType() ? false : d->notify_helper(receiver, event);
Execution Count:495116
495116
830} -
831 -
832bool QCoreApplicationPrivate::sendThroughApplicationEventFilters(QObject *receiver, QEvent *event) -
833{ -
834 if (receiver->d_func()->threadData == this->threadData && extraData) {
evaluated: receiver->d_func()->threadData == this->threadData
TRUEFALSE
yes
Evaluation Count:1116668
yes
Evaluation Count:101235
evaluated: extraData
TRUEFALSE
yes
Evaluation Count:125924
yes
Evaluation Count:990744
101235-1116668
835 // application event filters are only called for objects in the GUI thread -
836 for (int i = 0; i < extraData->eventFilters.size(); ++i) {
evaluated: i < extraData->eventFilters.size()
TRUEFALSE
yes
Evaluation Count:155610
yes
Evaluation Count:125909
125909-155610
837 register QObject *obj = extraData->eventFilters.at(i);
executed (the execution status of this line is deduced): register QObject *obj = extraData->eventFilters.at(i);
-
838 if (!obj)
evaluated: !obj
TRUEFALSE
yes
Evaluation Count:29818
yes
Evaluation Count:125792
29818-125792
839 continue;
executed: continue;
Execution Count:29818
29818
840 if (obj->d_func()->threadData != threadData) {
partially evaluated: obj->d_func()->threadData != threadData
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:125792
0-125792
841 qWarning("QCoreApplication: Application event filter cannot be in a different thread.");
never executed (the execution status of this line is deduced): QMessageLogger("kernel/qcoreapplication.cpp", 841, __PRETTY_FUNCTION__).warning("QCoreApplication: Application event filter cannot be in a different thread.");
-
842 continue;
never executed: continue;
0
843 } -
844 if (obj->eventFilter(receiver, event))
evaluated: obj->eventFilter(receiver, event)
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:125777
15-125777
845 return true;
executed: return true;
Execution Count:15
15
846 }
executed: }
Execution Count:125777
125777
847 }
executed: }
Execution Count:125909
125909
848 return false;
executed: return false;
Execution Count:1217818
1217818
849} -
850 -
851bool QCoreApplicationPrivate::sendThroughObjectEventFilters(QObject *receiver, QEvent *event) -
852{ -
853 Q_Q(QCoreApplication);
executed (the execution status of this line is deduced): QCoreApplication * const q = q_func();
-
854 if (receiver != q && receiver->d_func()->extraData) {
evaluated: receiver != q
TRUEFALSE
yes
Evaluation Count:1215503
yes
Evaluation Count:2309
evaluated: receiver->d_func()->extraData
TRUEFALSE
yes
Evaluation Count:374701
yes
Evaluation Count:840836
2309-1215503
855 for (int i = 0; i < receiver->d_func()->extraData->eventFilters.size(); ++i) {
evaluated: i < receiver->d_func()->extraData->eventFilters.size()
TRUEFALSE
yes
Evaluation Count:147738
yes
Evaluation Count:354035
147738-354035
856 register QObject *obj = receiver->d_func()->extraData->eventFilters.at(i);
executed (the execution status of this line is deduced): register QObject *obj = receiver->d_func()->extraData->eventFilters.at(i);
-
857 if (!obj)
evaluated: !obj
TRUEFALSE
yes
Evaluation Count:10469
yes
Evaluation Count:137269
10469-137269
858 continue;
executed: continue;
Execution Count:10469
10469
859 if (obj->d_func()->threadData != receiver->d_func()->threadData) {
evaluated: obj->d_func()->threadData != receiver->d_func()->threadData
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:137268
1-137268
860 qWarning("QCoreApplication: Object event filter cannot be in a different thread.");
executed (the execution status of this line is deduced): QMessageLogger("kernel/qcoreapplication.cpp", 860, __PRETTY_FUNCTION__).warning("QCoreApplication: Object event filter cannot be in a different thread.");
-
861 continue;
executed: continue;
Execution Count:1
1
862 } -
863 if (obj->eventFilter(receiver, event))
evaluated: obj->eventFilter(receiver, event)
TRUEFALSE
yes
Evaluation Count:20666
yes
Evaluation Count:116602
20666-116602
864 return true;
executed: return true;
Execution Count:20666
20666
865 }
executed: }
Execution Count:116602
116602
866 }
executed: }
Execution Count:354035
354035
867 return false;
executed: return false;
Execution Count:1197163
1197163
868} -
869 -
870/*! -
871 \internal -
872 -
873 Helper function called by notify() -
874 */ -
875bool QCoreApplicationPrivate::notify_helper(QObject *receiver, QEvent * event) -
876{ -
877 // send to all application event filters -
878 if (sendThroughApplicationEventFilters(receiver, event))
partially evaluated: sendThroughApplicationEventFilters(receiver, event)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:495059
0-495059
879 return true;
never executed: return true;
0
880 // send to all receiver event filters -
881 if (sendThroughObjectEventFilters(receiver, event))
partially evaluated: sendThroughObjectEventFilters(receiver, event)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:495054
0-495054
882 return true;
never executed: return true;
0
883 // deliver the event -
884 return receiver->event(event);
executed: return receiver->event(event);
Execution Count:495062
495062
885} -
886 -
887/*! -
888 Returns true if an application object has not been created yet; -
889 otherwise returns false. -
890 -
891 \sa closingDown() -
892*/ -
893 -
894bool QCoreApplication::startingUp() -
895{ -
896 return !QCoreApplicationPrivate::is_app_running;
executed: return !QCoreApplicationPrivate::is_app_running;
Execution Count:7
7
897} -
898 -
899/*! -
900 Returns true if the application objects are being destroyed; -
901 otherwise returns false. -
902 -
903 \sa startingUp() -
904*/ -
905 -
906bool QCoreApplication::closingDown() -
907{ -
908 return QCoreApplicationPrivate::is_app_closing;
executed: return QCoreApplicationPrivate::is_app_closing;
Execution Count:57087
57087
909} -
910 -
911 -
912/*! -
913 Processes all pending events for the calling thread according to -
914 the specified \a flags until there are no more events to process. -
915 -
916 You can call this function occasionally when your program is busy -
917 performing a long operation (e.g. copying a file). -
918 -
919 In event you are running a local loop which calls this function -
920 continuously, without an event loop, the -
921 \l{QEvent::DeferredDelete}{DeferredDelete} events will -
922 not be processed. This can affect the behaviour of widgets, -
923 e.g. QToolTip, that rely on \l{QEvent::DeferredDelete}{DeferredDelete} -
924 events to function properly. An alternative would be to call -
925 \l{QCoreApplication::sendPostedEvents()}{sendPostedEvents()} from -
926 within that local loop. -
927 -
928 Calling this function processes events only for the calling thread. -
929 -
930 \threadsafe -
931 -
932 \sa exec(), QTimer, QEventLoop::processEvents(), flush(), sendPostedEvents() -
933*/ -
934void QCoreApplication::processEvents(QEventLoop::ProcessEventsFlags flags) -
935{ -
936 QThreadData *data = QThreadData::current();
executed (the execution status of this line is deduced): QThreadData *data = QThreadData::current();
-
937 if (!data->eventDispatcher)
evaluated: !data->eventDispatcher
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:380645
1-380645
938 return;
executed: return;
Execution Count:1
1
939 data->eventDispatcher->processEvents(flags);
executed (the execution status of this line is deduced): data->eventDispatcher->processEvents(flags);
-
940}
executed: }
Execution Count:380645
380645
941 -
942/*! -
943 \overload processEvents() -
944 -
945 Processes pending events for the calling thread for \a maxtime -
946 milliseconds or until there are no more events to process, -
947 whichever is shorter. -
948 -
949 You can call this function occasionally when you program is busy -
950 doing a long operation (e.g. copying a file). -
951 -
952 Calling this function processes events only for the calling thread. -
953 -
954 \threadsafe -
955 -
956 \sa exec(), QTimer, QEventLoop::processEvents() -
957*/ -
958void QCoreApplication::processEvents(QEventLoop::ProcessEventsFlags flags, int maxtime) -
959{ -
960 QThreadData *data = QThreadData::current();
executed (the execution status of this line is deduced): QThreadData *data = QThreadData::current();
-
961 if (!data->eventDispatcher)
partially evaluated: !data->eventDispatcher
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:65070
0-65070
962 return;
never executed: return;
0
963 QElapsedTimer start;
executed (the execution status of this line is deduced): QElapsedTimer start;
-
964 start.start();
executed (the execution status of this line is deduced): start.start();
-
965 while (data->eventDispatcher->processEvents(flags & ~QEventLoop::WaitForMoreEvents)) {
evaluated: data->eventDispatcher->processEvents(flags & ~QEventLoop::WaitForMoreEvents)
TRUEFALSE
yes
Evaluation Count:43356
yes
Evaluation Count:64934
43356-64934
966 if (start.elapsed() > maxtime)
evaluated: start.elapsed() > maxtime
TRUEFALSE
yes
Evaluation Count:57
yes
Evaluation Count:43299
57-43299
967 break;
executed: break;
Execution Count:57
57
968 }
executed: }
Execution Count:43299
43299
969}
executed: }
Execution Count:64986
64986
970 -
971/***************************************************************************** -
972 Main event loop wrappers -
973 *****************************************************************************/ -
974 -
975/*! -
976 Enters the main event loop and waits until exit() is called. -
977 Returns the value that was set to exit() (which is 0 if exit() is -
978 called via quit()). -
979 -
980 It is necessary to call this function to start event handling. The -
981 main event loop receives events from the window system and -
982 dispatches these to the application widgets. -
983 -
984 To make your application perform idle processing (i.e. executing a -
985 special function whenever there are no pending events), use a -
986 QTimer with 0 timeout. More advanced idle processing schemes can -
987 be achieved using processEvents(). -
988 -
989 We recommend that you connect clean-up code to the -
990 \l{QCoreApplication::}{aboutToQuit()} signal, instead of putting it in -
991 your application's \c{main()} function because on some platforms the -
992 QCoreApplication::exec() call may not return. For example, on Windows -
993 when the user logs off, the system terminates the process after Qt -
994 closes all top-level windows. Hence, there is no guarantee that the -
995 application will have time to exit its event loop and execute code at -
996 the end of the \c{main()} function after the QCoreApplication::exec() -
997 call. -
998 -
999 \sa quit(), exit(), processEvents(), QApplication::exec() -
1000*/ -
1001int QCoreApplication::exec() -
1002{ -
1003 if (!QCoreApplicationPrivate::checkInstance("exec"))
partially evaluated: !QCoreApplicationPrivate::checkInstance("exec")
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:66
0-66
1004 return -1;
never executed: return -1;
0
1005 -
1006 QThreadData *threadData = self->d_func()->threadData;
executed (the execution status of this line is deduced): QThreadData *threadData = self->d_func()->threadData;
-
1007 if (threadData != QThreadData::current()) {
partially evaluated: threadData != QThreadData::current()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:66
0-66
1008 qWarning("%s::exec: Must be called from the main thread", self->metaObject()->className());
never executed (the execution status of this line is deduced): QMessageLogger("kernel/qcoreapplication.cpp", 1008, __PRETTY_FUNCTION__).warning("%s::exec: Must be called from the main thread", self->metaObject()->className());
-
1009 return -1;
never executed: return -1;
0
1010 } -
1011 if (!threadData->eventLoops.isEmpty()) {
partially evaluated: !threadData->eventLoops.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:66
0-66
1012 qWarning("QCoreApplication::exec: The event loop is already running");
never executed (the execution status of this line is deduced): QMessageLogger("kernel/qcoreapplication.cpp", 1012, __PRETTY_FUNCTION__).warning("QCoreApplication::exec: The event loop is already running");
-
1013 return -1;
never executed: return -1;
0
1014 } -
1015 -
1016 threadData->quitNow = false;
executed (the execution status of this line is deduced): threadData->quitNow = false;
-
1017 QEventLoop eventLoop;
executed (the execution status of this line is deduced): QEventLoop eventLoop;
-
1018 self->d_func()->in_exec = true;
executed (the execution status of this line is deduced): self->d_func()->in_exec = true;
-
1019 self->d_func()->aboutToQuitEmitted = false;
executed (the execution status of this line is deduced): self->d_func()->aboutToQuitEmitted = false;
-
1020 int returnCode = eventLoop.exec();
executed (the execution status of this line is deduced): int returnCode = eventLoop.exec();
-
1021 threadData->quitNow = false;
executed (the execution status of this line is deduced): threadData->quitNow = false;
-
1022 if (self) {
partially evaluated: self
TRUEFALSE
yes
Evaluation Count:66
no
Evaluation Count:0
0-66
1023 self->d_func()->in_exec = false;
executed (the execution status of this line is deduced): self->d_func()->in_exec = false;
-
1024 if (!self->d_func()->aboutToQuitEmitted)
partially evaluated: !self->d_func()->aboutToQuitEmitted
TRUEFALSE
yes
Evaluation Count:66
no
Evaluation Count:0
0-66
1025 emit self->aboutToQuit(QPrivateSignal());
executed: self->aboutToQuit(QPrivateSignal());
Execution Count:66
66
1026 self->d_func()->aboutToQuitEmitted = true;
executed (the execution status of this line is deduced): self->d_func()->aboutToQuitEmitted = true;
-
1027 sendPostedEvents(0, QEvent::DeferredDelete);
executed (the execution status of this line is deduced): sendPostedEvents(0, QEvent::DeferredDelete);
-
1028 }
executed: }
Execution Count:66
66
1029 -
1030 return returnCode;
executed: return returnCode;
Execution Count:66
66
1031} -
1032 -
1033 -
1034/*! -
1035 Tells the application to exit with a return code. -
1036 -
1037 After this function has been called, the application leaves the -
1038 main event loop and returns from the call to exec(). The exec() -
1039 function returns \a returnCode. If the event loop is not running, -
1040 this function does nothing. -
1041 -
1042 By convention, a \a returnCode of 0 means success, and any non-zero -
1043 value indicates an error. -
1044 -
1045 Note that unlike the C library function of the same name, this -
1046 function \e does return to the caller -- it is event processing that -
1047 stops. -
1048 -
1049 \sa quit(), exec() -
1050*/ -
1051void QCoreApplication::exit(int returnCode) -
1052{ -
1053 if (!self)
partially evaluated: !self
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:70
0-70
1054 return;
never executed: return;
0
1055 QThreadData *data = self->d_func()->threadData;
executed (the execution status of this line is deduced): QThreadData *data = self->d_func()->threadData;
-
1056 data->quitNow = true;
executed (the execution status of this line is deduced): data->quitNow = true;
-
1057 for (int i = 0; i < data->eventLoops.size(); ++i) {
evaluated: i < data->eventLoops.size()
TRUEFALSE
yes
Evaluation Count:72
yes
Evaluation Count:70
70-72
1058 QEventLoop *eventLoop = data->eventLoops.at(i);
executed (the execution status of this line is deduced): QEventLoop *eventLoop = data->eventLoops.at(i);
-
1059 eventLoop->exit(returnCode);
executed (the execution status of this line is deduced): eventLoop->exit(returnCode);
-
1060 }
executed: }
Execution Count:72
72
1061}
executed: }
Execution Count:70
70
1062 -
1063/***************************************************************************** -
1064 QCoreApplication management of posted events -
1065 *****************************************************************************/ -
1066 -
1067/*! -
1068 \fn bool QCoreApplication::sendEvent(QObject *receiver, QEvent *event) -
1069 -
1070 Sends event \a event directly to receiver \a receiver, using the -
1071 notify() function. Returns the value that was returned from the -
1072 event handler. -
1073 -
1074 The event is \e not deleted when the event has been sent. The normal -
1075 approach is to create the event on the stack, for example: -
1076 -
1077 \snippet code/src_corelib_kernel_qcoreapplication.cpp 0 -
1078 -
1079 \sa postEvent(), notify() -
1080*/ -
1081 -
1082/*! -
1083 \since 4.3 -
1084 -
1085 Adds the event \a event, with the object \a receiver as the -
1086 receiver of the event, to an event queue and returns immediately. -
1087 -
1088 The event must be allocated on the heap since the post event queue -
1089 will take ownership of the event and delete it once it has been -
1090 posted. It is \e {not safe} to access the event after -
1091 it has been posted. -
1092 -
1093 When control returns to the main event loop, all events that are -
1094 stored in the queue will be sent using the notify() function. -
1095 -
1096 Events are sorted in descending \a priority order, i.e. events -
1097 with a high \a priority are queued before events with a lower \a -
1098 priority. The \a priority can be any integer value, i.e. between -
1099 INT_MAX and INT_MIN, inclusive; see Qt::EventPriority for more -
1100 details. Events with equal \a priority will be processed in the -
1101 order posted. -
1102 -
1103 \threadsafe -
1104 -
1105 \sa sendEvent(), notify(), sendPostedEvents(), Qt::EventPriority -
1106*/ -
1107void QCoreApplication::postEvent(QObject *receiver, QEvent *event, int priority) -
1108{ -
1109 if (receiver == 0) {
partially evaluated: receiver == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:476518
0-476518
1110 qWarning("QCoreApplication::postEvent: Unexpected null receiver");
never executed (the execution status of this line is deduced): QMessageLogger("kernel/qcoreapplication.cpp", 1110, __PRETTY_FUNCTION__).warning("QCoreApplication::postEvent: Unexpected null receiver");
-
1111 delete event;
never executed (the execution status of this line is deduced): delete event;
-
1112 return;
never executed: return;
0
1113 } -
1114 -
1115 QThreadData * volatile * pdata = &receiver->d_func()->threadData;
executed (the execution status of this line is deduced): QThreadData * volatile * pdata = &receiver->d_func()->threadData;
-
1116 QThreadData *data = *pdata;
executed (the execution status of this line is deduced): QThreadData *data = *pdata;
-
1117 if (!data) {
partially evaluated: !data
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:476518
0-476518
1118 // posting during destruction? just delete the event to prevent a leak -
1119 delete event;
never executed (the execution status of this line is deduced): delete event;
-
1120 return;
never executed: return;
0
1121 } -
1122 -
1123 // lock the post event mutex -
1124 data->postEventList.mutex.lock();
executed (the execution status of this line is deduced): data->postEventList.mutex.lock();
-
1125 -
1126 // if object has moved to another thread, follow it -
1127 while (data != *pdata) {
evaluated: data != *pdata
TRUEFALSE
yes
Evaluation Count:4568
yes
Evaluation Count:476519
4568-476519
1128 data->postEventList.mutex.unlock();
executed (the execution status of this line is deduced): data->postEventList.mutex.unlock();
-
1129 -
1130 data = *pdata;
executed (the execution status of this line is deduced): data = *pdata;
-
1131 if (!data) {
partially evaluated: !data
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4568
0-4568
1132 // posting during destruction? just delete the event to prevent a leak -
1133 delete event;
never executed (the execution status of this line is deduced): delete event;
-
1134 return;
never executed: return;
0
1135 } -
1136 -
1137 data->postEventList.mutex.lock();
executed (the execution status of this line is deduced): data->postEventList.mutex.lock();
-
1138 }
executed: }
Execution Count:4568
4568
1139 -
1140 QMutexUnlocker locker(&data->postEventList.mutex);
executed (the execution status of this line is deduced): QMutexUnlocker locker(&data->postEventList.mutex);
-
1141 -
1142 // if this is one of the compressible events, do compression -
1143 if (receiver->d_func()->postedEvents
evaluated: receiver->d_func()->postedEvents
TRUEFALSE
yes
Evaluation Count:100661
yes
Evaluation Count:375858
100661-375858
1144 && self && self->compressEvent(event, receiver, &data->postEventList)) {
partially evaluated: self
TRUEFALSE
yes
Evaluation Count:100661
no
Evaluation Count:0
evaluated: self->compressEvent(event, receiver, &data->postEventList)
TRUEFALSE
yes
Evaluation Count:8367
yes
Evaluation Count:92294
0-100661
1145 return;
executed: return;
Execution Count:8367
8367
1146 } -
1147 -
1148 if (event->type() == QEvent::DeferredDelete && data == QThreadData::current()) {
evaluated: event->type() == QEvent::DeferredDelete
TRUEFALSE
yes
Evaluation Count:8426
yes
Evaluation Count:459725
evaluated: data == QThreadData::current()
TRUEFALSE
yes
Evaluation Count:7787
yes
Evaluation Count:639
639-459725
1149 // remember the current running eventloop for DeferredDelete -
1150 // events posted in the receiver's thread -
1151 static_cast<QDeferredDeleteEvent *>(event)->level = data->loopLevel;
executed (the execution status of this line is deduced): static_cast<QDeferredDeleteEvent *>(event)->level = data->loopLevel;
-
1152 }
executed: }
Execution Count:7787
7787
1153 -
1154 // delete the event on exceptions to protect against memory leaks till the event is -
1155 // properly owned in the postEventList -
1156 QScopedPointer<QEvent> eventDeleter(event);
executed (the execution status of this line is deduced): QScopedPointer<QEvent> eventDeleter(event);
-
1157 data->postEventList.addEvent(QPostEvent(receiver, event, priority));
executed (the execution status of this line is deduced): data->postEventList.addEvent(QPostEvent(receiver, event, priority));
-
1158 eventDeleter.take();
executed (the execution status of this line is deduced): eventDeleter.take();
-
1159 event->posted = true;
executed (the execution status of this line is deduced): event->posted = true;
-
1160 ++receiver->d_func()->postedEvents;
executed (the execution status of this line is deduced): ++receiver->d_func()->postedEvents;
-
1161 data->canWait = false;
executed (the execution status of this line is deduced): data->canWait = false;
-
1162 locker.unlock();
executed (the execution status of this line is deduced): locker.unlock();
-
1163 -
1164 if (data->eventDispatcher)
evaluated: data->eventDispatcher
TRUEFALSE
yes
Evaluation Count:467574
yes
Evaluation Count:576
576-467574
1165 data->eventDispatcher->wakeUp();
executed: data->eventDispatcher->wakeUp();
Execution Count:467573
467573
1166}
executed: }
Execution Count:468152
468152
1167 -
1168/*! -
1169 \internal -
1170 Returns true if \a event was compressed away (possibly deleted) and should not be added to the list. -
1171*/ -
1172bool QCoreApplication::compressEvent(QEvent *event, QObject *receiver, QPostEventList *postedEvents) -
1173{ -
1174#ifdef Q_OS_WIN -
1175 Q_ASSERT(event); -
1176 Q_ASSERT(receiver); -
1177 Q_ASSERT(postedEvents); -
1178 -
1179 // compress posted timers to this object. -
1180 if (event->type() == QEvent::Timer && receiver->d_func()->postedEvents > 0) { -
1181 int timerId = ((QTimerEvent *) event)->timerId(); -
1182 for (int i=0; i<postedEvents->size(); ++i) { -
1183 const QPostEvent &e = postedEvents->at(i); -
1184 if (e.receiver == receiver && e.event && e.event->type() == QEvent::Timer -
1185 && ((QTimerEvent *) e.event)->timerId() == timerId) { -
1186 delete event; -
1187 return true; -
1188 } -
1189 } -
1190 } else -
1191#endif -
1192 if ((event->type() == QEvent::DeferredDelete
evaluated: event->type() == QEvent::DeferredDelete
TRUEFALSE
yes
Evaluation Count:174
yes
Evaluation Count:75156
174-75156
1193 || event->type() == QEvent::Quit)
partially evaluated: event->type() == QEvent::Quit
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:75156
0-75156
1194 && receiver->d_func()->postedEvents > 0) {
partially evaluated: receiver->d_func()->postedEvents > 0
TRUEFALSE
yes
Evaluation Count:174
no
Evaluation Count:0
0-174
1195 for (int i = 0; i < postedEvents->size(); ++i) {
evaluated: i < postedEvents->size()
TRUEFALSE
yes
Evaluation Count:5813
yes
Evaluation Count:167
167-5813
1196 const QPostEvent &cur = postedEvents->at(i);
executed (the execution status of this line is deduced): const QPostEvent &cur = postedEvents->at(i);
-
1197 if (cur.receiver != receiver
evaluated: cur.receiver != receiver
TRUEFALSE
yes
Evaluation Count:5535
yes
Evaluation Count:278
278-5535
1198 || cur.event == 0
evaluated: cur.event == 0
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:267
11-267
1199 || cur.event->type() != event->type())
evaluated: cur.event->type() != event->type()
TRUEFALSE
yes
Evaluation Count:260
yes
Evaluation Count:7
7-260
1200 continue;
executed: continue;
Execution Count:5806
5806
1201 // found an event for this receiver -
1202 delete event;
executed (the execution status of this line is deduced): delete event;
-
1203 return true;
executed: return true;
Execution Count:7
7
1204 } -
1205 }
executed: }
Execution Count:167
167
1206 return false;
executed: return false;
Execution Count:75323
75323
1207} -
1208 -
1209/*! -
1210 Immediately dispatches all events which have been previously queued -
1211 with QCoreApplication::postEvent() and which are for the object \a receiver -
1212 and have the event type \a event_type. -
1213 -
1214 Events from the window system are \e not dispatched by this -
1215 function, but by processEvents(). -
1216 -
1217 If \a receiver is null, the events of \a event_type are sent for all -
1218 objects. If \a event_type is 0, all the events are sent for \a receiver. -
1219 -
1220 \note This method must be called from the same thread as its QObject parameter, \a receiver. -
1221 -
1222 \sa flush(), postEvent() -
1223*/ -
1224void QCoreApplication::sendPostedEvents(QObject *receiver, int event_type) -
1225{ -
1226 QThreadData *data = QThreadData::current();
executed (the execution status of this line is deduced): QThreadData *data = QThreadData::current();
-
1227 -
1228 QCoreApplicationPrivate::sendPostedEvents(receiver, event_type, data);
executed (the execution status of this line is deduced): QCoreApplicationPrivate::sendPostedEvents(receiver, event_type, data);
-
1229}
executed: }
Execution Count:2119992
2119992
1230 -
1231void QCoreApplicationPrivate::sendPostedEvents(QObject *receiver, int event_type, -
1232 QThreadData *data) -
1233{ -
1234 if (event_type == -1) {
partially evaluated: event_type == -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2119897
0-2119897
1235 // we were called by an obsolete event dispatcher. -
1236 event_type = 0;
never executed (the execution status of this line is deduced): event_type = 0;
-
1237 }
never executed: }
0
1238 -
1239 if (receiver && receiver->d_func()->threadData != data) {
evaluated: receiver
TRUEFALSE
yes
Evaluation Count:1032
yes
Evaluation Count:2118853
partially evaluated: receiver->d_func()->threadData != data
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1032
0-2118853
1240 qWarning("QCoreApplication::sendPostedEvents: Cannot send "
never executed (the execution status of this line is deduced): QMessageLogger("kernel/qcoreapplication.cpp", 1240, __PRETTY_FUNCTION__).warning("QCoreApplication::sendPostedEvents: Cannot send "
-
1241 "posted events for objects in another thread");
never executed (the execution status of this line is deduced): "posted events for objects in another thread");
-
1242 return;
never executed: return;
0
1243 } -
1244 -
1245 ++data->postEventList.recursion;
executed (the execution status of this line is deduced): ++data->postEventList.recursion;
-
1246 -
1247 QMutexLocker locker(&data->postEventList.mutex);
executed (the execution status of this line is deduced): QMutexLocker locker(&data->postEventList.mutex);
-
1248 -
1249 // by default, we assume that the event dispatcher can go to sleep after -
1250 // processing all events. if any new events are posted while we send -
1251 // events, canWait will be set to false. -
1252 data->canWait = (data->postEventList.size() == 0);
executed (the execution status of this line is deduced): data->canWait = (data->postEventList.size() == 0);
-
1253 -
1254 if (data->postEventList.size() == 0 || (receiver && !receiver->d_func()->postedEvents)) {
evaluated: data->postEventList.size() == 0
TRUEFALSE
yes
Evaluation Count:1787245
yes
Evaluation Count:332671
evaluated: receiver
TRUEFALSE
yes
Evaluation Count:1032
yes
Evaluation Count:331642
evaluated: !receiver->d_func()->postedEvents
TRUEFALSE
yes
Evaluation Count:25
yes
Evaluation Count:1007
25-1787245
1255 --data->postEventList.recursion;
executed (the execution status of this line is deduced): --data->postEventList.recursion;
-
1256 return;
executed: return;
Execution Count:1787265
1787265
1257 } -
1258 -
1259 data->canWait = true;
executed (the execution status of this line is deduced): data->canWait = true;
-
1260 -
1261 // okay. here is the tricky loop. be careful about optimizing -
1262 // this, it looks the way it does for good reasons. -
1263 int startOffset = data->postEventList.startOffset;
executed (the execution status of this line is deduced): int startOffset = data->postEventList.startOffset;
-
1264 int &i = (!event_type && !receiver) ? data->postEventList.startOffset : startOffset;
evaluated: !event_type
TRUEFALSE
yes
Evaluation Count:328134
yes
Evaluation Count:4514
evaluated: !receiver
TRUEFALSE
yes
Evaluation Count:328101
yes
Evaluation Count:34
34-328134
1265 data->postEventList.insertionOffset = data->postEventList.size();
executed (the execution status of this line is deduced): data->postEventList.insertionOffset = data->postEventList.size();
-
1266 -
1267 // Exception-safe cleaning up without the need for a try/catch block -
1268 struct CleanUp { -
1269 QObject *receiver; -
1270 int event_type; -
1271 QThreadData *data; -
1272 bool exceptionCaught; -
1273 -
1274 inline CleanUp(QObject *receiver, int event_type, QThreadData *data) : -
1275 receiver(receiver), event_type(event_type), data(data), exceptionCaught(true) -
1276 {}
executed: }
Execution Count:332647
332647
1277 inline ~CleanUp() -
1278 { -
1279 if (exceptionCaught) {
partially evaluated: exceptionCaught
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:332657
0-332657
1280 // since we were interrupted, we need another pass to make sure we clean everything up -
1281 data->canWait = false;
never executed (the execution status of this line is deduced): data->canWait = false;
-
1282 }
never executed: }
0
1283 -
1284 --data->postEventList.recursion;
executed (the execution status of this line is deduced): --data->postEventList.recursion;
-
1285 if (!data->postEventList.recursion && !data->canWait && data->eventDispatcher)
evaluated: !data->postEventList.recursion
TRUEFALSE
yes
Evaluation Count:330814
yes
Evaluation Count:1842
evaluated: !data->canWait
TRUEFALSE
yes
Evaluation Count:42917
yes
Evaluation Count:287906
partially evaluated: data->eventDispatcher
TRUEFALSE
yes
Evaluation Count:42917
no
Evaluation Count:0
0-330814
1286 data->eventDispatcher->wakeUp();
executed: data->eventDispatcher->wakeUp();
Execution Count:42916
42916
1287 -
1288 // clear the global list, i.e. remove everything that was -
1289 // delivered. -
1290 if (!event_type && !receiver && data->postEventList.startOffset >= 0) {
evaluated: !event_type
TRUEFALSE
yes
Evaluation Count:328150
yes
Evaluation Count:4514
evaluated: !receiver
TRUEFALSE
yes
Evaluation Count:328117
yes
Evaluation Count:34
partially evaluated: data->postEventList.startOffset >= 0
TRUEFALSE
yes
Evaluation Count:328117
no
Evaluation Count:0
0-328150
1291 const QPostEventList::iterator it = data->postEventList.begin();
executed (the execution status of this line is deduced): const QPostEventList::iterator it = data->postEventList.begin();
-
1292 data->postEventList.erase(it, it + data->postEventList.startOffset);
executed (the execution status of this line is deduced): data->postEventList.erase(it, it + data->postEventList.startOffset);
-
1293 data->postEventList.insertionOffset -= data->postEventList.startOffset;
executed (the execution status of this line is deduced): data->postEventList.insertionOffset -= data->postEventList.startOffset;
-
1294 Q_ASSERT(data->postEventList.insertionOffset >= 0);
executed (the execution status of this line is deduced): qt_noop();
-
1295 data->postEventList.startOffset = 0;
executed (the execution status of this line is deduced): data->postEventList.startOffset = 0;
-
1296 }
executed: }
Execution Count:328114
328114
1297 }
executed: }
Execution Count:332662
332662
1298 }; -
1299 CleanUp cleanup(receiver, event_type, data); -
1300 -
1301 while (i < data->postEventList.size()) {
evaluated: i < data->postEventList.size()
TRUEFALSE
yes
Evaluation Count:868864
yes
Evaluation Count:289905
289905-868864
1302 // avoid live-lock -
1303 if (i >= data->postEventList.insertionOffset)
evaluated: i >= data->postEventList.insertionOffset
TRUEFALSE
yes
Evaluation Count:42759
yes
Evaluation Count:826190
42759-826190
1304 break;
executed: break;
Execution Count:42758
42758
1305 -
1306 const QPostEvent &pe = data->postEventList.at(i);
executed (the execution status of this line is deduced): const QPostEvent &pe = data->postEventList.at(i);
-
1307 ++i;
executed (the execution status of this line is deduced): ++i;
-
1308 -
1309 if (!pe.event)
evaluated: !pe.event
TRUEFALSE
yes
Evaluation Count:414019
yes
Evaluation Count:412726
412726-414019
1310 continue;
executed: continue;
Execution Count:414037
414037
1311 if ((receiver && receiver != pe.receiver) || (event_type && event_type != pe.event->type())) {
evaluated: receiver
TRUEFALSE
yes
Evaluation Count:8949
yes
Evaluation Count:403775
evaluated: receiver != pe.receiver
TRUEFALSE
yes
Evaluation Count:6653
yes
Evaluation Count:2296
evaluated: event_type
TRUEFALSE
yes
Evaluation Count:2722
yes
Evaluation Count:403351
evaluated: event_type != pe.event->type()
TRUEFALSE
yes
Evaluation Count:1535
yes
Evaluation Count:1187
1187-403775
1312 data->canWait = false;
executed (the execution status of this line is deduced): data->canWait = false;
-
1313 continue;
executed: continue;
Execution Count:8188
8188
1314 } -
1315 -
1316 if (pe.event->type() == QEvent::DeferredDelete) {
evaluated: pe.event->type() == QEvent::DeferredDelete
TRUEFALSE
yes
Evaluation Count:3648
yes
Evaluation Count:400879
3648-400879
1317 // DeferredDelete events are only sent when we are explicitly asked to -
1318 // (s.a. QEvent::DeferredDelete), and then only if the event loop that -
1319 // posted the event has returned. -
1320 int loopLevel = static_cast<QDeferredDeleteEvent *>(pe.event)->loopLevel();
executed (the execution status of this line is deduced): int loopLevel = static_cast<QDeferredDeleteEvent *>(pe.event)->loopLevel();
-
1321 const bool allowDeferredDelete =
executed (the execution status of this line is deduced): const bool allowDeferredDelete =
-
1322 (loopLevel > data->loopLevel
evaluated: loopLevel > data->loopLevel
TRUEFALSE
yes
Evaluation Count:1820
yes
Evaluation Count:1828
1820-1828
1323 || (!loopLevel && data->loopLevel > 0)
evaluated: !loopLevel
TRUEFALSE
yes
Evaluation Count:1810
yes
Evaluation Count:18
evaluated: data->loopLevel > 0
TRUEFALSE
yes
Evaluation Count:663
yes
Evaluation Count:1147
18-1810
1324 || (event_type == QEvent::DeferredDelete
evaluated: event_type == QEvent::DeferredDelete
TRUEFALSE
yes
Evaluation Count:286
yes
Evaluation Count:879
286-879
1325 && loopLevel == data->loopLevel));
evaluated: loopLevel == data->loopLevel
TRUEFALSE
yes
Evaluation Count:285
yes
Evaluation Count:1
1-285
1326 if (!allowDeferredDelete) {
evaluated: !allowDeferredDelete
TRUEFALSE
yes
Evaluation Count:880
yes
Evaluation Count:2768
880-2768
1327 // cannot send deferred delete -
1328 if (!event_type && !receiver) {
evaluated: !event_type
TRUEFALSE
yes
Evaluation Count:879
yes
Evaluation Count:1
partially evaluated: !receiver
TRUEFALSE
yes
Evaluation Count:879
no
Evaluation Count:0
0-879
1329 // we must copy it first; we want to re-post the event -
1330 // with the event pointer intact, but we can't delay -
1331 // nulling the event ptr until after re-posting, as -
1332 // addEvent may invalidate pe. -
1333 QPostEvent pe_copy = pe;
executed (the execution status of this line is deduced): QPostEvent pe_copy = pe;
-
1334 -
1335 // null out the event so if sendPostedEvents recurses, it -
1336 // will ignore this one, as it's been re-posted. -
1337 const_cast<QPostEvent &>(pe).event = 0;
executed (the execution status of this line is deduced): const_cast<QPostEvent &>(pe).event = 0;
-
1338 -
1339 // re-post the copied event so it isn't lost -
1340 data->postEventList.addEvent(pe_copy);
executed (the execution status of this line is deduced): data->postEventList.addEvent(pe_copy);
-
1341 }
executed: }
Execution Count:879
879
1342 continue;
executed: continue;
Execution Count:880
880
1343 } -
1344 }
executed: }
Execution Count:2768
2768
1345 -
1346 // first, we diddle the event so that we can deliver -
1347 // it, and that no one will try to touch it later. -
1348 pe.event->posted = false;
executed (the execution status of this line is deduced): pe.event->posted = false;
-
1349 QScopedPointer<QEvent> e(pe.event);
executed (the execution status of this line is deduced): QScopedPointer<QEvent> e(pe.event);
-
1350 QObject * r = pe.receiver;
executed (the execution status of this line is deduced): QObject * r = pe.receiver;
-
1351 -
1352 --r->d_func()->postedEvents;
executed (the execution status of this line is deduced): --r->d_func()->postedEvents;
-
1353 Q_ASSERT(r->d_func()->postedEvents >= 0);
executed (the execution status of this line is deduced): qt_noop();
-
1354 -
1355 // next, update the data structure so that we're ready -
1356 // for the next event. -
1357 const_cast<QPostEvent &>(pe).event = 0;
executed (the execution status of this line is deduced): const_cast<QPostEvent &>(pe).event = 0;
-
1358 -
1359 struct MutexUnlocker
executed (the execution status of this line is deduced): struct MutexUnlocker
-
1360 {
executed (the execution status of this line is deduced): {
-
1361 QMutexLocker &m;
executed (the execution status of this line is deduced): QMutexLocker &m;
-
1362 MutexUnlocker(QMutexLocker &m) : m(m) { m.unlock(); }
executed: }
Execution Count:403671
403671
1363 ~MutexUnlocker() { m.relock(); }
executed: }
Execution Count:403661
403661
1364 };
executed (the execution status of this line is deduced): };
-
1365 MutexUnlocker unlocker(locker);
executed (the execution status of this line is deduced): MutexUnlocker unlocker(locker);
-
1366 -
1367 // after all that work, it's time to deliver the event. -
1368 QCoreApplication::sendEvent(r, e.data());
executed (the execution status of this line is deduced): QCoreApplication::sendEvent(r, e.data());
-
1369 -
1370 // careful when adding anything below this point - the -
1371 // sendEvent() call might invalidate any invariants this -
1372 // function depends on. -
1373 }
executed: }
Execution Count:403650
403650
1374 -
1375 cleanup.exceptionCaught = false;
executed (the execution status of this line is deduced): cleanup.exceptionCaught = false;
-
1376}
executed: }
Execution Count:332658
332658
1377 -
1378/*! -
1379 \since 4.3 -
1380 -
1381 Removes all events of the given \a eventType that were posted -
1382 using postEvent() for \a receiver. -
1383 -
1384 The events are \e not dispatched, instead they are removed from -
1385 the queue. You should never need to call this function. If you do -
1386 call it, be aware that killing events may cause \a receiver to -
1387 break one or more invariants. -
1388 -
1389 If \a receiver is null, the events of \a eventType are removed for -
1390 all objects. If \a eventType is 0, all the events are removed for -
1391 \a receiver. You should never call this function with \a eventType -
1392 of 0. If you do call it in this way, be aware that killing events -
1393 may cause \a receiver to break one or more invariants. -
1394 -
1395 \threadsafe -
1396*/ -
1397 -
1398void QCoreApplication::removePostedEvents(QObject *receiver, int eventType) -
1399{ -
1400 QThreadData *data = receiver ? receiver->d_func()->threadData : QThreadData::current();
evaluated: receiver
TRUEFALSE
yes
Evaluation Count:55058
yes
Evaluation Count:2
2-55058
1401 QMutexLocker locker(&data->postEventList.mutex);
executed (the execution status of this line is deduced): QMutexLocker locker(&data->postEventList.mutex);
-
1402 -
1403 // the QObject destructor calls this function directly. this can -
1404 // happen while the event loop is in the middle of posting events, -
1405 // and when we get here, we may not have any more posted events -
1406 // for this object. -
1407 if (receiver && !receiver->d_func()->postedEvents)
evaluated: receiver
TRUEFALSE
yes
Evaluation Count:55058
yes
Evaluation Count:2
evaluated: !receiver->d_func()->postedEvents
TRUEFALSE
yes
Evaluation Count:17401
yes
Evaluation Count:37657
2-55058
1408 return;
executed: return;
Execution Count:17401
17401
1409 -
1410 //we will collect all the posted events for the QObject -
1411 //and we'll delete after the mutex was unlocked -
1412 QVarLengthArray<QEvent*> events;
executed (the execution status of this line is deduced): QVarLengthArray<QEvent*> events;
-
1413 int n = data->postEventList.size();
executed (the execution status of this line is deduced): int n = data->postEventList.size();
-
1414 int j = 0;
executed (the execution status of this line is deduced): int j = 0;
-
1415 -
1416 for (int i = 0; i < n; ++i) {
evaluated: i < n
TRUEFALSE
yes
Evaluation Count:1350838
yes
Evaluation Count:37659
37659-1350838
1417 const QPostEvent &pe = data->postEventList.at(i);
executed (the execution status of this line is deduced): const QPostEvent &pe = data->postEventList.at(i);
-
1418 -
1419 if ((!receiver || pe.receiver == receiver)
evaluated: !receiver
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:1350826
evaluated: pe.receiver == receiver
TRUEFALSE
yes
Evaluation Count:58930
yes
Evaluation Count:1291896
12-1350826
1420 && (pe.event && (eventType == 0 || pe.event->type() == eventType))) {
evaluated: pe.event
TRUEFALSE
yes
Evaluation Count:58828
yes
Evaluation Count:114
evaluated: eventType == 0
TRUEFALSE
yes
Evaluation Count:58559
yes
Evaluation Count:269
evaluated: pe.event->type() == eventType
TRUEFALSE
yes
Evaluation Count:155
yes
Evaluation Count:114
114-58828
1421 --pe.receiver->d_func()->postedEvents;
executed (the execution status of this line is deduced): --pe.receiver->d_func()->postedEvents;
-
1422 pe.event->posted = false;
executed (the execution status of this line is deduced): pe.event->posted = false;
-
1423 events.append(pe.event);
executed (the execution status of this line is deduced): events.append(pe.event);
-
1424 const_cast<QPostEvent &>(pe).event = 0;
executed (the execution status of this line is deduced): const_cast<QPostEvent &>(pe).event = 0;
-
1425 } else if (!data->postEventList.recursion) {
executed: }
Execution Count:58714
evaluated: !data->postEventList.recursion
TRUEFALSE
yes
Evaluation Count:1291808
yes
Evaluation Count:316
316-1291808
1426 if (i != j)
evaluated: i != j
TRUEFALSE
yes
Evaluation Count:728310
yes
Evaluation Count:563498
563498-728310
1427 qSwap(data->postEventList[i], data->postEventList[j]);
executed: qSwap(data->postEventList[i], data->postEventList[j]);
Execution Count:728310
728310
1428 ++j;
executed (the execution status of this line is deduced): ++j;
-
1429 }
executed: }
Execution Count:1291808
1291808
1430 } -
1431 -
1432#ifdef QT_DEBUG -
1433 if (receiver && eventType == 0) { -
1434 Q_ASSERT(!receiver->d_func()->postedEvents); -
1435 } -
1436#endif -
1437 -
1438 if (!data->postEventList.recursion) {
evaluated: !data->postEventList.recursion
TRUEFALSE
yes
Evaluation Count:37474
yes
Evaluation Count:185
185-37474
1439 // truncate list -
1440 data->postEventList.erase(data->postEventList.begin() + j, data->postEventList.end());
executed (the execution status of this line is deduced): data->postEventList.erase(data->postEventList.begin() + j, data->postEventList.end());
-
1441 }
executed: }
Execution Count:37474
37474
1442 -
1443 locker.unlock();
executed (the execution status of this line is deduced): locker.unlock();
-
1444 for (int i = 0; i < events.count(); ++i) {
evaluated: i < events.count()
TRUEFALSE
yes
Evaluation Count:58714
yes
Evaluation Count:37659
37659-58714
1445 delete events[i];
executed (the execution status of this line is deduced): delete events[i];
-
1446 }
executed: }
Execution Count:58714
58714
1447}
executed: }
Execution Count:37659
37659
1448 -
1449/*! -
1450 Removes \a event from the queue of posted events, and emits a -
1451 warning message if appropriate. -
1452 -
1453 \warning This function can be \e really slow. Avoid using it, if -
1454 possible. -
1455 -
1456 \threadsafe -
1457*/ -
1458 -
1459void QCoreApplicationPrivate::removePostedEvent(QEvent * event) -
1460{ -
1461 if (!event || !event->posted)
never evaluated: !event
never evaluated: !event->posted
0
1462 return;
never executed: return;
0
1463 -
1464 QThreadData *data = QThreadData::current();
never executed (the execution status of this line is deduced): QThreadData *data = QThreadData::current();
-
1465 -
1466 QMutexLocker locker(&data->postEventList.mutex);
never executed (the execution status of this line is deduced): QMutexLocker locker(&data->postEventList.mutex);
-
1467 -
1468 if (data->postEventList.size() == 0) {
never evaluated: data->postEventList.size() == 0
0
1469#if defined(QT_DEBUG) -
1470 qDebug("QCoreApplication::removePostedEvent: Internal error: %p %d is posted", -
1471 (void*)event, event->type()); -
1472 return; -
1473#endif -
1474 }
never executed: }
0
1475 -
1476 for (int i = 0; i < data->postEventList.size(); ++i) {
never evaluated: i < data->postEventList.size()
0
1477 const QPostEvent & pe = data->postEventList.at(i);
never executed (the execution status of this line is deduced): const QPostEvent & pe = data->postEventList.at(i);
-
1478 if (pe.event == event) {
never evaluated: pe.event == event
0
1479#ifndef QT_NO_DEBUG -
1480 qWarning("QCoreApplication::removePostedEvent: Event of type %d deleted while posted to %s %s", -
1481 event->type(), -
1482 pe.receiver->metaObject()->className(), -
1483 pe.receiver->objectName().toLocal8Bit().data()); -
1484#endif -
1485 --pe.receiver->d_func()->postedEvents;
never executed (the execution status of this line is deduced): --pe.receiver->d_func()->postedEvents;
-
1486 pe.event->posted = false;
never executed (the execution status of this line is deduced): pe.event->posted = false;
-
1487 delete pe.event;
never executed (the execution status of this line is deduced): delete pe.event;
-
1488 const_cast<QPostEvent &>(pe).event = 0;
never executed (the execution status of this line is deduced): const_cast<QPostEvent &>(pe).event = 0;
-
1489 return;
never executed: return;
0
1490 } -
1491 }
never executed: }
0
1492}
never executed: }
0
1493 -
1494/*!\reimp -
1495 -
1496*/ -
1497bool QCoreApplication::event(QEvent *e) -
1498{ -
1499 if (e->type() == QEvent::Quit) {
evaluated: e->type() == QEvent::Quit
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:2296
13-2296
1500 quit();
executed (the execution status of this line is deduced): quit();
-
1501 return true;
executed: return true;
Execution Count:13
13
1502 } -
1503 return QObject::event(e);
executed: return QObject::event(e);
Execution Count:2296
2296
1504} -
1505 -
1506/*! \enum QCoreApplication::Encoding -
1507 \obsolete -
1508 -
1509 This enum type used to define the 8-bit encoding of character string -
1510 arguments to translate(). This enum is now obsolete and UTF-8 will be -
1511 used in all cases. -
1512 -
1513 \value UnicodeUTF8 UTF-8. -
1514 \omitvalue Latin1 -
1515 \omitvalue DefaultCodec UTF-8. -
1516 \omitvalue CodecForTr -
1517 -
1518 \sa QObject::tr(), QString::fromUtf8() -
1519*/ -
1520 -
1521void QCoreApplicationPrivate::ref() -
1522{ -
1523 quitLockRef.ref();
executed (the execution status of this line is deduced): quitLockRef.ref();
-
1524}
executed: }
Execution Count:6
6
1525 -
1526void QCoreApplicationPrivate::deref() -
1527{ -
1528 if (!quitLockRef.deref())
evaluated: !quitLockRef.deref()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:5
1-5
1529 maybeQuit();
executed: maybeQuit();
Execution Count:1
1
1530}
executed: }
Execution Count:6
6
1531 -
1532void QCoreApplicationPrivate::maybeQuit() -
1533{ -
1534 if (quitLockRef.load() == 0 && in_exec && quitLockRefEnabled && shouldQuit())
partially evaluated: quitLockRef.load() == 0
TRUEFALSE
yes
Evaluation Count:1775
no
Evaluation Count:0
evaluated: in_exec
TRUEFALSE
yes
Evaluation Count:19
yes
Evaluation Count:1756
partially evaluated: quitLockRefEnabled
TRUEFALSE
yes
Evaluation Count:19
no
Evaluation Count:0
evaluated: shouldQuit()
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:2
0-1775
1535 QCoreApplication::postEvent(QCoreApplication::instance(), new QEvent(QEvent::Quit));
executed: QCoreApplication::postEvent(QCoreApplication::instance(), new QEvent(QEvent::Quit));
Execution Count:17
17
1536}
executed: }
Execution Count:1775
1775
1537 -
1538/*! -
1539 Tells the application to exit with return code 0 (success). -
1540 Equivalent to calling QCoreApplication::exit(0). -
1541 -
1542 It's common to connect the QApplication::lastWindowClosed() signal -
1543 to quit(), and you also often connect e.g. QAbstractButton::clicked() or -
1544 signals in QAction, QMenu, or QMenuBar to it. -
1545 -
1546 Example: -
1547 -
1548 \snippet code/src_corelib_kernel_qcoreapplication.cpp 1 -
1549 -
1550 \sa exit(), aboutToQuit(), QApplication::lastWindowClosed() -
1551*/ -
1552 -
1553void QCoreApplication::quit() -
1554{ -
1555 exit(0);
executed: exit(0);
Execution Count:64
64
1556} -
1557 -
1558/*! -
1559 \fn void QCoreApplication::aboutToQuit() -
1560 -
1561 This signal is emitted when the application is about to quit the -
1562 main event loop, e.g. when the event loop level drops to zero. -
1563 This may happen either after a call to quit() from inside the -
1564 application or when the users shuts down the entire desktop session. -
1565 -
1566 The signal is particularly useful if your application has to do some -
1567 last-second cleanup. Note that no user interaction is possible in -
1568 this state. -
1569 -
1570 \sa quit() -
1571*/ -
1572 -
1573#ifndef QT_NO_TRANSLATION -
1574/*! -
1575 Adds the translation file \a translationFile to the list of -
1576 translation files to be used for translations. -
1577 -
1578 Multiple translation files can be installed. Translations are -
1579 searched for in the reverse order in which they were installed, -
1580 so the most recently installed translation file is searched first -
1581 and the first translation file installed is searched last. -
1582 The search stops as soon as a translation containing a matching -
1583 string is found. -
1584 -
1585 Installing or removing a QTranslator, or changing an installed QTranslator -
1586 generates a \l{QEvent::LanguageChange}{LanguageChange} event for the -
1587 QCoreApplication instance. A QApplication instance will propagate the event -
1588 to all toplevel windows, where a reimplementation of changeEvent can -
1589 re-translate the user interface by passing user-visible strings via the -
1590 tr() function to the respective property setters. User-interface classes -
1591 generated by Qt Designer provide a \c retranslateUi() function that can be -
1592 called. -
1593 -
1594 The function returns true on success and false on failure. -
1595 -
1596 \sa removeTranslator(), translate(), QTranslator::load(), {Dynamic Translation} -
1597*/ -
1598 -
1599bool QCoreApplication::installTranslator(QTranslator *translationFile) -
1600{ -
1601 if (!translationFile)
partially evaluated: !translationFile
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:31
0-31
1602 return false;
never executed: return false;
0
1603 -
1604 if (!QCoreApplicationPrivate::checkInstance("installTranslator"))
partially evaluated: !QCoreApplicationPrivate::checkInstance("installTranslator")
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:31
0-31
1605 return false;
never executed: return false;
0
1606 QCoreApplicationPrivate *d = self->d_func();
executed (the execution status of this line is deduced): QCoreApplicationPrivate *d = self->d_func();
-
1607 d->translators.prepend(translationFile);
executed (the execution status of this line is deduced): d->translators.prepend(translationFile);
-
1608 -
1609#ifndef QT_NO_TRANSLATION_BUILDER -
1610 if (translationFile->isEmpty())
evaluated: translationFile->isEmpty()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:30
1-30
1611 return false;
executed: return false;
Execution Count:1
1
1612#endif -
1613 -
1614 QEvent ev(QEvent::LanguageChange);
executed (the execution status of this line is deduced): QEvent ev(QEvent::LanguageChange);
-
1615 QCoreApplication::sendEvent(self, &ev);
executed (the execution status of this line is deduced): QCoreApplication::sendEvent(self, &ev);
-
1616 return true;
executed: return true;
Execution Count:30
30
1617} -
1618 -
1619/*! -
1620 Removes the translation file \a translationFile from the list of -
1621 translation files used by this application. (It does not delete the -
1622 translation file from the file system.) -
1623 -
1624 The function returns true on success and false on failure. -
1625 -
1626 \sa installTranslator(), translate(), QObject::tr() -
1627*/ -
1628 -
1629bool QCoreApplication::removeTranslator(QTranslator *translationFile) -
1630{ -
1631 if (!translationFile)
partially evaluated: !translationFile
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:42
0-42
1632 return false;
never executed: return false;
0
1633 if (!QCoreApplicationPrivate::checkInstance("removeTranslator"))
partially evaluated: !QCoreApplicationPrivate::checkInstance("removeTranslator")
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:42
0-42
1634 return false;
never executed: return false;
0
1635 QCoreApplicationPrivate *d = self->d_func();
executed (the execution status of this line is deduced): QCoreApplicationPrivate *d = self->d_func();
-
1636 if (d->translators.removeAll(translationFile)) {
evaluated: d->translators.removeAll(translationFile)
TRUEFALSE
yes
Evaluation Count:31
yes
Evaluation Count:11
11-31
1637 if (!self->closingDown()) {
partially evaluated: !self->closingDown()
TRUEFALSE
yes
Evaluation Count:31
no
Evaluation Count:0
0-31
1638 QEvent ev(QEvent::LanguageChange);
executed (the execution status of this line is deduced): QEvent ev(QEvent::LanguageChange);
-
1639 QCoreApplication::sendEvent(self, &ev);
executed (the execution status of this line is deduced): QCoreApplication::sendEvent(self, &ev);
-
1640 }
executed: }
Execution Count:31
31
1641 return true;
executed: return true;
Execution Count:31
31
1642 } -
1643 return false;
executed: return false;
Execution Count:11
11
1644} -
1645 -
1646static void replacePercentN(QString *result, int n) -
1647{ -
1648 if (n >= 0) {
evaluated: n >= 0
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:315117
6-315117
1649 int percentPos = 0;
executed (the execution status of this line is deduced): int percentPos = 0;
-
1650 int len = 0;
executed (the execution status of this line is deduced): int len = 0;
-
1651 while ((percentPos = result->indexOf(QLatin1Char('%'), percentPos + len)) != -1) {
evaluated: (percentPos = result->indexOf(QLatin1Char('%'), percentPos + len)) != -1
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:6
6
1652 len = 1;
executed (the execution status of this line is deduced): len = 1;
-
1653 QString fmt;
executed (the execution status of this line is deduced): QString fmt;
-
1654 if (result->at(percentPos + len) == QLatin1Char('L')) {
partially evaluated: result->at(percentPos + len) == QLatin1Char('L')
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
0-6
1655 ++len;
never executed (the execution status of this line is deduced): ++len;
-
1656 fmt = QLatin1String("%L1");
never executed (the execution status of this line is deduced): fmt = QLatin1String("%L1");
-
1657 } else {
never executed: }
0
1658 fmt = QLatin1String("%1");
executed (the execution status of this line is deduced): fmt = QLatin1String("%1");
-
1659 }
executed: }
Execution Count:6
6
1660 if (result->at(percentPos + len) == QLatin1Char('n')) {
partially evaluated: result->at(percentPos + len) == QLatin1Char('n')
TRUEFALSE
yes
Evaluation Count:6
no
Evaluation Count:0
0-6
1661 fmt = fmt.arg(n);
executed (the execution status of this line is deduced): fmt = fmt.arg(n);
-
1662 ++len;
executed (the execution status of this line is deduced): ++len;
-
1663 result->replace(percentPos, len, fmt);
executed (the execution status of this line is deduced): result->replace(percentPos, len, fmt);
-
1664 len = fmt.length();
executed (the execution status of this line is deduced): len = fmt.length();
-
1665 }
executed: }
Execution Count:6
6
1666 }
executed: }
Execution Count:6
6
1667 }
executed: }
Execution Count:6
6
1668}
executed: }
Execution Count:315123
315123
1669 -
1670/*! -
1671 \reentrant -
1672 -
1673 Returns the translation text for \a sourceText, by querying the -
1674 installed translation files. The translation files are searched -
1675 from the most recently installed file back to the first -
1676 installed file. -
1677 -
1678 QObject::tr() provides this functionality more conveniently. -
1679 -
1680 \a context is typically a class name (e.g., "MyDialog") and \a -
1681 sourceText is either English text or a short identifying text. -
1682 -
1683 \a disambiguation is an identifying string, for when the same \a -
1684 sourceText is used in different roles within the same context. By -
1685 default, it is null. -
1686 -
1687 See the \l QTranslator and \l QObject::tr() documentation for -
1688 more information about contexts, disambiguations and comments. -
1689 -
1690 \a n is used in conjunction with \c %n to support plural forms. -
1691 See QObject::tr() for details. -
1692 -
1693 If none of the translation files contain a translation for \a -
1694 sourceText in \a context, this function returns a QString -
1695 equivalent of \a sourceText. -
1696 -
1697 This function is not virtual. You can use alternative translation -
1698 techniques by subclassing \l QTranslator. -
1699 -
1700 \warning This method is reentrant only if all translators are -
1701 installed \e before calling this method. Installing or removing -
1702 translators while performing translations is not supported. Doing -
1703 so will most likely result in crashes or other undesirable -
1704 behavior. -
1705 -
1706 \sa QObject::tr(), installTranslator() -
1707*/ -
1708QString QCoreApplication::translate(const char *context, const char *sourceText, -
1709 const char *disambiguation, int n) -
1710{ -
1711 QString result;
executed (the execution status of this line is deduced): QString result;
-
1712 -
1713 if (!sourceText)
evaluated: !sourceText
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:315123
4-315123
1714 return result;
executed: return result;
Execution Count:4
4
1715 -
1716 if (self && !self->d_func()->translators.isEmpty()) {
evaluated: self
TRUEFALSE
yes
Evaluation Count:315111
yes
Evaluation Count:12
evaluated: !self->d_func()->translators.isEmpty()
TRUEFALSE
yes
Evaluation Count:183
yes
Evaluation Count:314928
12-315111
1717 QList<QTranslator*>::ConstIterator it;
executed (the execution status of this line is deduced): QList<QTranslator*>::ConstIterator it;
-
1718 QTranslator *translationFile;
executed (the execution status of this line is deduced): QTranslator *translationFile;
-
1719 for (it = self->d_func()->translators.constBegin(); it != self->d_func()->translators.constEnd(); ++it) {
evaluated: it != self->d_func()->translators.constEnd()
TRUEFALSE
yes
Evaluation Count:208
yes
Evaluation Count:46
46-208
1720 translationFile = *it;
executed (the execution status of this line is deduced): translationFile = *it;
-
1721 result = translationFile->translate(context, sourceText, disambiguation, n);
executed (the execution status of this line is deduced): result = translationFile->translate(context, sourceText, disambiguation, n);
-
1722 if (!result.isNull())
evaluated: !result.isNull()
TRUEFALSE
yes
Evaluation Count:137
yes
Evaluation Count:71
71-137
1723 break;
executed: break;
Execution Count:137
137
1724 }
executed: }
Execution Count:71
71
1725 }
executed: }
Execution Count:183
183
1726 -
1727 if (result.isNull())
evaluated: result.isNull()
TRUEFALSE
yes
Evaluation Count:314986
yes
Evaluation Count:137
137-314986
1728 result = QString::fromUtf8(sourceText);
executed: result = QString::fromUtf8(sourceText);
Execution Count:314986
314986
1729 -
1730 replacePercentN(&result, n);
executed (the execution status of this line is deduced): replacePercentN(&result, n);
-
1731 return result;
executed: return result;
Execution Count:315123
315123
1732} -
1733 -
1734/*! \fn static QString QCoreApplication::translate(const char *context, const char *key, const char *disambiguation, Encoding encoding, int n = -1) -
1735 -
1736 \obsolete -
1737*/ -
1738 -
1739// Declared in qglobal.h -
1740QString qtTrId(const char *id, int n) -
1741{ -
1742 return QCoreApplication::translate(0, id, 0, n);
never executed: return QCoreApplication::translate(0, id, 0, n);
0
1743} -
1744 -
1745bool QCoreApplicationPrivate::isTranslatorInstalled(QTranslator *translator) -
1746{ -
1747 return QCoreApplication::self
executed: return QCoreApplication::self && QCoreApplication::self->d_func()->translators.contains(translator);
Execution Count:34
34
1748 && QCoreApplication::self->d_func()->translators.contains(translator);
executed: return QCoreApplication::self && QCoreApplication::self->d_func()->translators.contains(translator);
Execution Count:34
34
1749} -
1750 -
1751#endif //QT_NO_TRANSLATE -
1752 -
1753/*! -
1754 Returns the directory that contains the application executable. -
1755 -
1756 For example, if you have installed Qt in the \c{C:\Qt} -
1757 directory, and you run the \c{regexp} example, this function will -
1758 return "C:/Qt/examples/tools/regexp". -
1759 -
1760 On Mac OS X this will point to the directory actually containing the -
1761 executable, which may be inside of an application bundle (if the -
1762 application is bundled). -
1763 -
1764 \warning On Linux, this function will try to get the path from the -
1765 \c {/proc} file system. If that fails, it assumes that \c -
1766 {argv[0]} contains the absolute file name of the executable. The -
1767 function also assumes that the current directory has not been -
1768 changed by the application. -
1769 -
1770 \sa applicationFilePath() -
1771*/ -
1772QString QCoreApplication::applicationDirPath() -
1773{ -
1774 if (!self) {
partially evaluated: !self
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:521
0-521
1775 qWarning("QCoreApplication::applicationDirPath: Please instantiate the QApplication object first");
never executed (the execution status of this line is deduced): QMessageLogger("kernel/qcoreapplication.cpp", 1775, __PRETTY_FUNCTION__).warning("QCoreApplication::applicationDirPath: Please instantiate the QApplication object first");
-
1776 return QString();
never executed: return QString();
0
1777 } -
1778 -
1779 QCoreApplicationPrivate *d = self->d_func();
executed (the execution status of this line is deduced): QCoreApplicationPrivate *d = self->d_func();
-
1780 if (d->cachedApplicationDirPath.isNull())
evaluated: d->cachedApplicationDirPath.isNull()
TRUEFALSE
yes
Evaluation Count:60
yes
Evaluation Count:461
60-461
1781 d->cachedApplicationDirPath = QFileInfo(applicationFilePath()).path();
executed: d->cachedApplicationDirPath = QFileInfo(applicationFilePath()).path();
Execution Count:60
60
1782 return d->cachedApplicationDirPath;
executed: return d->cachedApplicationDirPath;
Execution Count:521
521
1783} -
1784 -
1785/*! -
1786 Returns the file path of the application executable. -
1787 -
1788 For example, if you have installed Qt in the \c{/usr/local/qt} -
1789 directory, and you run the \c{regexp} example, this function will -
1790 return "/usr/local/qt/examples/tools/regexp/regexp". -
1791 -
1792 \warning On Linux, this function will try to get the path from the -
1793 \c {/proc} file system. If that fails, it assumes that \c -
1794 {argv[0]} contains the absolute file name of the executable. The -
1795 function also assumes that the current directory has not been -
1796 changed by the application. -
1797 -
1798 \sa applicationDirPath() -
1799*/ -
1800QString QCoreApplication::applicationFilePath() -
1801{ -
1802 if (!self) {
partially evaluated: !self
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:98
0-98
1803 qWarning("QCoreApplication::applicationFilePath: Please instantiate the QApplication object first");
never executed (the execution status of this line is deduced): QMessageLogger("kernel/qcoreapplication.cpp", 1803, __PRETTY_FUNCTION__).warning("QCoreApplication::applicationFilePath: Please instantiate the QApplication object first");
-
1804 return QString();
never executed: return QString();
0
1805 } -
1806 -
1807 QCoreApplicationPrivate *d = self->d_func();
executed (the execution status of this line is deduced): QCoreApplicationPrivate *d = self->d_func();
-
1808 if (!d->cachedApplicationFilePath.isNull())
evaluated: !d->cachedApplicationFilePath.isNull()
TRUEFALSE
yes
Evaluation Count:35
yes
Evaluation Count:63
35-63
1809 return d->cachedApplicationFilePath;
executed: return d->cachedApplicationFilePath;
Execution Count:35
35
1810 -
1811#if defined(Q_OS_WIN) -
1812 d->cachedApplicationFilePath = QFileInfo(qAppFileName()).filePath(); -
1813 return d->cachedApplicationFilePath; -
1814#elif defined(Q_OS_BLACKBERRY) -
1815 if (!arguments().isEmpty()) { // args is never empty, but the navigator can change behaviour some day -
1816 QFileInfo fileInfo(arguments().at(0)); -
1817 const bool zygotized = fileInfo.exists(); -
1818 if (zygotized) { -
1819 // Handle the zygotized case: -
1820 d->cachedApplicationFilePath = QDir::cleanPath(fileInfo.absoluteFilePath()); -
1821 return d->cachedApplicationFilePath; -
1822 } -
1823 } -
1824 -
1825 // Handle the non-zygotized case: -
1826 const size_t maximum_path = static_cast<size_t>(pathconf("/",_PC_PATH_MAX)); -
1827 char buff[maximum_path+1]; -
1828 if (_cmdname(buff)) { -
1829 d->cachedApplicationFilePath = QDir::cleanPath(QString::fromLocal8Bit(buff)); -
1830 return d->cachedApplicationFilePath; -
1831 } else { -
1832 qWarning("QCoreApplication::applicationFilePath: _cmdname() failed"); -
1833 // _cmdname() won't fail, but just in case, fallback to the old method -
1834 QDir dir(QStringLiteral("./app/native/")); -
1835 QStringList executables = dir.entryList(QDir::Executable | QDir::Files); -
1836 if (!executables.empty()) { -
1837 //We assume that there is only one executable in the folder -
1838 d->cachedApplicationFilePath = dir.absoluteFilePath(executables.first()); -
1839 return d->cachedApplicationFilePath; -
1840 } else { -
1841 return QString(); -
1842 } -
1843 } -
1844#elif defined(Q_OS_MAC) -
1845 QString qAppFileName_str = qAppFileName(); -
1846 if(!qAppFileName_str.isEmpty()) { -
1847 QFileInfo fi(qAppFileName_str); -
1848 d->cachedApplicationFilePath = fi.exists() ? fi.canonicalFilePath() : QString(); -
1849 return d->cachedApplicationFilePath; -
1850 } -
1851#endif -
1852#if defined( Q_OS_UNIX ) -
1853# ifdef Q_OS_LINUX -
1854 // Try looking for a /proc/<pid>/exe symlink first which points to -
1855 // the absolute path of the executable -
1856 QFileInfo pfi(QString::fromLatin1("/proc/%1/exe").arg(getpid()));
executed (the execution status of this line is deduced): QFileInfo pfi(QString::fromLatin1("/proc/%1/exe").arg(getpid()));
-
1857 if (pfi.exists() && pfi.isSymLink()) {
partially evaluated: pfi.exists()
TRUEFALSE
yes
Evaluation Count:63
no
Evaluation Count:0
partially evaluated: pfi.isSymLink()
TRUEFALSE
yes
Evaluation Count:63
no
Evaluation Count:0
0-63
1858 d->cachedApplicationFilePath = pfi.canonicalFilePath();
executed (the execution status of this line is deduced): d->cachedApplicationFilePath = pfi.canonicalFilePath();
-
1859 return d->cachedApplicationFilePath;
executed: return d->cachedApplicationFilePath;
Execution Count:63
63
1860 } -
1861# endif -
1862 -
1863 QString argv0 = QFile::decodeName(arguments().at(0).toLocal8Bit());
never executed (the execution status of this line is deduced): QString argv0 = QFile::decodeName(arguments().at(0).toLocal8Bit());
-
1864 QString absPath;
never executed (the execution status of this line is deduced): QString absPath;
-
1865 -
1866 if (!argv0.isEmpty() && argv0.at(0) == QLatin1Char('/')) {
never evaluated: !argv0.isEmpty()
never evaluated: argv0.at(0) == QLatin1Char('/')
0
1867 /* -
1868 If argv0 starts with a slash, it is already an absolute -
1869 file path. -
1870 */ -
1871 absPath = argv0;
never executed (the execution status of this line is deduced): absPath = argv0;
-
1872 } else if (argv0.contains(QLatin1Char('/'))) {
never executed: }
never evaluated: argv0.contains(QLatin1Char('/'))
0
1873 /* -
1874 If argv0 contains one or more slashes, it is a file path -
1875 relative to the current directory. -
1876 */ -
1877 absPath = QDir::current().absoluteFilePath(argv0);
never executed (the execution status of this line is deduced): absPath = QDir::current().absoluteFilePath(argv0);
-
1878 } else {
never executed: }
0
1879 /* -
1880 Otherwise, the file path has to be determined using the -
1881 PATH environment variable. -
1882 */ -
1883 absPath = QStandardPaths::findExecutable(argv0);
never executed (the execution status of this line is deduced): absPath = QStandardPaths::findExecutable(argv0);
-
1884 }
never executed: }
0
1885 -
1886 absPath = QDir::cleanPath(absPath);
never executed (the execution status of this line is deduced): absPath = QDir::cleanPath(absPath);
-
1887 -
1888 QFileInfo fi(absPath);
never executed (the execution status of this line is deduced): QFileInfo fi(absPath);
-
1889 d->cachedApplicationFilePath = fi.exists() ? fi.canonicalFilePath() : QString();
never evaluated: fi.exists()
0
1890 return d->cachedApplicationFilePath;
never executed: return d->cachedApplicationFilePath;
0
1891#endif -
1892} -
1893 -
1894/*! -
1895 \since 4.4 -
1896 -
1897 Returns the current process ID for the application. -
1898*/ -
1899qint64 QCoreApplication::applicationPid() -
1900{ -
1901#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE) -
1902 return GetCurrentProcessId(); -
1903#elif defined(Q_OS_VXWORKS) -
1904 return (pid_t) taskIdCurrent; -
1905#else -
1906 return getpid();
executed: return getpid();
Execution Count:1485
1485
1907#endif -
1908} -
1909 -
1910/*! -
1911 \since 4.1 -
1912 -
1913 Returns the list of command-line arguments. -
1914 -
1915 Usually arguments().at(0) is the program name, arguments().at(1) -
1916 is the first argument, and arguments().last() is the last -
1917 argument. See the note below about Windows. -
1918 -
1919 Calling this function is slow - you should store the result in a variable -
1920 when parsing the command line. -
1921 -
1922 \warning On Unix, this list is built from the argc and argv parameters passed -
1923 to the constructor in the main() function. The string-data in argv is -
1924 interpreted using QString::fromLocal8Bit(); hence it is not possible to -
1925 pass, for example, Japanese command line arguments on a system that runs in a -
1926 Latin1 locale. Most modern Unix systems do not have this limitation, as they are -
1927 Unicode-based. -
1928 -
1929 On NT-based Windows, this limitation does not apply either. -
1930 On Windows, the arguments() are not built from the contents of argv/argc, as -
1931 the content does not support Unicode. Instead, the arguments() are constructed -
1932 from the return value of -
1933 \l{http://msdn2.microsoft.com/en-us/library/ms683156(VS.85).aspx}{GetCommandLine()}. -
1934 As a result of this, the string given by arguments().at(0) might not be -
1935 the program name on Windows, depending on how the application was started. -
1936 -
1937 \sa applicationFilePath() -
1938*/ -
1939 -
1940QStringList QCoreApplication::arguments() -
1941{ -
1942 QStringList list;
executed (the execution status of this line is deduced): QStringList list;
-
1943 -
1944 if (!self) {
partially evaluated: !self
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
1945 qWarning("QCoreApplication::arguments: Please instantiate the QApplication object first");
never executed (the execution status of this line is deduced): QMessageLogger("kernel/qcoreapplication.cpp", 1945, __PRETTY_FUNCTION__).warning("QCoreApplication::arguments: Please instantiate the QApplication object first");
-
1946 return list;
never executed: return list;
0
1947 } -
1948 const int ac = self->d_func()->argc;
executed (the execution status of this line is deduced): const int ac = self->d_func()->argc;
-
1949 char ** const av = self->d_func()->argv;
executed (the execution status of this line is deduced): char ** const av = self->d_func()->argv;
-
1950 list.reserve(ac);
executed (the execution status of this line is deduced): list.reserve(ac);
-
1951 -
1952#ifdef Q_OS_WIN -
1953 // On Windows, it is possible to pass Unicode arguments on -
1954 // the command line. To restore those, we split the command line -
1955 // and filter out arguments that were deleted by derived application -
1956 // classes by index. -
1957 QString cmdline = QString::fromWCharArray(GetCommandLine()); -
1958 -
1959#if defined(Q_OS_WINCE) -
1960 wchar_t tempFilename[MAX_PATH+1]; -
1961 if (GetModuleFileName(0, tempFilename, MAX_PATH)) { -
1962 tempFilename[MAX_PATH] = 0; -
1963 cmdline.prepend(QLatin1Char('\"') + QString::fromWCharArray(tempFilename) + QLatin1String("\" ")); -
1964 } -
1965#endif // Q_OS_WINCE -
1966 -
1967 char ** const origArgv = self->d_func()->origArgv; -
1968 const int origArgc = self->d_func()->origArgc; -
1969 char ** const avEnd = av + ac; -
1970 -
1971 const QStringList allArguments = qWinCmdArgs(cmdline); -
1972 Q_ASSERT(allArguments.size() == origArgc); -
1973 for (int i = 0; i < origArgc; ++i) -
1974 if (qFind(av, avEnd, origArgv[i]) != avEnd) -
1975 list.push_back(allArguments.at(i)); -
1976 -
1977#else -
1978 for (int a = 0; a < ac; ++a) {
evaluated: a < ac
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:4
4-6
1979 list << QString::fromLocal8Bit(av[a]);
executed (the execution status of this line is deduced): list << QString::fromLocal8Bit(av[a]);
-
1980 }
executed: }
Execution Count:6
6
1981#endif -
1982 -
1983 return list;
executed: return list;
Execution Count:4
4
1984} -
1985 -
1986/*! -
1987 \property QCoreApplication::organizationName -
1988 \brief the name of the organization that wrote this application -
1989 -
1990 The value is used by the QSettings class when it is constructed -
1991 using the empty constructor. This saves having to repeat this -
1992 information each time a QSettings object is created. -
1993 -
1994 On Mac, QSettings uses organizationDomain() as the organization -
1995 if it's not an empty string; otherwise it uses -
1996 organizationName(). On all other platforms, QSettings uses -
1997 organizationName() as the organization. -
1998 -
1999 \sa organizationDomain, applicationName -
2000*/ -
2001 -
2002void QCoreApplication::setOrganizationName(const QString &orgName) -
2003{ -
2004 coreappdata()->orgName = orgName;
executed (the execution status of this line is deduced): coreappdata()->orgName = orgName;
-
2005}
executed: }
Execution Count:5
5
2006 -
2007QString QCoreApplication::organizationName() -
2008{ -
2009#ifdef Q_OS_BLACKBERRY -
2010 coreappdata()->loadManifest(); -
2011#endif -
2012 return coreappdata()->orgName;
executed: return coreappdata()->orgName;
Execution Count:22
22
2013} -
2014 -
2015/*! -
2016 \property QCoreApplication::organizationDomain -
2017 \brief the Internet domain of the organization that wrote this application -
2018 -
2019 The value is used by the QSettings class when it is constructed -
2020 using the empty constructor. This saves having to repeat this -
2021 information each time a QSettings object is created. -
2022 -
2023 On Mac, QSettings uses organizationDomain() as the organization -
2024 if it's not an empty string; otherwise it uses organizationName(). -
2025 On all other platforms, QSettings uses organizationName() as the -
2026 organization. -
2027 -
2028 \sa organizationName, applicationName, applicationVersion -
2029*/ -
2030void QCoreApplication::setOrganizationDomain(const QString &orgDomain) -
2031{ -
2032 coreappdata()->orgDomain = orgDomain;
never executed (the execution status of this line is deduced): coreappdata()->orgDomain = orgDomain;
-
2033}
never executed: }
0
2034 -
2035QString QCoreApplication::organizationDomain() -
2036{ -
2037 return coreappdata()->orgDomain;
executed: return coreappdata()->orgDomain;
Execution Count:5
5
2038} -
2039 -
2040/*! -
2041 \property QCoreApplication::applicationName -
2042 \brief the name of this application -
2043 -
2044 The value is used by the QSettings class when it is constructed -
2045 using the empty constructor. This saves having to repeat this -
2046 information each time a QSettings object is created. -
2047 -
2048 If not set, the application name defaults to the executable name (since 5.0). -
2049 -
2050 \sa organizationName, organizationDomain, applicationVersion, applicationFilePath -
2051*/ -
2052void QCoreApplication::setApplicationName(const QString &application) -
2053{ -
2054 coreappdata()->application = application;
executed (the execution status of this line is deduced): coreappdata()->application = application;
-
2055}
executed: }
Execution Count:17
17
2056 -
2057QString QCoreApplication::applicationName() -
2058{ -
2059#ifdef Q_OS_BLACKBERRY -
2060 coreappdata()->loadManifest(); -
2061#endif -
2062 QString appname = coreappdata() ? coreappdata()->application : QString();
partially evaluated: coreappdata()
TRUEFALSE
yes
Evaluation Count:7547
no
Evaluation Count:0
0-7547
2063 if (appname.isEmpty() && QCoreApplication::self)
evaluated: appname.isEmpty()
TRUEFALSE
yes
Evaluation Count:5436
yes
Evaluation Count:2111
partially evaluated: QCoreApplication::self
TRUEFALSE
yes
Evaluation Count:5436
no
Evaluation Count:0
0-5436
2064 appname = QCoreApplication::self->d_func()->appName();
executed: appname = QCoreApplication::self->d_func()->appName();
Execution Count:5436
5436
2065 return appname;
executed: return appname;
Execution Count:7547
7547
2066} -
2067 -
2068// Exported for QDesktopServices (Qt4 behavior compatibility) -
2069Q_CORE_EXPORT QString qt_applicationName_noFallback() -
2070{ -
2071 return coreappdata()->application;
executed: return coreappdata()->application;
Execution Count:2
2
2072} -
2073 -
2074/*! -
2075 \property QCoreApplication::applicationVersion -
2076 \since 4.4 -
2077 \brief the version of this application -
2078 -
2079 \sa applicationName, organizationName, organizationDomain -
2080*/ -
2081void QCoreApplication::setApplicationVersion(const QString &version) -
2082{ -
2083 coreappdata()->applicationVersion = version;
executed (the execution status of this line is deduced): coreappdata()->applicationVersion = version;
-
2084}
executed: }
Execution Count:2
2
2085 -
2086QString QCoreApplication::applicationVersion() -
2087{ -
2088#ifdef Q_OS_BLACKBERRY -
2089 coreappdata()->loadManifest(); -
2090#endif -
2091 return coreappdata()->applicationVersion;
executed: return coreappdata()->applicationVersion;
Execution Count:4
4
2092} -
2093 -
2094#ifndef QT_NO_LIBRARY -
2095 -
2096Q_GLOBAL_STATIC_WITH_ARGS(QMutex, libraryPathMutex, (QMutex::Recursive))
never executed: delete x;
executed: return thisGlobalStatic.pointer.load();
Execution Count:171
partially evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:23
evaluated: !thisGlobalStatic.pointer.load()
TRUEFALSE
yes
Evaluation Count:23
yes
Evaluation Count:148
partially evaluated: !thisGlobalStatic.destroyed
TRUEFALSE
yes
Evaluation Count:23
no
Evaluation Count:0
0-171
2097 -
2098/*! -
2099 Returns a list of paths that the application will search when -
2100 dynamically loading libraries. -
2101 -
2102 Qt provides default library paths, but they can also be set using -
2103 a \l{Using qt.conf}{qt.conf} file. Paths specified in this file -
2104 will override default values. -
2105 -
2106 This list will include the installation directory for plugins if -
2107 it exists (the default installation directory for plugins is \c -
2108 INSTALL/plugins, where \c INSTALL is the directory where Qt was -
2109 installed). The directory of the application executable (NOT the -
2110 working directory) is always added, as well as the colon separated -
2111 entries of the QT_PLUGIN_PATH environment variable. -
2112 -
2113 If you want to iterate over the list, you can use the \l foreach -
2114 pseudo-keyword: -
2115 -
2116 \snippet code/src_corelib_kernel_qcoreapplication.cpp 2 -
2117 -
2118 \sa setLibraryPaths(), addLibraryPath(), removeLibraryPath(), QLibrary, -
2119 {How to Create Qt Plugins} -
2120*/ -
2121QStringList QCoreApplication::libraryPaths() -
2122{ -
2123 QMutexLocker locker(libraryPathMutex());
executed (the execution status of this line is deduced): QMutexLocker locker(libraryPathMutex());
-
2124 if (!coreappdata()->app_libpaths) {
evaluated: !coreappdata()->app_libpaths
TRUEFALSE
yes
Evaluation Count:30
yes
Evaluation Count:131
30-131
2125 QStringList *app_libpaths = coreappdata()->app_libpaths = new QStringList;
executed (the execution status of this line is deduced): QStringList *app_libpaths = coreappdata()->app_libpaths = new QStringList;
-
2126 QString installPathPlugins = QLibraryInfo::location(QLibraryInfo::PluginsPath);
executed (the execution status of this line is deduced): QString installPathPlugins = QLibraryInfo::location(QLibraryInfo::PluginsPath);
-
2127 if (QFile::exists(installPathPlugins)) {
partially evaluated: QFile::exists(installPathPlugins)
TRUEFALSE
yes
Evaluation Count:30
no
Evaluation Count:0
0-30
2128 // Make sure we convert from backslashes to slashes. -
2129 installPathPlugins = QDir(installPathPlugins).canonicalPath();
executed (the execution status of this line is deduced): installPathPlugins = QDir(installPathPlugins).canonicalPath();
-
2130 if (!app_libpaths->contains(installPathPlugins))
partially evaluated: !app_libpaths->contains(installPathPlugins)
TRUEFALSE
yes
Evaluation Count:30
no
Evaluation Count:0
0-30
2131 app_libpaths->append(installPathPlugins);
executed: app_libpaths->append(installPathPlugins);
Execution Count:30
30
2132 }
executed: }
Execution Count:30
30
2133 -
2134 // If QCoreApplication is not yet instantiated, -
2135 // make sure we add the application path when we construct the QCoreApplication -
2136 if (self) self->d_func()->appendApplicationPathToLibraryPaths();
executed: self->d_func()->appendApplicationPathToLibraryPaths();
Execution Count:29
evaluated: self
TRUEFALSE
yes
Evaluation Count:29
yes
Evaluation Count:1
1-29
2137 -
2138 const QByteArray libPathEnv = qgetenv("QT_PLUGIN_PATH");
executed (the execution status of this line is deduced): const QByteArray libPathEnv = qgetenv("QT_PLUGIN_PATH");
-
2139 if (!libPathEnv.isEmpty()) {
evaluated: !libPathEnv.isEmpty()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:27
3-27
2140#if defined(Q_OS_WIN) -
2141 QLatin1Char pathSep(';'); -
2142#else -
2143 QLatin1Char pathSep(':');
executed (the execution status of this line is deduced): QLatin1Char pathSep(':');
-
2144#endif -
2145 QStringList paths = QFile::decodeName(libPathEnv).split(pathSep, QString::SkipEmptyParts);
executed (the execution status of this line is deduced): QStringList paths = QFile::decodeName(libPathEnv).split(pathSep, QString::SkipEmptyParts);
-
2146 for (QStringList::const_iterator it = paths.constBegin(); it != paths.constEnd(); ++it) {
evaluated: it != paths.constEnd()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:3
3-5
2147 QString canonicalPath = QDir(*it).canonicalPath();
executed (the execution status of this line is deduced): QString canonicalPath = QDir(*it).canonicalPath();
-
2148 if (!canonicalPath.isEmpty()
evaluated: !canonicalPath.isEmpty()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:2
2-3
2149 && !app_libpaths->contains(canonicalPath)) {
evaluated: !app_libpaths->contains(canonicalPath)
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
1-2
2150 app_libpaths->append(canonicalPath);
executed (the execution status of this line is deduced): app_libpaths->append(canonicalPath);
-
2151 }
executed: }
Execution Count:2
2
2152 }
executed: }
Execution Count:5
5
2153 }
executed: }
Execution Count:3
3
2154 }
executed: }
Execution Count:30
30
2155 return *(coreappdata()->app_libpaths);
executed: return *(coreappdata()->app_libpaths);
Execution Count:161
161
2156} -
2157 -
2158 -
2159 -
2160/*! -
2161 -
2162 Sets the list of directories to search when loading libraries to -
2163 \a paths. All existing paths will be deleted and the path list -
2164 will consist of the paths given in \a paths. -
2165 -
2166 \sa libraryPaths(), addLibraryPath(), removeLibraryPath(), QLibrary -
2167 */ -
2168void QCoreApplication::setLibraryPaths(const QStringList &paths) -
2169{ -
2170 QMutexLocker locker(libraryPathMutex());
executed (the execution status of this line is deduced): QMutexLocker locker(libraryPathMutex());
-
2171 if (!coreappdata()->app_libpaths)
evaluated: !coreappdata()->app_libpaths
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
1-2
2172 coreappdata()->app_libpaths = new QStringList;
executed: coreappdata()->app_libpaths = new QStringList;
Execution Count:2
2
2173 *(coreappdata()->app_libpaths) = paths;
executed (the execution status of this line is deduced): *(coreappdata()->app_libpaths) = paths;
-
2174 locker.unlock();
executed (the execution status of this line is deduced): locker.unlock();
-
2175 QFactoryLoader::refreshAll();
executed (the execution status of this line is deduced): QFactoryLoader::refreshAll();
-
2176}
executed: }
Execution Count:3
3
2177 -
2178/*! -
2179 Prepends \a path to the beginning of the library path list, ensuring that -
2180 it is searched for libraries first. If \a path is empty or already in the -
2181 path list, the path list is not changed. -
2182 -
2183 The default path list consists of a single entry, the installation -
2184 directory for plugins. The default installation directory for plugins -
2185 is \c INSTALL/plugins, where \c INSTALL is the directory where Qt was -
2186 installed. -
2187 -
2188 \sa removeLibraryPath(), libraryPaths(), setLibraryPaths() -
2189 */ -
2190void QCoreApplication::addLibraryPath(const QString &path) -
2191{ -
2192 if (path.isEmpty())
partially evaluated: path.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
0-7
2193 return;
never executed: return;
0
2194 -
2195 QMutexLocker locker(libraryPathMutex());
executed (the execution status of this line is deduced): QMutexLocker locker(libraryPathMutex());
-
2196 -
2197 // make sure that library paths is initialized -
2198 libraryPaths();
executed (the execution status of this line is deduced): libraryPaths();
-
2199 -
2200 QString canonicalPath = QDir(path).canonicalPath();
executed (the execution status of this line is deduced): QString canonicalPath = QDir(path).canonicalPath();
-
2201 if (!canonicalPath.isEmpty()
partially evaluated: !canonicalPath.isEmpty()
TRUEFALSE
yes
Evaluation Count:7
no
Evaluation Count:0
0-7
2202 && !coreappdata()->app_libpaths->contains(canonicalPath)) {
evaluated: !coreappdata()->app_libpaths->contains(canonicalPath)
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:4
3-4
2203 coreappdata()->app_libpaths->prepend(canonicalPath);
executed (the execution status of this line is deduced): coreappdata()->app_libpaths->prepend(canonicalPath);
-
2204 locker.unlock();
executed (the execution status of this line is deduced): locker.unlock();
-
2205 QFactoryLoader::refreshAll();
executed (the execution status of this line is deduced): QFactoryLoader::refreshAll();
-
2206 }
executed: }
Execution Count:3
3
2207}
executed: }
Execution Count:7
7
2208 -
2209/*! -
2210 Removes \a path from the library path list. If \a path is empty or not -
2211 in the path list, the list is not changed. -
2212 -
2213 \sa addLibraryPath(), libraryPaths(), setLibraryPaths() -
2214*/ -
2215void QCoreApplication::removeLibraryPath(const QString &path) -
2216{ -
2217 if (path.isEmpty())
never evaluated: path.isEmpty()
0
2218 return;
never executed: return;
0
2219 -
2220 QMutexLocker locker(libraryPathMutex());
never executed (the execution status of this line is deduced): QMutexLocker locker(libraryPathMutex());
-
2221 -
2222 // make sure that library paths is initialized -
2223 libraryPaths();
never executed (the execution status of this line is deduced): libraryPaths();
-
2224 -
2225 QString canonicalPath = QDir(path).canonicalPath();
never executed (the execution status of this line is deduced): QString canonicalPath = QDir(path).canonicalPath();
-
2226 coreappdata()->app_libpaths->removeAll(canonicalPath);
never executed (the execution status of this line is deduced): coreappdata()->app_libpaths->removeAll(canonicalPath);
-
2227 QFactoryLoader::refreshAll();
never executed (the execution status of this line is deduced): QFactoryLoader::refreshAll();
-
2228}
never executed: }
0
2229 -
2230#endif //QT_NO_LIBRARY -
2231 -
2232/*! -
2233 Installs an event filter \a filterObj for all native events -
2234 received by the application in the main thread. -
2235 -
2236 The event filter \a filterObj receives events via its nativeEventFilter() -
2237 function, which is called for all native events received in the main thread. -
2238 -
2239 The nativeEventFilter() function should return true if the event should -
2240 be filtered, (i.e. stopped). It should return false to allow -
2241 normal Qt processing to continue: the native event can then be translated -
2242 into a QEvent and handled by the standard Qt \l{QEvent} {event} filtering, -
2243 e.g. QObject::installEventFilter(). -
2244 -
2245 If multiple event filters are installed, the filter that was -
2246 installed last is activated first. -
2247 -
2248 \note The filter function set here receives native messages, -
2249 i.e. MSG or XCB event structs. -
2250 -
2251 For maximum portability, you should always try to use QEvents -
2252 and QObject::installEventFilter() whenever possible. -
2253 -
2254 \sa QObject::installEventFilter() -
2255 -
2256 \since 5.0 -
2257*/ -
2258void QCoreApplication::installNativeEventFilter(QAbstractNativeEventFilter *filterObj) -
2259{ -
2260 QAbstractEventDispatcher *eventDispatcher = QAbstractEventDispatcher::instance(QCoreApplicationPrivate::theMainThread);
executed (the execution status of this line is deduced): QAbstractEventDispatcher *eventDispatcher = QAbstractEventDispatcher::instance(QCoreApplicationPrivate::theMainThread);
-
2261 if (!filterObj || !eventDispatcher)
partially evaluated: !filterObj
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
partially evaluated: !eventDispatcher
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
2262 return;
never executed: return;
0
2263 eventDispatcher->installNativeEventFilter(filterObj);
executed (the execution status of this line is deduced): eventDispatcher->installNativeEventFilter(filterObj);
-
2264}
executed: }
Execution Count:1
1
2265 -
2266/*! -
2267 Removes an event \a filterObject from this object. The -
2268 request is ignored if such an event filter has not been installed. -
2269 -
2270 All event filters for this object are automatically removed when -
2271 this object is destroyed. -
2272 -
2273 It is always safe to remove an event filter, even during event -
2274 filter activation (i.e. from the nativeEventFilter() function). -
2275 -
2276 \sa installNativeEventFilter() -
2277 \since 5.0 -
2278*/ -
2279void QCoreApplication::removeNativeEventFilter(QAbstractNativeEventFilter *filterObject) -
2280{ -
2281 QAbstractEventDispatcher *eventDispatcher = QAbstractEventDispatcher::instance();
never executed (the execution status of this line is deduced): QAbstractEventDispatcher *eventDispatcher = QAbstractEventDispatcher::instance();
-
2282 if (!filterObject || !eventDispatcher)
never evaluated: !filterObject
never evaluated: !eventDispatcher
0
2283 return;
never executed: return;
0
2284 eventDispatcher->removeNativeEventFilter(filterObject);
never executed (the execution status of this line is deduced): eventDispatcher->removeNativeEventFilter(filterObject);
-
2285}
never executed: }
0
2286 -
2287/*! -
2288 This function returns true if there are pending events; otherwise -
2289 returns false. Pending events can be either from the window -
2290 system or posted events using postEvent(). -
2291 -
2292 \sa QAbstractEventDispatcher::hasPendingEvents() -
2293*/ -
2294bool QCoreApplication::hasPendingEvents() -
2295{ -
2296 QAbstractEventDispatcher *eventDispatcher = QAbstractEventDispatcher::instance();
never executed (the execution status of this line is deduced): QAbstractEventDispatcher *eventDispatcher = QAbstractEventDispatcher::instance();
-
2297 if (eventDispatcher)
never evaluated: eventDispatcher
0
2298 return eventDispatcher->hasPendingEvents();
never executed: return eventDispatcher->hasPendingEvents();
0
2299 return false;
never executed: return false;
0
2300} -
2301 -
2302/*! -
2303 Returns a pointer to the event dispatcher object for the main thread. If no -
2304 event dispatcher exists for the thread, this function returns 0. -
2305*/ -
2306QAbstractEventDispatcher *QCoreApplication::eventDispatcher() -
2307{ -
2308 if (QCoreApplicationPrivate::theMainThread)
partially evaluated: QCoreApplicationPrivate::theMainThread
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
2309 return QCoreApplicationPrivate::theMainThread->eventDispatcher();
executed: return QCoreApplicationPrivate::theMainThread->eventDispatcher();
Execution Count:3
3
2310 return 0;
never executed: return 0;
0
2311} -
2312 -
2313/*! -
2314 Sets the event dispatcher for the main thread to \a eventDispatcher. This -
2315 is only possible as long as there is no event dispatcher installed yet. That -
2316 is, before QCoreApplication has been instantiated. This method takes -
2317 ownership of the object. -
2318*/ -
2319void QCoreApplication::setEventDispatcher(QAbstractEventDispatcher *eventDispatcher) -
2320{ -
2321 QThread *mainThread = QCoreApplicationPrivate::theMainThread;
executed (the execution status of this line is deduced): QThread *mainThread = QCoreApplicationPrivate::theMainThread;
-
2322 if (!mainThread)
partially evaluated: !mainThread
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
2323 mainThread = QThread::currentThread(); // will also setup theMainThread
never executed: mainThread = QThread::currentThread();
0
2324 mainThread->setEventDispatcher(eventDispatcher);
executed (the execution status of this line is deduced): mainThread->setEventDispatcher(eventDispatcher);
-
2325}
executed: }
Execution Count:1
1
2326 -
2327/*! -
2328 \fn void qAddPostRoutine(QtCleanUpFunction ptr) -
2329 \relates QCoreApplication -
2330 -
2331 Adds a global routine that will be called from the QApplication -
2332 destructor. This function is normally used to add cleanup routines -
2333 for program-wide functionality. -
2334 -
2335 The function specified by \a ptr should take no arguments and should -
2336 return nothing. For example: -
2337 -
2338 \snippet code/src_corelib_kernel_qcoreapplication.cpp 4 -
2339 -
2340 Note that for an application- or module-wide cleanup, -
2341 qAddPostRoutine() is often not suitable. For example, if the -
2342 program is split into dynamically loaded modules, the relevant -
2343 module may be unloaded long before the QApplication destructor is -
2344 called. -
2345 -
2346 For modules and libraries, using a reference-counted -
2347 initialization manager or Qt's parent-child deletion mechanism may -
2348 be better. Here is an example of a private class that uses the -
2349 parent-child mechanism to call a cleanup function at the right -
2350 time: -
2351 -
2352 \snippet code/src_corelib_kernel_qcoreapplication.cpp 5 -
2353 -
2354 By selecting the right parent object, this can often be made to -
2355 clean up the module's data at the right moment. -
2356*/ -
2357 -
2358/*! -
2359 \macro Q_DECLARE_TR_FUNCTIONS(context) -
2360 \relates QCoreApplication -
2361 -
2362 The Q_DECLARE_TR_FUNCTIONS() macro declares and implements two -
2363 translation functions, \c tr() and \c trUtf8(), with these -
2364 signatures: -
2365 -
2366 \snippet code/src_corelib_kernel_qcoreapplication.cpp 6 -
2367 -
2368 This macro is useful if you want to use QObject::tr() or -
2369 QObject::trUtf8() in classes that don't inherit from QObject. -
2370 -
2371 Q_DECLARE_TR_FUNCTIONS() must appear at the very top of the -
2372 class definition (before the first \c{public:} or \c{protected:}). -
2373 For example: -
2374 -
2375 \snippet code/src_corelib_kernel_qcoreapplication.cpp 7 -
2376 -
2377 The \a context parameter is normally the class name, but it can -
2378 be any string. -
2379 -
2380 \sa Q_OBJECT, QObject::tr(), QObject::trUtf8() -
2381*/ -
2382 -
2383QT_END_NAMESPACE -
2384 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial