summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qcoreapplication_p.h
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2017-04-20 18:02:16 +0200
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2017-05-08 11:01:39 +0000
commit4a5a4245b7f24b53847e96f1eee5445bdae537e6 (patch)
treec9c4d42fc00df2cd9e12dd2a9224db28b31c70b8 /src/corelib/kernel/qcoreapplication_p.h
parenta6f3bb21e3cfcbd8ba3356fb509b465041c35858 (diff)
macOS: Add root level NSAutoreleasePool for objects autoreleased in main()
Any objects directly or indirectly autoreleased in main(), before we start the event loop, will never be released, as there are no pools present yet. This includes all resources allocated during application and window setup, unless those function have local pools. Ideally that setup code would be called from within the runloop callstack, where there is a pool present, but that requires a new main/startup-API for Qt. To aid in debugging object ownership and hierarchies within Qt, we set up our own root level pool tied to QApplication, which ensures that most objects autoreleased in main() will eventually be released and have their dealloc methods called. The feature can be disabled by setting an environment variable: QT_DISABLE_ROOT_LEVEL_AUTORELEASE_POOL=1 Combined with OBJC_DEBUG_MISSING_POOLS=YES, this allows breaking on the function objc_autoreleaseNoPool to weed out codepaths in Qt that should have local pools. Change-Id: Id02e1edaaaeaa04c53862d7228e519214c99ab51 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Diffstat (limited to 'src/corelib/kernel/qcoreapplication_p.h')
-rw-r--r--src/corelib/kernel/qcoreapplication_p.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/corelib/kernel/qcoreapplication_p.h b/src/corelib/kernel/qcoreapplication_p.h
index c646786296..da6ce1249f 100644
--- a/src/corelib/kernel/qcoreapplication_p.h
+++ b/src/corelib/kernel/qcoreapplication_p.h
@@ -58,6 +58,10 @@
#include "private/qobject_p.h"
#endif
+#ifdef Q_OS_MACOS
+#include "private/qcore_mac_p.h"
+#endif
+
QT_BEGIN_NAMESPACE
typedef QList<QTranslator*> QTranslatorList;
@@ -85,6 +89,10 @@ public:
QString appName() const;
QString appVersion() const;
+#ifdef Q_OS_MACOS
+ QMacRootLevelAutoReleasePool autoReleasePool;
+#endif
+
#ifdef Q_OS_DARWIN
static QString infoDictionaryStringProperty(const QString &propertyName);
#endif