From 17ad6e2a93f93aaa948c1286b3cad785e7f38808 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 13 Apr 2016 14:09:35 +0200 Subject: Fix build when Qt is used in an automatic reference-counted environment When automatic reference-counting (ARC) is enabled on Darwin platforms the NSAutoReleasePool class should not be used directly, which caused a build error if qglobal.h was included after the Foundation.h in client code. The preferred alternative for ARC is the scoped @autoreleasepool construct, which allows the compiler to reason about needing to insert _objc_autoreleasePoolPush and _objc_autoreleasePoolPop calls. Note that ARC translation units can be combined with non-ARC translation units, so Qt and the QMacAutoReleasePool class can still be used in ARC client code even if Qt is not built with ARC. Task-number: QTBUG-51332 Change-Id: I7ef1c3146aa416a9d6a1dc299ce7b17f22f889e5 Reviewed-by: Simon Hausmann Reviewed-by: Richard Moe Gustavsen --- src/corelib/global/qglobal.h | 6 +----- src/corelib/kernel/qcore_mac_objc.mm | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 98c9902674..5bb1ce77bd 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -579,10 +579,6 @@ Q_DECL_CONSTEXPR inline const T &qBound(const T &min, const T &val, const T &max # define QT_OSX_DEPLOYMENT_TARGET_BELOW(osx) \ QT_MAC_DEPLOYMENT_TARGET_BELOW(osx, __IPHONE_NA) -QT_END_NAMESPACE -Q_FORWARD_DECLARE_OBJC_CLASS(NSAutoreleasePool); -QT_BEGIN_NAMESPACE - // Implemented in qcore_mac_objc.mm class Q_CORE_EXPORT QMacAutoReleasePool { @@ -591,7 +587,7 @@ public: ~QMacAutoReleasePool(); private: Q_DISABLE_COPY(QMacAutoReleasePool) - NSAutoreleasePool *pool; + void *pool; }; #endif // Q_OS_MAC diff --git a/src/corelib/kernel/qcore_mac_objc.mm b/src/corelib/kernel/qcore_mac_objc.mm index 1a2b047041..e1480a36d5 100644 --- a/src/corelib/kernel/qcore_mac_objc.mm +++ b/src/corelib/kernel/qcore_mac_objc.mm @@ -150,7 +150,7 @@ QMacAutoReleasePool::~QMacAutoReleasePool() // Drain behaves the same as release, with the advantage that // if we're ever used in a garbage-collected environment, the // drain acts as a hint to the garbage collector to collect. - [pool drain]; + [static_cast(pool) drain]; } // ------------------------------------------------------------------------- -- cgit v1.2.3