15#include <private/qproperty_p.h>
23#include <private/qloggingregistry_p.h>
30#include <QtCore/qpromise.h>
32#include <private/qthread_p.h>
35#include <private/qthreadpool_p.h>
40#include <private/qfactoryloader_p.h>
41#include <private/qfunctions_p.h>
42#include <private/qlocale_p.h>
43#include <private/qlocking_p.h>
44#include <private/qhooks_p.h>
46#if QT_CONFIG(permissions)
47#include <private/qpermissions_p.h>
52# if defined(Q_OS_DARWIN)
55# if !defined(QT_NO_GLIB)
56# include "qeventdispatcher_glib_p.h"
66#if defined(Q_OS_ANDROID)
67#include <QtCore/qjniobject.h>
78# ifndef Q_OS_INTEGRITY
82# include <sys/types.h>
87#if __has_include(<sys/auxv.h>)
96#include <emscripten/val.h>
100#include <private/qtrace_p.h>
102#include <qtcore_tracepoints_p.h>
114 "#include <qcoreevent.h>"
124Q_TRACE_POINT(qtcore, QCoreApplication_notify_exit,
bool consumed,
bool filtered);
126#if defined(Q_OS_WIN) || defined(Q_OS_DARWIN)
132#if !defined(Q_OS_WIN)
134QString QCoreApplicationPrivate::infoDictionaryStringProperty(
const QString &propertyName)
137 QCFString cfPropertyName = propertyName.toCFString();
138 CFTypeRef
string = CFBundleGetValueForInfoDictionaryKey(CFBundleGetMainBundle(),
141 bundleName = QString::fromCFString(
static_cast<CFStringRef
>(
string));
149 applicationName = infoDictionaryStringProperty(
QStringLiteral(
"CFBundleName"));
152 char *
p = strrchr(
argv[0],
'/');
156 return applicationName;
161#ifdef QT_BOOTSTRAPPED
162#elif defined(Q_OS_DARWIN)
163 applicationVersion = infoDictionaryStringProperty(
QStringLiteral(
"CFBundleVersion"));
164#elif defined(Q_OS_ANDROID)
168 "getPackageManager",
"()Landroid/content/pm/PackageManager;");
170 if (pm.isValid() && pn.isValid()) {
172 "getPackageInfo",
"(Ljava/lang/String;I)Landroid/content/pm/PackageInfo;",
174 if (packageInfo.isValid()) {
175 QJniObject versionName = packageInfo.getObjectField(
176 "versionName",
"Ljava/lang/String;");
177 if (versionName.isValid())
178 return versionName.toString();
183 return applicationVersion;
191 bool b = (QCoreApplication::self !=
nullptr);
193 qWarning(
"QApplication::%s: Please instantiate the QApplication object first",
function);
197#if QT_CONFIG(commandlineparser)
201 QStringLiteral(
"Activates the QML/JS debugger with a specified port. The value must be of format port:1234[,block]. \"block\" makes the application wait for a connection."),
208 int j =
argc ? 1 : 0;
209 for (
int i = 1;
i <
argc; ++
i) {
212 if (*
argv[
i] !=
'-') {
219 if (strncmp(
arg,
"-qmljsdebugger=", 15) == 0) {
221 }
else if (strcmp(
arg,
"-qmljsdebugger") == 0 &&
i <
argc - 1) {
294 if (!preRList.exists())
311 if (!postRList.exists())
373#if QT_CONFIG(library)
374 std::unique_ptr<QStringList> app_libpaths;
375 std::unique_ptr<QStringList> manual_libpaths;
392static inline bool isArgvModified(
int argc,
char **argv)
394 if (__argc != argc || !__argv )
398 for (
int a = 0;
a < argc; ++
a) {
399 if (argv[
a] != __argv[
a] && strcmp(argv[
a], __argv[
a]))
405static inline bool contains(
int argc,
char **argv,
const char *needle)
407 for (
int a = 0;
a < argc; ++
a) {
408 if (!strcmp(argv[
a], needle))
429 , aboutToQuitEmitted(
false)
430 , threadData_clean(
false)
435 static const char *
const empty =
"";
438 argv =
const_cast<char **
>(&empty);
443 origArgv =
new char *[
argc];
451# if defined(Q_OS_UNIX)
453 qFatal(
"FATAL: The application binary appears to be running setuid, this is a security hole.");
458 qWarning(
"WARNING: QApplication was not created in the main() thread.");
469 if (consoleAllocated)
483 void *
data = &thisThreadData->tls;
484 QThreadStorageData::finish((
void **)
data);
488 const auto locker = qt_scoped_lock(thisThreadData->postEventList.mutex);
489 for (
const QPostEvent &pe : std::as_const(thisThreadData->postEventList)) {
491 --pe.receiver->d_func()->postedEvents;
492 pe.event->m_posted =
false;
496 thisThreadData->postEventList.clear();
497 thisThreadData->postEventList.recursion = 0;
498 thisThreadData->quitNow =
false;
528 return data->requiresCoreApplication;
536 "QCoreApplication::sendEvent",
538 "Current thread 0x%p. Receiver '%ls' (of type '%s') was created in thread 0x%p",
540 receiver->metaObject()->className(), thr)
550#if QT_CONFIG(library)
551 QStringList *app_libpaths = coreappdata()->app_libpaths.get();
553 coreappdata()->app_libpaths.reset(app_libpaths =
new QStringList);
557 if (
QFile::exists(app_location) && !app_libpaths->contains(app_location))
558 app_libpaths->append(app_location);
576 if (AllocConsole() == FALSE)
578 consoleAllocated =
true;
580 if (AttachConsole(ATTACH_PARENT_PROCESS) == FALSE)
590 freopen_s(&
in,
"CONIN$",
"r", stdin);
591 freopen_s(&
out,
"CONOUT$",
"w", stdout);
592 freopen_s(&err,
"CONOUT$",
"w", stderr);
602#if defined(QT_BOOTSTRAPPED)
604#elif defined(Q_OS_UNIX)
605 Q_CONSTINIT
static bool qt_locale_initialized =
false;
606 if (qt_locale_initialized)
608 qt_locale_initialized =
true;
613 setlocale(LC_ALL,
"");
617# if defined(Q_OS_INTEGRITY)
618 setlocale(LC_CTYPE,
"UTF-8");
619# elif defined(Q_OS_QNX)
622# elif defined(Q_OS_ANDROID) && __ANDROID_API__ < __ANDROID_API_O__
627 const std::string oldEncoding = nl_langinfo(CODESET);
629 ||
qstricmp(oldEncoding.data(),
"utf8") == 0)) {
630 const QByteArray oldLocale = setlocale(LC_ALL,
nullptr);
632 bool warnOnOverride =
true;
633# if defined(Q_OS_DARWIN)
637 warnOnOverride =
qstrcmp(setlocale(LC_CTYPE,
nullptr),
"C") != 0
638 || getenv(
"LC_ALL") || getenv(
"LC_CTYPE") || getenv(
"LANG");
642 newLocale = setlocale(LC_CTYPE,
"UTF-8");
644 newLocale = setlocale(LC_CTYPE,
nullptr);
649 newLocale +=
".UTF-8";
650 newLocale = setlocale(LC_CTYPE, newLocale);
654 newLocale = setlocale(LC_CTYPE,
"C.UTF-8");
656 newLocale = setlocale(LC_CTYPE,
"C.utf8");
661 qWarning(
"Detected locale \"%s\" with character encoding \"%s\", which is not UTF-8.\n"
662 "Qt depends on a UTF-8 locale, but has failed to switch to one.\n"
663 "If this causes problems, reconfigure your locale. See the locale(1) manual\n"
664 "for more information.", oldLocale.
constData(), oldEncoding.data());
665 }
else if (warnOnOverride) {
667 qWarning(
"Detected locale \"%s\" with character encoding \"%s\", which is not UTF-8.\n"
668 "Qt depends on a UTF-8 locale, and has switched to \"%s\" instead.\n"
669 "If this causes problems, reconfigure your locale. See the locale(1) manual\n"
670 "for more information.",
773 d_func()->q_ptr =
this;
803 d_func()->q_ptr =
this;
821#if defined(Q_OS_MACOS)
831 Q_ASSERT_X(!QCoreApplication::self,
"QCoreApplication",
"there should be only one application object");
832 QCoreApplication::self =
q;
836 emscripten::val hardwareConcurrency = emscripten::val::global(
"navigator")[
"hardwareConcurrency"];
837 if (hardwareConcurrency.isUndefined())
838 QThreadPrivate::idealThreadCount = 2;
840 QThreadPrivate::idealThreadCount = hardwareConcurrency.as<
int>();
845 if (!coreappdata()->applicationNameSet)
846 coreappdata()->application =
appName();
848 if (!coreappdata()->applicationVersionSet)
849 coreappdata()->applicationVersion =
appVersion();
851#if defined(Q_OS_ANDROID)
859#if QT_CONFIG(library)
863 QStringList *appPaths = coreappdata()->app_libpaths.release();
864 QStringList *manualPaths = coreappdata()->manual_libpaths.release();
874 newPaths.prepend((*manualPaths)[--
i]);
875 }
else if (--
i < 0) {
876 newPaths.removeAll((*appPaths)[
j]);
877 }
else if ((*manualPaths)[
i] != (*appPaths)[
j]) {
878 newPaths.removeAll((*appPaths)[
j]);
883 coreappdata()->manual_libpaths.reset(
new QStringList(newPaths));
913#ifndef QT_BOOTSTRAPPED
949 if (globalThreadPool) {
951 delete globalThreadPool;
955 delete guiThreadPool;
960 d_func()->threadData.loadRelaxed()->eventDispatcher =
nullptr;
966#if QT_CONFIG(library)
967 coreappdata()->app_libpaths.reset();
968 coreappdata()->manual_libpaths.reset();
1030#if defined(QT_NO_QOBJECT)
1041#ifdef QT_BOOTSTRAPPED
1042 qWarning(
"Attribute %d must be set before QCoreApplication is created.",
1045 qWarning(
"Attribute Qt::%s must be set before QCoreApplication is created.",
1046 QMetaEnum::fromType<Qt::ApplicationAttribute>().valueToKey(
attribute));
1066#ifndef QT_NO_QOBJECT
1101 if (!self && selfRequired)
1133 if (
event && originatingEvent)
1134 event->m_spont = originatingEvent->m_spont;
1136 return notifyInternal2(receiver,
event);
1208 if (receiver ==
nullptr) {
1209 qWarning(
"QCoreApplication::notify: Unexpected null receiver");
1223 Q_ASSERT(receiver->d_func()->threadData.loadAcquire()->
thread.loadRelaxed() == mainThread());
1227 for (
qsizetype i = 0;
i < extraData->eventFilters.size(); ++
i) {
1231 if (
obj->d_func()->threadData.loadRelaxed() != threadData.loadRelaxed()) {
1232 qWarning(
"QCoreApplication: Application event filter cannot be in a different thread.");
1235 if (
obj->eventFilter(receiver,
event))
1245 for (
qsizetype i = 0;
i < receiver->d_func()->extraData->eventFilters.size(); ++
i) {
1246 QObject *
obj = receiver->d_func()->extraData->eventFilters.at(
i);
1249 if (
obj->d_func()->threadData.loadRelaxed() != receiver->d_func()->threadData.loadRelaxed()) {
1250 qWarning(
"QCoreApplication: Object event filter cannot be in a different thread.");
1253 if (
obj->eventFilter(receiver,
event))
1270 bool consumed =
false;
1271 bool filtered =
false;
1272 Q_TRACE_EXIT(QCoreApplication_notify_exit, consumed, filtered);
1275 if (QCoreApplication::self
1276 && receiver->d_func()->threadData.loadRelaxed()->
thread.loadAcquire() == mainThread()
1277 && QCoreApplication::self->d_func()->sendThroughApplicationEventFilters(receiver,
event)) {
1282 if (sendThroughObjectEventFilters(receiver,
event)) {
1348 if (!
data->hasEventDispatcher())
1350 data->eventDispatcher.loadRelaxed()->processEvents(
flags);
1400 if (!
data->hasEventDispatcher())
1444 QThreadData *threadData = self->d_func()->threadData.loadAcquire();
1446 qWarning(
"%s::exec: Must be called from the main thread", self->metaObject()->className());
1450 qWarning(
"QCoreApplication::exec: The event loop is already running");
1456 self->d_func()->in_exec =
true;
1457 self->d_func()->aboutToQuitEmitted =
false;
1462 self->d_func()->execCleanup();
1475 threadData.loadRelaxed()->
quitNow =
false;
1516 if (!
d->aboutToQuitEmitted) {
1518 d->aboutToQuitEmitted =
true;
1521 data->quitNow =
true;
1524 eventLoop->
exit(returnCode);
1532#ifndef QT_NO_QOBJECT
1549 Q_ASSERT_X(receiver,
"QCoreApplication::sendEvent",
"Unexpected null receiver");
1550 Q_ASSERT_X(
event,
"QCoreApplication::sendEvent",
"Unexpected null event");
1554 event->m_spont =
false;
1555 return notifyInternal2(receiver,
event);
1563 Q_ASSERT_X(receiver,
"QCoreApplication::sendSpontaneousEvent",
"Unexpected null receiver");
1564 Q_ASSERT_X(
event,
"QCoreApplication::sendSpontaneousEvent",
"Unexpected null event");
1568 event->m_spont =
true;
1569 return notifyInternal2(receiver,
event);
1589 locker.
threadData = threadData.loadAcquire();
1596 if (locker.
threadData == threadData.loadAcquire()) {
1597 locker.
locker = std::move(temporaryLocker);
1633 Q_ASSERT_X(
event,
"QCoreApplication::postEvent",
"Unexpected null event");
1638 if (receiver ==
nullptr) {
1639 qWarning(
"QCoreApplication::postEvent: Unexpected null receiver");
1645 if (!locker.threadData) {
1654 if (receiver->d_func()->postedEvents
1656 Q_TRACE(QCoreApplication_postEvent_event_compressed, receiver,
event);
1678 int loopLevel =
data->loopLevel;
1679 int scopeLevel =
data->scopeLevel;
1680 if (scopeLevel == 0 && loopLevel != 0)
1684 deleteEvent->m_loopLevel = loopLevel;
1685 deleteEvent->m_scopeLevel = scopeLevel;
1690 std::unique_ptr<QEvent> eventDeleter(
event);
1691 Q_TRACE(QCoreApplication_postEvent_event_posted, receiver,
event,
event->type());
1694 event->m_posted =
true;
1695 ++receiver->d_func()->postedEvents;
1696 data->canWait =
false;
1718 for (
const QPostEvent &
e : std::as_const(*postedEvents)) {
1741 for (
const QPostEvent &cur : std::as_const(*postedEvents)) {
1742 if (cur.receiver != receiver
1743 || cur.
event ==
nullptr
1744 || cur.event->type() !=
event->type())
1785 if (event_type == -1) {
1790 if (receiver && receiver->d_func()->threadData.loadRelaxed() !=
data) {
1791 qWarning(
"QCoreApplication::sendPostedEvents: Cannot send "
1792 "posted events for objects in another thread");
1796 ++
data->postEventList.recursion;
1798 auto locker = qt_unique_lock(
data->postEventList.mutex);
1803 data->canWait = (
data->postEventList.size() == 0);
1805 if (
data->postEventList.size() == 0 || (receiver && !receiver->d_func()->postedEvents)) {
1806 --
data->postEventList.recursion;
1810 data->canWait =
true;
1815 qsizetype &
i = (!event_type && !receiver) ?
data->postEventList.startOffset : startOffset;
1816 data->postEventList.insertionOffset =
data->postEventList.size();
1823 bool exceptionCaught;
1826 receiver(receiver), event_type(event_type),
data(
data), exceptionCaught(
true)
1830 if (exceptionCaught) {
1832 data->canWait =
false;
1835 --
data->postEventList.recursion;
1836 if (!
data->postEventList.recursion && !
data->canWait &&
data->hasEventDispatcher())
1837 data->eventDispatcher.loadRelaxed()->wakeUp();
1841 if (!event_type && !receiver &&
data->postEventList.startOffset >= 0) {
1842 const QPostEventList::iterator
it =
data->postEventList.
begin();
1843 data->postEventList.erase(
it,
it +
data->postEventList.startOffset);
1844 data->postEventList.insertionOffset -=
data->postEventList.startOffset;
1846 data->postEventList.startOffset = 0;
1850 CleanUp cleanup(receiver, event_type,
data);
1852 while (i < data->postEventList.size()) {
1854 if (
i >=
data->postEventList.insertionOffset)
1862 if ((receiver && receiver != pe.
receiver) || (event_type && event_type != pe.
event->
type())) {
1863 data->canWait =
false;
1877 const bool postedBeforeOutermostLoop = eventLoopLevel == 0;
1878 const bool allowDeferredDelete =
1879 (eventLoopLevel + eventScopeLevel >
data->loopLevel +
data->scopeLevel
1880 || (postedBeforeOutermostLoop &&
data->loopLevel > 0)
1882 && eventLoopLevel + eventScopeLevel ==
data->loopLevel +
data->scopeLevel));
1883 if (!allowDeferredDelete) {
1885 if (!event_type && !receiver) {
1897 data->postEventList.addEvent(pe_copy);
1905 pe.
event->m_posted =
false;
1909 --
r->d_func()->postedEvents;
1910 Q_ASSERT(
r->d_func()->postedEvents >= 0);
1917 const auto relocker =
qScopeGuard([&locker] { locker.lock(); });
1929 cleanup.exceptionCaught =
false;
1960 if (receiver && !receiver->d_func()->postedEvents)
1972 if ((!receiver || pe.
receiver == receiver)
1973 && (pe.
event && (eventType == 0 || pe.
event->
type() == eventType))) {
1974 --pe.
receiver->d_func()->postedEvents;
1975 pe.
event->m_posted =
false;
1978 }
else if (!
data->postEventList.recursion) {
1986 if (receiver && eventType == 0) {
1987 Q_ASSERT(!receiver->d_func()->postedEvents);
1991 if (!
data->postEventList.recursion) {
1993 data->postEventList.erase(
data->postEventList.begin() +
j,
data->postEventList.end());
2017 const auto locker = qt_scoped_lock(
data->postEventList.mutex);
2019 if (
data->postEventList.size() == 0) {
2020#if defined(QT_DEBUG)
2021 qDebug(
"QCoreApplication::removePostedEvent: Internal error: %p %d is posted",
2027 for (
const QPostEvent &pe : std::as_const(
data->postEventList)) {
2028 if (pe.event ==
event) {
2030 qWarning(
"QCoreApplication::removePostedEvent: Event of type %d deleted while posted to %s %s",
2032 pe.receiver->metaObject()->className(),
2033 pe.receiver->objectName().toLocal8Bit().data());
2035 --pe.receiver->d_func()->postedEvents;
2036 pe.event->m_posted =
false;
2063 quitLockRef.deref();
2066 quitAutomatically();
2132 if (!self->d_func()->in_exec)
2135 self->d_func()->
quit();
2167#ifndef QT_NO_TRANSLATION
2198 if (!translationFile)
2206 d->translators.prepend(translationFile);
2209#ifndef QT_NO_TRANSLATION_BUILDER
2210 if (translationFile->
isEmpty())
2214#ifndef QT_NO_QOBJECT
2234 if (!translationFile)
2240 if (
d->translators.removeAll(translationFile)) {
2241#ifndef QT_NO_QOBJECT
2258 while ((percentPos =
result->indexOf(u
'%', percentPos +
len)) != -1) {
2263 if (
result->at(percentPos +
len) == u
'L') {
2271 if (
result->at(percentPos +
len) == u
'n') {
2315 const char *disambiguation,
int n)
2325 if (!
d->translators.isEmpty()) {
2328 for (
it =
d->translators.constBegin();
it !=
d->translators.constEnd(); ++
it) {
2329 translationFile = *
it;
2352 if (!QCoreApplication::self)
2356 return d->translators.contains(translator);
2362 const char *disambiguation,
int n)
2410 qWarning(
"QCoreApplication::applicationDirPath: Please instantiate the QApplication object first");
2415 if (
d->cachedApplicationDirPath.isNull())
2417 return d->cachedApplicationDirPath;
2420#if !defined(Q_OS_WIN) && !defined(Q_OS_DARWIN)
2423# if defined(Q_OS_ANDROID)
2426# elif defined(Q_OS_LINUX)
2429# elif defined(AT_EXECPATH)
2432 if (elf_aux_info(AT_EXECPATH, execfn,
sizeof(execfn)) != 0)
2462 qWarning(
"QCoreApplication::applicationFilePath: Please instantiate the QApplication object first");
2470 if (procName !=
d->argv[0]) {
2484 if (!argv0.
isEmpty() && argv0.
at(0) == u
'/') {
2520#if defined(Q_OS_WIN)
2521 return GetCurrentProcessId();
2522#elif defined(Q_OS_VXWORKS)
2523 return (pid_t) taskIdCurrent;
2565 qWarning(
"QCoreApplication::arguments: Please instantiate the QApplication object first");
2571 const int argc =
d->argc;
2572 char **
const argv =
d->argv;
2575#if defined(Q_OS_WIN)
2576 const bool argsModifiedByUser =
d->origArgv ==
nullptr;
2577 if (!argsModifiedByUser) {
2584 QStringList commandLineArguments = qWinCmdArgs(cmdline);
2589 if (argc !=
d->origArgc) {
2596 for (
int i = 0;
i <
d->origArgc; ++
i) {
2602 return commandLineArguments;
2606 for (
int a = 0;
a < argc; ++
a)
2638 if (coreappdata()->orgName == orgName)
2640 coreappdata()->orgName = orgName;
2641#ifndef QT_NO_QOBJECT
2642 if (QCoreApplication::self)
2649 return coreappdata()->orgName;
2675 if (coreappdata()->orgDomain == orgDomain)
2677 coreappdata()->orgDomain = orgDomain;
2678#ifndef QT_NO_QOBJECT
2679 if (QCoreApplication::self)
2686 return coreappdata()->orgDomain;
2713 coreappdata()->applicationNameSet = !application.
isEmpty();
2714 QString newAppName = application;
2715 if (newAppName.
isEmpty() && QCoreApplication::self)
2716 newAppName = QCoreApplication::self->d_func()->appName();
2717 if (coreappdata()->application == newAppName)
2719 coreappdata()->application = newAppName;
2720#ifndef QT_NO_QOBJECT
2721 if (QCoreApplication::self)
2728 return coreappdata() ? coreappdata()->application :
QString();
2766 coreappdata()->applicationVersionSet = !version.
isEmpty();
2768 if (newVersion.
isEmpty() && QCoreApplication::self)
2769 newVersion = QCoreApplication::self->d_func()->appVersion();
2773#ifndef QT_NO_QOBJECT
2774 if (QCoreApplication::self)
2781 return coreappdata() ? coreappdata()->applicationVersion :
QString();
2784#if QT_CONFIG(permissions) || defined(Q_QDOC)
2874void QCoreApplication::requestPermission(
const QPermission &requestedPermission,
2878 qWarning(lcPermissions,
"Permissions can only be requested from the GUI (main) thread");
2889 static constexpr ushort PermissionReceivedID = 0xffff;
2895 class PermissionReceiver :
public QObject
2906 if (metaCallEvent->id() == PermissionReceivedID) {
2910 slotObject->call(
const_cast<QObject*
>(
context.data()), metaCallEvent->args());
2911 slotObject->destroyIfLastRef();
2923 PermissionReceiver *receiver =
nullptr;
2925 receiver =
new PermissionReceiver(slotObj,
context);
2926 receiver->moveToThread(
context->thread());
2931 "QCoreApplication::requestPermission() should never return Undetermined");
2935 if (QCoreApplication::self) {
2937 permission.m_status = status;
2941 PermissionReceivedID, permission);
2942 qApp->postEvent(receiver, metaCallEvent);
2944 void *argv[] = {
nullptr, &permission };
2956#if QT_CONFIG(library)
2997 return libraryPathsLocked();
3005 if (coreappdata()->manual_libpaths)
3006 return *(coreappdata()->manual_libpaths);
3008 if (!coreappdata()->app_libpaths) {
3010 coreappdata()->app_libpaths.reset(app_libpaths);
3012 auto setPathsFromEnv = [&](
QString libPathEnv) {
3013 if (!libPathEnv.isEmpty()) {
3030 if (CFBundleRef bundleRef = CFBundleGetMainBundle()) {
3033 if (
QCFString path = CFURLCopyFileSystemPath(absoluteUrlRef, kCFURLPOSIXPathStyle)) {
3036 if (!app_libpaths->contains(
path))
3037 app_libpaths->append(
path);
3049 if (!app_libpaths->contains(installPathPlugins))
3050 app_libpaths->append(installPathPlugins);
3055 if (self) self->d_func()->appendApplicationPathToLibraryPaths();
3057 return *(coreappdata()->app_libpaths);
3081 if (!coreappdata()->app_libpaths)
3082 libraryPathsLocked();
3084 if (coreappdata()->manual_libpaths)
3085 *(coreappdata()->manual_libpaths) =
paths;
3090 QFactoryLoader::refreshAll();
3109void QCoreApplication::addLibraryPath(
const QString &
path)
3120 QStringList *libpaths = coreappdata()->manual_libpaths.get();
3126 libraryPathsLocked();
3127 QStringList *app_libpaths = coreappdata()->app_libpaths.get();
3131 coreappdata()->manual_libpaths.reset(libpaths =
new QStringList(*app_libpaths));
3136 QFactoryLoader::refreshAll();
3148void QCoreApplication::removeLibraryPath(
const QString &
path)
3159 QStringList *libpaths = coreappdata()->manual_libpaths.get();
3165 libraryPathsLocked();
3166 QStringList *app_libpaths = coreappdata()->app_libpaths.get();
3170 coreappdata()->manual_libpaths.reset(libpaths =
new QStringList(*app_libpaths));
3175 QFactoryLoader::refreshAll();
3180#ifndef QT_NO_QOBJECT
3214 qWarning(
"Native event filters are not applied when the Qt::AA_PluginApplication attribute is set");
3389#ifndef QT_NO_QOBJECT
3390#include "moc_qcoreapplication.cpp"
static QAbstractEventDispatcher * instance(QThread *thread=nullptr)
Returns a pointer to the event dispatcher object for the specified thread.
virtual void startingUp()
virtual void wakeUp()=0
\threadsafe
void installNativeEventFilter(QAbstractNativeEventFilter *filterObj)
\variable QAbstractEventDispatcher::TimerInfo::timerId
void removeNativeEventFilter(QAbstractNativeEventFilter *filterObj)
Removes the event filter filter from this object.
virtual void closingDown()
Type loadAcquire() const noexcept
Type loadRelaxed() const noexcept
char * data()
\macro QT_NO_CAST_FROM_BYTEARRAY
const char * constData() const noexcept
Returns a pointer to the const data stored in the byte array.
qsizetype indexOf(char c, qsizetype from=0) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
void truncate(qsizetype pos)
Truncates the byte array at index position pos.
bool isEmpty() const noexcept
Returns true if the byte array has size 0; otherwise returns false.
static QByteArray fromRawData(const char *data, qsizetype size)
Constructs a QByteArray that uses the first size bytes of the data array.
The QCommandLineOption class defines a possible command-line option. \inmodule QtCore.
static bool checkInstance(const char *method)
static bool isTranslatorInstalled(QTranslator *translator)
QString appVersion() const
void appendApplicationPathToLibraryPaths(void)
static QPostEventListLocker lockThreadPostEventList(QObject *object)
static void sendPostedEvents(QObject *receiver, int event_type, QThreadData *data)
static bool is_app_closing
~QCoreApplicationPrivate()
QCoreApplicationPrivate(int &aargc, char **aargv)
bool sendThroughApplicationEventFilters(QObject *, QEvent *)
void processCommandLineArguments()
static QString * cachedApplicationFilePath
virtual void eventDispatcherReady()
static bool sendThroughObjectEventFilters(QObject *, QEvent *)
static bool is_app_running
static void checkReceiverThread(QObject *receiver)
static QAbstractEventDispatcher * eventDispatcher
static bool testAttribute(uint flag)
virtual void createEventDispatcher()
static void clearApplicationFilePath()
static bool setuidAllowed
static QThread * mainThread()
static void removePostedEvent(QEvent *)
Removes event from the queue of posted events, and emits a warning message if appropriate.
virtual bool canQuitAutomatically()
static void setApplicationFilePath(const QString &path)
static bool threadRequiresCoreApplication()
static QBasicAtomicPointer< QThread > theMainThread
static bool notify_helper(QObject *, QEvent *)
QString qmljs_debug_arguments
void * resolveInterface(const char *name, int revision) const
\macro Q_DECLARE_TR_FUNCTIONS(context)
static QAbstractEventDispatcher * eventDispatcher()
Returns a pointer to the event dispatcher object for the main thread.
static QString applicationFilePath()
Returns the file path of the application executable.
void organizationDomainChanged()
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
static bool isSetuidAllowed()
bool event(QEvent *) override
\reimp
static void setEventDispatcher(QAbstractEventDispatcher *eventDispatcher)
Sets the event dispatcher for the main thread to eventDispatcher.
virtual bool compressEvent(QEvent *, QObject *receiver, QPostEventList *)
void removeNativeEventFilter(QAbstractNativeEventFilter *filterObj)
Removes an event filterObject from this object.
static void quit()
\threadsafe
virtual bool notify(QObject *, QEvent *)
Sends event to receiver: {receiver}->event(event).
static void removePostedEvents(QObject *receiver, int eventType=0)
static void processEvents(QEventLoop::ProcessEventsFlags flags=QEventLoop::AllEvents)
Processes some pending events for the calling thread according to the specified flags.
static void setOrganizationDomain(const QString &orgDomain)
void applicationNameChanged()
static bool isQuitLockEnabled()
void organizationNameChanged()
static void setAttribute(Qt::ApplicationAttribute attribute, bool on=true)
Sets the attribute attribute if on is true; otherwise clears the attribute.
static QCoreApplication * instance() noexcept
Returns a pointer to the application's QCoreApplication (or QGuiApplication/QApplication) instance.
QString applicationVersion
the version of this application
static bool closingDown()
Returns true if the application objects are being destroyed; otherwise returns false.
static QString translate(const char *context, const char *key, const char *disambiguation=nullptr, int n=-1)
\threadsafe
void installNativeEventFilter(QAbstractNativeEventFilter *filterObj)
Installs an event filter filterObj for all native events received by the application in the main thre...
static bool testAttribute(Qt::ApplicationAttribute attribute)
Returns true if attribute attribute is set; otherwise returns false.
QString organizationName
the name of the organization that wrote this application
static void setOrganizationName(const QString &orgName)
[11]
static void postEvent(QObject *receiver, QEvent *event, int priority=Qt::NormalEventPriority)
void aboutToQuit(QPrivateSignal)
This signal is emitted when the application is about to quit the main event loop, e....
static QString applicationDirPath()
Returns the directory that contains the application executable.
static void setApplicationName(const QString &application)
static int exec()
Enters the main event loop and waits until exit() is called.
static bool installTranslator(QTranslator *messageFile)
Adds the translation file translationFile to the list of translation files to be used for translation...
static bool startingUp()
Returns true if an application object has not been created yet; otherwise returns false.
static qint64 applicationPid() Q_DECL_CONST_FUNCTION
static void setApplicationVersion(const QString &version)
static bool removeTranslator(QTranslator *messageFile)
Removes the translation file translationFile from the list of translation files used by this applicat...
static QStringList arguments()
static void setQuitLockEnabled(bool enabled)
~QCoreApplication()
Destroys the QCoreApplication object.
QString applicationName
the name of this application
void applicationVersionChanged()
static void setSetuidAllowed(bool allow)
static void sendPostedEvents(QObject *receiver=nullptr, int event_type=0)
Immediately dispatches all events which have been previously queued with QCoreApplication::postEvent(...
static void exit(int retcode=0)
Tells the application to exit with a return code.
bool quitLockEnabled
Whether the use of the QEventLoopLocker feature can cause the application to quit.
QString organizationDomain
the Internet domain of the organization that wrote this application
bool hasExpired() const noexcept
Returns true if this QDeadlineTimer object has expired, false if there remains time left.
static QDir current()
Returns the application's current directory.
QString canonicalPath() const
Returns the canonical path, i.e.
QString absoluteFilePath(const QString &fileName) const
Returns the absolute path name of a file in the directory.
static constexpr QChar listSeparator() noexcept
int exec(ProcessEventsFlags flags=AllEvents)
Enters the main event loop and waits until exit() is called.
void exit(int returnCode=0)
Tells the event loop to exit with a return code.
Type
This enum type defines the valid event types in Qt.
Type type() const
Returns the event type.
\inmodule QtCore \reentrant
QString canonicalFilePath() const
Returns the canonical path including the file name, i.e.
QString path() const
Returns the file's path.
static QString decodeName(const QByteArray &localFileName)
This does the reverse of QFile::encodeName() using localFileName.
bool exists() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
static bool activateCallbacks(Callback, void **)
static QString path(LibraryPath p)
qsizetype size() const noexcept
bool isEmpty() const noexcept
qsizetype removeAll(const AT &t)
void prepend(rvalue_ref t)
void reserve(qsizetype size)
void append(parameter_type t)
static QLoggingRegistry * instance()
static QObjectPrivate * get(QObject *o)
QAtomicPointer< QThreadData > threadData
QObject * parent() const
Returns a pointer to the parent object.
void moveToThread(QThread *thread)
Changes the thread affinity for this object and its children.
QString objectName
the name of this object
virtual bool event(QEvent *event)
This virtual function receives events to an object and should return true if the event e was recogniz...
void setParent(QObject *parent)
Makes the object a child of parent.
friend class QCoreApplication
QThread * thread() const
Returns the thread in which the object lives.
QScopedPointer< QObjectData > d_ptr
bool isWidgetType() const
Returns true if the object is a widget; otherwise returns false.
\inmodule QtCore \inheaderfile QPermissions
const_iterator constBegin() const noexcept
const_iterator constEnd() const noexcept
static QString findExecutable(const QString &executableName, const QStringList &paths=QStringList())
\macro QT_RESTRICTED_CAST_FROM_ASCII
qsizetype lastIndexOf(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
void truncate(qsizetype pos)
Truncates the string at the given position index.
static QString fromLocal8Bit(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
const QChar at(qsizetype i) const
Returns the character at the given index position in the string.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
int compare(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
QByteArray toLocal8Bit() const &
bool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
static QString fromWCharArray(const wchar_t *string, qsizetype size=-1)
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
static QString static QString asprintf(const char *format,...) Q_ATTRIBUTE_FORMAT_PRINTF(1
static Q_AUTOTEST_EXPORT QThreadData * current(bool createIfNecessary=true)
QStack< QEventLoop * > eventLoops
static QThreadData * get2(QThread *thread)
QPostEventList postEventList
static QThreadPool * qtGuiInstance()
Returns the QThreadPool instance for Qt Gui.
static QThreadPool * globalInstance()
Returns the global QThreadPool instance.
bool waitForDone(int msecs=-1)
Waits up to msecs milliseconds for all threads to exit and removes all threads from the thread pool.
QAbstractEventDispatcher * eventDispatcher() const
static QThread * currentThread()
void setEventDispatcher(QAbstractEventDispatcher *eventDispatcher)
virtual bool isEmpty() const
Returns true if this translator is empty, otherwise returns false.
virtual QString translate(const char *context, const char *sourceText, const char *disambiguation=nullptr, int n=-1) const
Returns the translation for the key (context, sourceText, disambiguation).
constexpr size_type size() const noexcept
void destroyIfLastRef() noexcept
void call(QObject *r, void **a)
qDeleteAll(list.begin(), list.end())
QSet< QString >::iterator it
void(* StartupCallback)()
void requestPermission(const QPermission &permission, const PermissionCallback &callback)
Qt::PermissionStatus checkPermission(const QPermission &permission)
Combined button and popup list for selecting options.
void initBindingStatusThreadId()
@ AA_SynthesizeMouseForUnhandledTabletEvents
@ AA_SynthesizeMouseForUnhandledTouchEvents
#define Q_BASIC_ATOMIC_INITIALIZER(a)
size_t qstrlen(const char *str)
Q_CORE_EXPORT int qstricmp(const char *, const char *)
Q_CORE_EXPORT int qstrcmp(const char *str1, const char *str2)
#define QT_MAKE_CHECKED_ARRAY_ITERATOR(x, N)
#define Q_DECL_EXPORT_OVERRIDABLE
QT_BEGIN_NAMESPACE QByteArray qt_readlink(const char *path)
void qAddPreRoutine(QtStartUpFunction p)
void Q_DECL_EXPORT_OVERRIDABLE qt_startup_hook()
static Q_CONSTINIT bool preRoutinesCalled
static Q_CONSTINIT bool quitLockEnabled
static QString qAppFileName()
void qAddPostRoutine(QtCleanUpFunction p)
static void qt_call_pre_routines()
qsizetype qGlobalPostedEventsCount()
static Q_CONSTINIT QBasicMutex globalRoutinesMutex
static bool doNotify(QObject *, QEvent *)
QList< QtStartUpFunction > QStartUpFuncList
static void replacePercentN(QString *result, int n)
void Q_CORE_EXPORT qt_call_post_routines()
void qRemovePostRoutine(QtCleanUpFunction p)
void(* QtCleanUpFunction)()
void(* QtStartUpFunction)()
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction function
EGLOutputLayerEXT EGLint attribute
#define Q_GLOBAL_STATIC(TYPE, NAME,...)
QT_BEGIN_NAMESPACE quintptr Q_CORE_EXPORT qtHookData[]
static bool contains(const QJsonArray &haystack, unsigned needle)
GLboolean GLboolean GLboolean b
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLsizei const GLuint * paths
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLdouble GLdouble GLdouble GLdouble q
GLsizei const GLchar *const * path
static qreal dot(const QPointF &a, const QPointF &b)
#define Q_ASSERT_X(cond, x, msg)
QScopeGuard< typename std::decay< F >::type > qScopeGuard(F &&f)
[qScopeGuard]
static QString canonicalPath(const QString &rootPath)
#define qUtf16Printable(string)
static char * toLocal8Bit(char *out, QStringView in, QStringConverter::State *state)
#define QStringLiteral(str)
QString qEnvironmentVariable(const char *varName, const QString &defaultValue)
#define Q_TRACE_METADATA(provider, metadata)
#define Q_TRACE_PREFIX(provider, prefix)
#define Q_TRACE_SCOPE(x,...)
#define Q_TRACE_INSTRUMENT(provider)
#define Q_TRACE_EXIT(x,...)
#define Q_TRACE_POINT(provider, tracepoint,...)
Q_CORE_EXPORT QString qtTrId(const char *id, int n=-1)
QVideoFrameFormat::PixelFormat fmt
if(qFloatDistance(a, b)<(1<< 7))
[0]
QTextStream out(stdout)
[7]
QDeadlineTimer deadline(30s)
QString applicationVersion
QCoreApplicationData() noexcept
bool applicationVersionSet
std::unique_lock< QMutex > locker