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 <simon.hausmann@theqtcompany.com> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@theqtcompany.com>
This commit is contained in:
parent
96ff51f856
commit
17ad6e2a93
@ -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
|
||||
|
@ -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<NSAutoreleasePool*>(pool) drain];
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user