Add shared implementation of a NSAutoreleasePool wrapper to qglobal
We have at least 5 different (but equal) implementations of a wrapper in Qt, and some code uses explicit NSAutoreleasePools. Having a shared implementation lets us clean up things a bit and makes it easier to reason about which pools are actually needed. Change-Id: I2fd8eefc3ae7308595ef9899b7820206268362a5 Reviewed-by: Tim Blechmann <tim@klingt.org> Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>bb10
parent
5f21aa22fb
commit
5471413522
|
|
@ -321,6 +321,15 @@ typedef double qreal;
|
|||
# define Q_NETWORK_EXPORT
|
||||
#endif
|
||||
|
||||
/*
|
||||
Some classes do not permit copies to be made of an object. These
|
||||
classes contains a private copy constructor and assignment
|
||||
operator to disable copying (the compiler gives an error message).
|
||||
*/
|
||||
#define Q_DISABLE_COPY(Class) \
|
||||
Class(const Class &) Q_DECL_EQ_DELETE;\
|
||||
Class &operator=(const Class &) Q_DECL_EQ_DELETE;
|
||||
|
||||
/*
|
||||
No, this is not an evil backdoor. QT_BUILD_INTERNAL just exports more symbols
|
||||
for Qt's internal unit tests. If you want slower loading times and more
|
||||
|
|
@ -543,7 +552,21 @@ template <typename T>
|
|||
Q_DECL_CONSTEXPR inline const T &qBound(const T &min, const T &val, const T &max)
|
||||
{ return qMax(min, qMin(max, val)); }
|
||||
|
||||
#ifdef Q_OS_DARWIN
|
||||
#ifndef Q_FORWARD_DECLARE_OBJC_CLASS
|
||||
# ifdef __OBJC__
|
||||
# define Q_FORWARD_DECLARE_OBJC_CLASS(classname) @class classname
|
||||
# else
|
||||
# define Q_FORWARD_DECLARE_OBJC_CLASS(classname) typedef struct objc_object classname
|
||||
# endif
|
||||
#endif
|
||||
#ifndef Q_FORWARD_DECLARE_CF_TYPE
|
||||
# define Q_FORWARD_DECLARE_CF_TYPE(type) typedef const struct __ ## type * type ## Ref
|
||||
#endif
|
||||
#ifndef Q_FORWARD_DECLARE_MUTABLE_CF_TYPE
|
||||
# define Q_FORWARD_DECLARE_MUTABLE_CF_TYPE(type) typedef struct __ ## type * type ## Ref
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
# define QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(osx, ios) \
|
||||
((defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && osx != __MAC_NA && __MAC_OS_X_VERSION_MAX_ALLOWED >= osx) || \
|
||||
(defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && ios != __IPHONE_NA && __IPHONE_OS_VERSION_MAX_ALLOWED >= ios))
|
||||
|
|
@ -561,7 +584,21 @@ Q_DECL_CONSTEXPR inline const T &qBound(const T &min, const T &val, const T &max
|
|||
QT_MAC_DEPLOYMENT_TARGET_BELOW(__MAC_NA, ios)
|
||||
# define QT_OSX_DEPLOYMENT_TARGET_BELOW(osx) \
|
||||
QT_MAC_DEPLOYMENT_TARGET_BELOW(osx, __IPHONE_NA)
|
||||
#endif
|
||||
|
||||
Q_FORWARD_DECLARE_OBJC_CLASS(NSAutoreleasePool);
|
||||
|
||||
// Implemented in qcore_mac_objc.mm
|
||||
class Q_CORE_EXPORT QMacAutoReleasePool
|
||||
{
|
||||
public:
|
||||
QMacAutoReleasePool();
|
||||
~QMacAutoReleasePool();
|
||||
private:
|
||||
Q_DISABLE_COPY(QMacAutoReleasePool);
|
||||
NSAutoreleasePool *pool;
|
||||
};
|
||||
|
||||
#endif // Q_OS_MAC
|
||||
|
||||
/*
|
||||
Data stream functions are provided by many classes (defined in qdatastream.h)
|
||||
|
|
@ -1033,15 +1070,6 @@ Q_CORE_EXPORT QString qtTrId(const char *id, int n = -1);
|
|||
{ return T::dynamic_cast_will_always_fail_because_rtti_is_disabled; }
|
||||
#endif
|
||||
|
||||
/*
|
||||
Some classes do not permit copies to be made of an object. These
|
||||
classes contains a private copy constructor and assignment
|
||||
operator to disable copying (the compiler gives an error message).
|
||||
*/
|
||||
#define Q_DISABLE_COPY(Class) \
|
||||
Class(const Class &) Q_DECL_EQ_DELETE;\
|
||||
Class &operator=(const Class &) Q_DECL_EQ_DELETE;
|
||||
|
||||
class QByteArray;
|
||||
Q_CORE_EXPORT QByteArray qgetenv(const char *varName);
|
||||
Q_CORE_EXPORT bool qputenv(const char *varName, const QByteArray& value);
|
||||
|
|
@ -1076,20 +1104,6 @@ template <bool B, typename T, typename F> struct QConditional { typedef T Type;
|
|||
template <typename T, typename F> struct QConditional<false, T, F> { typedef F Type; };
|
||||
}
|
||||
|
||||
#ifndef Q_FORWARD_DECLARE_OBJC_CLASS
|
||||
# ifdef __OBJC__
|
||||
# define Q_FORWARD_DECLARE_OBJC_CLASS(classname) @class classname
|
||||
# else
|
||||
# define Q_FORWARD_DECLARE_OBJC_CLASS(classname) typedef struct objc_object classname
|
||||
# endif
|
||||
#endif
|
||||
#ifndef Q_FORWARD_DECLARE_CF_TYPE
|
||||
# define Q_FORWARD_DECLARE_CF_TYPE(type) typedef const struct __ ## type * type ## Ref
|
||||
#endif
|
||||
#ifndef Q_FORWARD_DECLARE_MUTABLE_CF_TYPE
|
||||
# define Q_FORWARD_DECLARE_MUTABLE_CF_TYPE(type) typedef struct __ ## type * type ## Ref
|
||||
#endif
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
// We need to keep QTypeInfo, QSysInfo, QFlags, qDebug & family in qglobal.h for compatibility with Qt 4.
|
||||
|
|
|
|||
|
|
@ -56,25 +56,6 @@
|
|||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
namespace {
|
||||
class RaiiAutoreleasePool
|
||||
{
|
||||
Q_DISABLE_COPY(RaiiAutoreleasePool)
|
||||
|
||||
public:
|
||||
RaiiAutoreleasePool()
|
||||
: pool([[NSAutoreleasePool alloc] init])
|
||||
{}
|
||||
|
||||
~RaiiAutoreleasePool()
|
||||
{ [pool release]; }
|
||||
|
||||
private:
|
||||
NSAutoreleasePool *pool;
|
||||
};
|
||||
#define Q_AUTORELEASE_POOL(pool) RaiiAutoreleasePool pool; Q_UNUSED(pool);
|
||||
}
|
||||
|
||||
static void callBackFunction(ConstFSEventStreamRef streamRef,
|
||||
void *clientCallBackInfo,
|
||||
size_t numEvents,
|
||||
|
|
@ -82,7 +63,7 @@ static void callBackFunction(ConstFSEventStreamRef streamRef,
|
|||
const FSEventStreamEventFlags eventFlags[],
|
||||
const FSEventStreamEventId eventIds[])
|
||||
{
|
||||
Q_AUTORELEASE_POOL(pool)
|
||||
QMacAutoReleasePool pool;
|
||||
|
||||
char **paths = static_cast<char **>(eventPaths);
|
||||
QFseventsFileSystemWatcherEngine *engine = static_cast<QFseventsFileSystemWatcherEngine *>(clientCallBackInfo);
|
||||
|
|
@ -297,7 +278,7 @@ void QFseventsFileSystemWatcherEngine::doEmitDirectoryChanged(const QString &pat
|
|||
|
||||
void QFseventsFileSystemWatcherEngine::restartStream()
|
||||
{
|
||||
Q_AUTORELEASE_POOL(pool)
|
||||
QMacAutoReleasePool pool;
|
||||
QMutexLocker locker(&lock);
|
||||
stopStream();
|
||||
startStream();
|
||||
|
|
@ -328,7 +309,7 @@ QFseventsFileSystemWatcherEngine::QFseventsFileSystemWatcherEngine(QObject *pare
|
|||
|
||||
QFseventsFileSystemWatcherEngine::~QFseventsFileSystemWatcherEngine()
|
||||
{
|
||||
Q_AUTORELEASE_POOL(pool)
|
||||
QMacAutoReleasePool pool;
|
||||
|
||||
if (stream)
|
||||
FSEventStreamStop(stream);
|
||||
|
|
@ -344,7 +325,7 @@ QStringList QFseventsFileSystemWatcherEngine::addPaths(const QStringList &paths,
|
|||
QStringList *files,
|
||||
QStringList *directories)
|
||||
{
|
||||
Q_AUTORELEASE_POOL(pool)
|
||||
QMacAutoReleasePool pool;
|
||||
|
||||
if (stream) {
|
||||
DEBUG("Flushing, last id is %llu", FSEventStreamGetLatestEventId(stream));
|
||||
|
|
@ -432,7 +413,7 @@ QStringList QFseventsFileSystemWatcherEngine::removePaths(const QStringList &pat
|
|||
QStringList *files,
|
||||
QStringList *directories)
|
||||
{
|
||||
Q_AUTORELEASE_POOL(pool)
|
||||
QMacAutoReleasePool pool;
|
||||
|
||||
QMutexLocker locker(&lock);
|
||||
|
||||
|
|
@ -489,7 +470,7 @@ QStringList QFseventsFileSystemWatcherEngine::removePaths(const QStringList &pat
|
|||
bool QFseventsFileSystemWatcherEngine::startStream()
|
||||
{
|
||||
Q_ASSERT(stream == 0);
|
||||
Q_AUTORELEASE_POOL(pool)
|
||||
QMacAutoReleasePool pool;
|
||||
if (stream) // This shouldn't happen, but let's be nice and handle it.
|
||||
stopStream();
|
||||
|
||||
|
|
|
|||
|
|
@ -131,5 +131,22 @@ QAppleOperatingSystemVersion qt_apple_os_version()
|
|||
return v;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
QMacAutoReleasePool::QMacAutoReleasePool()
|
||||
: pool([[NSAutoreleasePool alloc] init])
|
||||
{
|
||||
}
|
||||
|
||||
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];
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
|
|
|
|||
|
|
@ -44,18 +44,6 @@
|
|||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
namespace {
|
||||
class AutoReleasePool
|
||||
{
|
||||
public:
|
||||
AutoReleasePool(): pool([[NSAutoreleasePool alloc] init]) {}
|
||||
~AutoReleasePool() { [pool release]; }
|
||||
|
||||
private:
|
||||
NSAutoreleasePool *pool;
|
||||
};
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
** Wrappers for Mac locale system functions
|
||||
*/
|
||||
|
|
@ -426,7 +414,7 @@ QLocale QSystemLocale::fallbackUiLocale() const
|
|||
|
||||
QVariant QSystemLocale::query(QueryType type, QVariant in = QVariant()) const
|
||||
{
|
||||
AutoReleasePool pool;
|
||||
QMacAutoReleasePool pool;
|
||||
switch(type) {
|
||||
// case Name:
|
||||
// return getMacLocaleName();
|
||||
|
|
|
|||
|
|
@ -48,18 +48,6 @@
|
|||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
namespace {
|
||||
class AutoReleasePool
|
||||
{
|
||||
public:
|
||||
AutoReleasePool(): pool([[NSAutoreleasePool alloc] init]) {}
|
||||
~AutoReleasePool() { [pool release]; }
|
||||
|
||||
private:
|
||||
NSAutoreleasePool *pool;
|
||||
};
|
||||
}
|
||||
|
||||
// this could become a list of all languages used for each writing
|
||||
// system, instead of using the single most common language.
|
||||
static const char *languageForWritingSystem[] = {
|
||||
|
|
@ -453,7 +441,7 @@ QStringList QCoreTextFontDatabase::fallbacksForFamily(const QString &family, QFo
|
|||
Q_UNUSED(style);
|
||||
Q_UNUSED(script);
|
||||
|
||||
AutoReleasePool pool;
|
||||
QMacAutoReleasePool pool;
|
||||
|
||||
static QHash<QString, QStringList> fallbackLists;
|
||||
|
||||
|
|
|
|||
|
|
@ -76,12 +76,11 @@ extern "C" { // Otherwise it won't find CWKeychain* symbols at link time
|
|||
- (id) init
|
||||
{
|
||||
[locker lock];
|
||||
NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
|
||||
QMacAutoReleasePool pool;
|
||||
notificationCenter = [NSNotificationCenter defaultCenter];
|
||||
currentInterface = [CWInterface interfaceWithName:nil];
|
||||
[notificationCenter addObserver:self selector:@selector(notificationHandler:) name:CWPowerDidChangeNotification object:nil];
|
||||
[locker unlock];
|
||||
[autoreleasepool release];
|
||||
return self;
|
||||
}
|
||||
|
||||
|
|
@ -151,7 +150,7 @@ void QScanThread::quit()
|
|||
|
||||
void QScanThread::run()
|
||||
{
|
||||
NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
|
||||
QMacAutoReleasePool pool;
|
||||
QStringList found;
|
||||
mutex.lock();
|
||||
CWInterface *currentInterface = [CWInterface interfaceWithName: QCFString::toNSString(interfaceName)];
|
||||
|
|
@ -233,7 +232,6 @@ void QScanThread::run()
|
|||
}
|
||||
}
|
||||
emit networksChanged();
|
||||
[autoreleasepool release];
|
||||
}
|
||||
|
||||
QStringList QScanThread::foundNetwork(const QString &id, const QString &name, const QNetworkConfiguration::StateFlags state, const QString &interfaceName, const QNetworkConfiguration::Purpose purpose)
|
||||
|
|
@ -273,7 +271,7 @@ void QScanThread::getUserConfigurations()
|
|||
{
|
||||
QMutexLocker locker(&mutex);
|
||||
|
||||
NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
|
||||
QMacAutoReleasePool pool;
|
||||
userProfiles.clear();
|
||||
|
||||
NSSet *wifiInterfaces = [CWInterface interfaceNames];
|
||||
|
|
@ -354,7 +352,6 @@ void QScanThread::getUserConfigurations()
|
|||
}
|
||||
}
|
||||
}
|
||||
[autoreleasepool release];
|
||||
}
|
||||
|
||||
QString QScanThread::getSsidFromNetworkName(const QString &name)
|
||||
|
|
@ -433,7 +430,7 @@ QCoreWlanEngine::~QCoreWlanEngine()
|
|||
void QCoreWlanEngine::initialize()
|
||||
{
|
||||
QMutexLocker locker(&mutex);
|
||||
NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
|
||||
QMacAutoReleasePool pool;
|
||||
|
||||
if ([[CWInterface interfaceNames] count] > 0 && !listener) {
|
||||
listener = [[QT_MANGLE_NAMESPACE(QNSListener) alloc] init];
|
||||
|
|
@ -445,7 +442,6 @@ void QCoreWlanEngine::initialize()
|
|||
storeSession = NULL;
|
||||
|
||||
startNetworkChangeLoop();
|
||||
[autoreleasepool release];
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -466,7 +462,7 @@ bool QCoreWlanEngine::hasIdentifier(const QString &id)
|
|||
void QCoreWlanEngine::connectToId(const QString &id)
|
||||
{
|
||||
QMutexLocker locker(&mutex);
|
||||
NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
|
||||
QMacAutoReleasePool pool;
|
||||
QString interfaceString = getInterfaceFromId(id);
|
||||
|
||||
CWInterface *wifiInterface =
|
||||
|
|
@ -538,7 +534,6 @@ void QCoreWlanEngine::connectToId(const QString &id)
|
|||
|
||||
locker.unlock();
|
||||
emit connectionError(id, InterfaceLookupError);
|
||||
[autoreleasepool release];
|
||||
}
|
||||
|
||||
void QCoreWlanEngine::disconnectFromId(const QString &id)
|
||||
|
|
@ -551,7 +546,7 @@ void QCoreWlanEngine::disconnectFromId(const QString &id)
|
|||
emit connectionError(id, DisconnectionError);
|
||||
return;
|
||||
}
|
||||
NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
|
||||
QMacAutoReleasePool pool;
|
||||
|
||||
CWInterface *wifiInterface =
|
||||
[CWInterface interfaceWithName: QCFString::toNSString(interfaceString)];
|
||||
|
|
@ -560,14 +555,13 @@ void QCoreWlanEngine::disconnectFromId(const QString &id)
|
|||
[wifiInterface disassociate];
|
||||
|
||||
QTimer::singleShot(1000, this,SLOT(checkDisconnect()));
|
||||
[autoreleasepool release];
|
||||
}
|
||||
|
||||
void QCoreWlanEngine::checkDisconnect()
|
||||
{
|
||||
QMutexLocker locker(&mutex);
|
||||
if (!disconnectedInterfaceString.isEmpty()) {
|
||||
NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
|
||||
QMacAutoReleasePool pool;
|
||||
|
||||
CWInterface *wifiInterface =
|
||||
[CWInterface interfaceWithName: QCFString::toNSString(disconnectedInterfaceString)];
|
||||
|
|
@ -579,7 +573,6 @@ void QCoreWlanEngine::checkDisconnect()
|
|||
emit connectionError(id, DisconnectionError);
|
||||
locker.relock();
|
||||
}
|
||||
[autoreleasepool release];
|
||||
disconnectedInterfaceString.clear();
|
||||
}
|
||||
}
|
||||
|
|
@ -594,7 +587,7 @@ void QCoreWlanEngine::doRequestUpdate()
|
|||
{
|
||||
QMutexLocker locker(&mutex);
|
||||
|
||||
NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
|
||||
QMacAutoReleasePool pool;
|
||||
|
||||
NSSet *wifiInterfaces = [CWInterface interfaceNames];
|
||||
for (NSString *ifName in wifiInterfaces) {
|
||||
|
|
@ -604,7 +597,6 @@ void QCoreWlanEngine::doRequestUpdate()
|
|||
locker.unlock();
|
||||
if ([wifiInterfaces count] == 0)
|
||||
networksChanged();
|
||||
[autoreleasepool release];
|
||||
}
|
||||
|
||||
bool QCoreWlanEngine::isWifiReady(const QString &wifiDeviceName)
|
||||
|
|
@ -612,12 +604,11 @@ bool QCoreWlanEngine::isWifiReady(const QString &wifiDeviceName)
|
|||
QMutexLocker locker(&mutex);
|
||||
bool haswifi = false;
|
||||
if(hasWifi) {
|
||||
NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
|
||||
QMacAutoReleasePool pool;
|
||||
CWInterface *defaultInterface = [CWInterface interfaceWithName: QCFString::toNSString(wifiDeviceName)];
|
||||
if (defaultInterface.powerOn) {
|
||||
haswifi = true;
|
||||
}
|
||||
[autoreleasepool release];
|
||||
}
|
||||
return haswifi;
|
||||
}
|
||||
|
|
@ -811,7 +802,7 @@ quint64 QCoreWlanEngine::bytesReceived(const QString &id)
|
|||
quint64 QCoreWlanEngine::startTime(const QString &identifier)
|
||||
{
|
||||
QMutexLocker locker(&mutex);
|
||||
NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
|
||||
QMacAutoReleasePool pool;
|
||||
quint64 timestamp = 0;
|
||||
|
||||
NSString *filePath = @"/Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist";
|
||||
|
|
@ -858,7 +849,6 @@ quint64 QCoreWlanEngine::startTime(const QString &identifier)
|
|||
}
|
||||
}
|
||||
}
|
||||
[autoreleasepool release];
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ OBJECTIVE_SOURCES += main.mm \
|
|||
qcocoawindow.mm \
|
||||
qnsview.mm \
|
||||
qnsviewaccessibility.mm \
|
||||
qcocoaautoreleasepool.mm \
|
||||
qnswindowdelegate.mm \
|
||||
qcocoanativeinterface.mm \
|
||||
qcocoaeventdispatcher.mm \
|
||||
|
|
@ -48,7 +47,6 @@ HEADERS += qcocoaintegration.h \
|
|||
qcocoabackingstore.h \
|
||||
qcocoawindow.h \
|
||||
qnsview.h \
|
||||
qcocoaautoreleasepool.h \
|
||||
qnswindowdelegate.h \
|
||||
qcocoanativeinterface.h \
|
||||
qcocoaeventdispatcher.h \
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ QPlatformIntegration * QCocoaIntegrationPlugin::create(const QString& system, co
|
|||
{
|
||||
Q_UNUSED(paramList);
|
||||
|
||||
QCocoaAutoReleasePool pool;
|
||||
QMacAutoReleasePool pool;
|
||||
if (system.compare(QLatin1String("cocoa"), Qt::CaseInsensitive) == 0)
|
||||
return new QCocoaIntegration;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,53 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the plugins of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL21$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** As a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QCOCOAAUTORELEASEPOOL_H
|
||||
#define QCOCOAAUTORELEASEPOOL_H
|
||||
|
||||
#undef slots
|
||||
#include <qglobal.h>
|
||||
#include <Cocoa/Cocoa.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QCocoaAutoReleasePool
|
||||
{
|
||||
public:
|
||||
QCocoaAutoReleasePool();
|
||||
~QCocoaAutoReleasePool();
|
||||
|
||||
private:
|
||||
NSAutoreleasePool *pool;
|
||||
};
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QCOCOAAUTORELEASEPOOL_H
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the plugins of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL21$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see http://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at http://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** As a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qcocoaautoreleasepool.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QCocoaAutoReleasePool::QCocoaAutoReleasePool()
|
||||
{
|
||||
pool = [[NSAutoreleasePool alloc] init];
|
||||
}
|
||||
|
||||
QCocoaAutoReleasePool::~QCocoaAutoReleasePool()
|
||||
{
|
||||
[pool release];
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
@ -34,7 +34,6 @@
|
|||
#include "qcocoacursor.h"
|
||||
#include "qcocoawindow.h"
|
||||
#include "qcocoahelpers.h"
|
||||
#include "qcocoaautoreleasepool.h"
|
||||
|
||||
#include <QtGui/QBitmap>
|
||||
|
||||
|
|
|
|||
|
|
@ -66,7 +66,6 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include "qcocoaeventdispatcher.h"
|
||||
#include "qcocoaautoreleasepool.h"
|
||||
#include "qcocoawindow.h"
|
||||
|
||||
#include "qcocoahelpers.h"
|
||||
|
|
@ -364,7 +363,7 @@ bool QCocoaEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags)
|
|||
if (d->interrupt)
|
||||
break;
|
||||
|
||||
QCocoaAutoReleasePool pool;
|
||||
QMacAutoReleasePool pool;
|
||||
NSEvent* event = 0;
|
||||
|
||||
// First, send all previously excluded input events, if any:
|
||||
|
|
@ -622,7 +621,7 @@ NSModalSession QCocoaEventDispatcherPrivate::currentModalSession()
|
|||
continue;
|
||||
|
||||
if (!info.session) {
|
||||
QCocoaAutoReleasePool pool;
|
||||
QMacAutoReleasePool pool;
|
||||
QCocoaWindow *cocoaWindow = static_cast<QCocoaWindow *>(info.window->handle());
|
||||
NSWindow *nswindow = cocoaWindow->nativeWindow();
|
||||
if (!nswindow)
|
||||
|
|
@ -670,7 +669,7 @@ void QCocoaEventDispatcherPrivate::updateChildrenWorksWhenModal()
|
|||
// Make the dialog children of the window
|
||||
// active. And make the dialog children of
|
||||
// the previous modal dialog unactive again:
|
||||
QCocoaAutoReleasePool pool;
|
||||
QMacAutoReleasePool pool;
|
||||
int size = cocoaModalSessionStack.size();
|
||||
if (size > 0){
|
||||
if (QWindow *prevModal = cocoaModalSessionStack[size-1].window)
|
||||
|
|
@ -691,7 +690,7 @@ void QCocoaEventDispatcherPrivate::cleanupModalSessions()
|
|||
// point they were marked as stopped), is that ending a session
|
||||
// when no other session runs below it on the stack will make cocoa
|
||||
// drop some events on the floor.
|
||||
QCocoaAutoReleasePool pool;
|
||||
QMacAutoReleasePool pool;
|
||||
int stackSize = cocoaModalSessionStack.size();
|
||||
|
||||
for (int i=stackSize-1; i>=0; --i) {
|
||||
|
|
@ -926,7 +925,7 @@ void QCocoaEventDispatcherPrivate::cancelWaitForMoreEvents()
|
|||
{
|
||||
// In case the event dispatcher is waiting for more
|
||||
// events somewhere, we post a dummy event to wake it up:
|
||||
QCocoaAutoReleasePool pool;
|
||||
QMacAutoReleasePool pool;
|
||||
[NSApp postEvent:[NSEvent otherEventWithType:NSApplicationDefined location:NSZeroPoint
|
||||
modifierFlags:0 timestamp:0. windowNumber:0 context:0
|
||||
subtype:QtCocoaEventSubTypeWakeup data1:0 data2:0] atStart:NO];
|
||||
|
|
|
|||
|
|
@ -53,7 +53,6 @@
|
|||
#include <qvarlengtharray.h>
|
||||
#include <stdlib.h>
|
||||
#include <qabstracteventdispatcher.h>
|
||||
#include "qcocoaautoreleasepool.h"
|
||||
#include <QDir>
|
||||
|
||||
#include <qpa/qplatformnativeinterface.h>
|
||||
|
|
@ -557,7 +556,7 @@ QCocoaFileDialogHelper::~QCocoaFileDialogHelper()
|
|||
{
|
||||
if (!mDelegate)
|
||||
return;
|
||||
QCocoaAutoReleasePool pool;
|
||||
QMacAutoReleasePool pool;
|
||||
[mDelegate release];
|
||||
mDelegate = 0;
|
||||
}
|
||||
|
|
@ -687,7 +686,7 @@ bool QCocoaFileDialogHelper::show(Qt::WindowFlags windowFlags, Qt::WindowModalit
|
|||
|
||||
void QCocoaFileDialogHelper::createNSOpenSavePanelDelegate()
|
||||
{
|
||||
QCocoaAutoReleasePool pool;
|
||||
QMacAutoReleasePool pool;
|
||||
|
||||
const SharedPointerFileDialogOptions &opts = options();
|
||||
const QList<QUrl> selectedFiles = opts->initiallySelectedFiles();
|
||||
|
|
@ -737,7 +736,7 @@ void QCocoaFileDialogHelper::exec()
|
|||
// QEventLoop has been interrupted, and the second-most event loop has not
|
||||
// yet been reactivated (regardless if [NSApp run] is still on the stack)),
|
||||
// showing a native modal dialog will fail.
|
||||
QCocoaAutoReleasePool pool;
|
||||
QMacAutoReleasePool pool;
|
||||
if ([mDelegate runApplicationModalPanel])
|
||||
emit accept();
|
||||
else
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@
|
|||
|
||||
#include "qcocoaglcontext.h"
|
||||
#include "qcocoawindow.h"
|
||||
#include "qcocoaautoreleasepool.h"
|
||||
#include "qcocoahelpers.h"
|
||||
#include <qdebug.h>
|
||||
#include <QtCore/private/qcore_mac_p.h>
|
||||
|
|
@ -145,7 +144,7 @@ QCocoaGLContext::QCocoaGLContext(const QSurfaceFormat &format, QPlatformOpenGLCo
|
|||
if (m_format.renderableType() != QSurfaceFormat::OpenGL)
|
||||
return;
|
||||
|
||||
QCocoaAutoReleasePool pool; // For the SG Canvas render thread
|
||||
QMacAutoReleasePool pool; // For the SG Canvas render thread
|
||||
|
||||
NSOpenGLPixelFormat *pixelFormat = static_cast <NSOpenGLPixelFormat *>(qcgl_createNSOpenGLPixelFormat(m_format));
|
||||
m_shareContext = share ? static_cast<QCocoaGLContext *>(share)->nsOpenGLContext() : nil;
|
||||
|
|
@ -218,7 +217,7 @@ bool QCocoaGLContext::makeCurrent(QPlatformSurface *surface)
|
|||
{
|
||||
Q_ASSERT(surface->surface()->supportsOpenGL());
|
||||
|
||||
QCocoaAutoReleasePool pool;
|
||||
QMacAutoReleasePool pool;
|
||||
|
||||
QWindow *window = static_cast<QCocoaWindow *>(surface)->window();
|
||||
setActiveWindow(window);
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@
|
|||
|
||||
#include "qcocoahelpers.h"
|
||||
|
||||
#include "qcocoaautoreleasepool.h"
|
||||
|
||||
#include <QtCore>
|
||||
#include <QtGui>
|
||||
|
|
@ -630,7 +629,7 @@ QString qt_mac_applicationName()
|
|||
|
||||
int qt_mac_mainScreenHeight()
|
||||
{
|
||||
QCocoaAutoReleasePool pool;
|
||||
QMacAutoReleasePool pool;
|
||||
// The first screen in the screens array is documented
|
||||
// to have the (0,0) origin.
|
||||
NSRect screenFrame = [[[NSScreen screens] firstObject] frame];
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@
|
|||
#include "qnsview.h"
|
||||
#include "qcocoainputcontext.h"
|
||||
#include "qcocoanativeinterface.h"
|
||||
#include "qcocoaautoreleasepool.h"
|
||||
#include "qcocoawindow.h"
|
||||
|
||||
#include <QtCore/QRect>
|
||||
|
|
@ -98,7 +97,7 @@ void QCocoaInputContext::reset()
|
|||
if (!view)
|
||||
return;
|
||||
|
||||
QCocoaAutoReleasePool pool;
|
||||
QMacAutoReleasePool pool;
|
||||
if (NSTextInputContext *ctxt = [NSTextInputContext currentInputContext]) {
|
||||
[ctxt discardMarkedText];
|
||||
[view unmarkText];
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@
|
|||
|
||||
#include <Cocoa/Cocoa.h>
|
||||
|
||||
#include "qcocoaautoreleasepool.h"
|
||||
#include "qcocoacursor.h"
|
||||
#include "qcocoawindow.h"
|
||||
#include "qcocoanativeinterface.h"
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@
|
|||
|
||||
#include "qcocoaintegration.h"
|
||||
|
||||
#include "qcocoaautoreleasepool.h"
|
||||
#include "qcocoawindow.h"
|
||||
#include "qcocoabackingstore.h"
|
||||
#include "qcocoanativeinterface.h"
|
||||
|
|
@ -137,7 +136,7 @@ void QCocoaScreen::updateGeometry()
|
|||
|
||||
qreal QCocoaScreen::devicePixelRatio() const
|
||||
{
|
||||
QCocoaAutoReleasePool pool;
|
||||
QMacAutoReleasePool pool;
|
||||
NSScreen * screen = osScreen();
|
||||
return qreal(screen ? [screen backingScaleFactor] : 1.0);
|
||||
}
|
||||
|
|
@ -263,7 +262,7 @@ QCocoaIntegration::QCocoaIntegration()
|
|||
mInstance = this;
|
||||
|
||||
initResources();
|
||||
QCocoaAutoReleasePool pool;
|
||||
QMacAutoReleasePool pool;
|
||||
|
||||
qApp->setAttribute(Qt::AA_DontUseNativeMenuBar, false);
|
||||
|
||||
|
|
@ -314,7 +313,7 @@ QCocoaIntegration::~QCocoaIntegration()
|
|||
|
||||
qt_resetNSApplicationSendEvent();
|
||||
|
||||
QCocoaAutoReleasePool pool;
|
||||
QMacAutoReleasePool pool;
|
||||
if (!QCoreApplication::testAttribute(Qt::AA_MacPluginApplication)) {
|
||||
// remove the apple event handlers installed by QCocoaApplicationDelegate
|
||||
QCocoaApplicationDelegate *delegate = [QCocoaApplicationDelegate sharedDelegate];
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@
|
|||
#include "qcocoamenu.h"
|
||||
|
||||
#include "qcocoahelpers.h"
|
||||
#include "qcocoaautoreleasepool.h"
|
||||
|
||||
#include <QtCore/QtDebug>
|
||||
#include <QtCore/qmetaobject.h>
|
||||
|
|
@ -223,7 +222,7 @@ QCocoaMenu::QCocoaMenu() :
|
|||
m_menuBar(0),
|
||||
m_containingMenuItem(0)
|
||||
{
|
||||
QCocoaAutoReleasePool pool;
|
||||
QMacAutoReleasePool pool;
|
||||
|
||||
m_delegate = [[QCocoaMenuDelegate alloc] initWithMenu:this];
|
||||
m_nativeItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""];
|
||||
|
|
@ -243,7 +242,7 @@ QCocoaMenu::~QCocoaMenu()
|
|||
if (m_containingMenuItem)
|
||||
m_containingMenuItem->clearMenu(this);
|
||||
|
||||
QCocoaAutoReleasePool pool;
|
||||
QMacAutoReleasePool pool;
|
||||
[m_nativeItem setSubmenu:nil];
|
||||
[m_nativeMenu release];
|
||||
[m_delegate release];
|
||||
|
|
@ -252,7 +251,7 @@ QCocoaMenu::~QCocoaMenu()
|
|||
|
||||
void QCocoaMenu::setText(const QString &text)
|
||||
{
|
||||
QCocoaAutoReleasePool pool;
|
||||
QMacAutoReleasePool pool;
|
||||
QString stripped = qt_mac_removeAmpersandEscapes(text);
|
||||
[m_nativeMenu setTitle:QCFString::toNSString(stripped)];
|
||||
[m_nativeItem setTitle:QCFString::toNSString(stripped)];
|
||||
|
|
@ -274,7 +273,7 @@ void QCocoaMenu::setFont(const QFont &font)
|
|||
|
||||
void QCocoaMenu::insertMenuItem(QPlatformMenuItem *menuItem, QPlatformMenuItem *before)
|
||||
{
|
||||
QCocoaAutoReleasePool pool;
|
||||
QMacAutoReleasePool pool;
|
||||
QCocoaMenuItem *cocoaItem = static_cast<QCocoaMenuItem *>(menuItem);
|
||||
QCocoaMenuItem *beforeItem = static_cast<QCocoaMenuItem *>(before);
|
||||
|
||||
|
|
@ -328,7 +327,7 @@ void QCocoaMenu::insertNative(QCocoaMenuItem *item, QCocoaMenuItem *beforeItem)
|
|||
|
||||
void QCocoaMenu::removeMenuItem(QPlatformMenuItem *menuItem)
|
||||
{
|
||||
QCocoaAutoReleasePool pool;
|
||||
QMacAutoReleasePool pool;
|
||||
QCocoaMenuItem *cocoaItem = static_cast<QCocoaMenuItem *>(menuItem);
|
||||
if (!m_menuItems.contains(cocoaItem)) {
|
||||
qWarning() << Q_FUNC_INFO << "Menu does not contain the item to be removed";
|
||||
|
|
@ -358,7 +357,7 @@ QCocoaMenuItem *QCocoaMenu::itemOrNull(int index) const
|
|||
|
||||
void QCocoaMenu::syncMenuItem(QPlatformMenuItem *menuItem)
|
||||
{
|
||||
QCocoaAutoReleasePool pool;
|
||||
QMacAutoReleasePool pool;
|
||||
QCocoaMenuItem *cocoaItem = static_cast<QCocoaMenuItem *>(menuItem);
|
||||
if (!m_menuItems.contains(cocoaItem)) {
|
||||
qWarning() << Q_FUNC_INFO << "Item does not belong to this menu";
|
||||
|
|
@ -387,7 +386,7 @@ void QCocoaMenu::syncMenuItem(QPlatformMenuItem *menuItem)
|
|||
|
||||
void QCocoaMenu::syncSeparatorsCollapsible(bool enable)
|
||||
{
|
||||
QCocoaAutoReleasePool pool;
|
||||
QMacAutoReleasePool pool;
|
||||
if (enable) {
|
||||
bool previousIsSeparator = true; // setting to true kills all the separators placed at the top.
|
||||
NSMenuItem *previousItem = nil;
|
||||
|
|
@ -445,7 +444,7 @@ void QCocoaMenu::setVisible(bool visible)
|
|||
|
||||
void QCocoaMenu::showPopup(const QWindow *parentWindow, const QRect &targetRect, const QPlatformMenuItem *item)
|
||||
{
|
||||
QCocoaAutoReleasePool pool;
|
||||
QMacAutoReleasePool pool;
|
||||
|
||||
QPoint pos = QPoint(targetRect.left(), targetRect.top() + targetRect.height());
|
||||
QCocoaWindow *cocoaWindow = parentWindow ? static_cast<QCocoaWindow *>(parentWindow->handle()) : 0;
|
||||
|
|
@ -550,7 +549,7 @@ QList<QCocoaMenuItem *> QCocoaMenu::merged() const
|
|||
|
||||
void QCocoaMenu::syncModalState(bool modal)
|
||||
{
|
||||
QCocoaAutoReleasePool pool;
|
||||
QMacAutoReleasePool pool;
|
||||
|
||||
if (!m_enabled)
|
||||
modal = true;
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@
|
|||
#include "qcocoawindow.h"
|
||||
#include "qcocoamenuloader.h"
|
||||
#include "qcocoaapplication.h" // for custom application category
|
||||
#include "qcocoaautoreleasepool.h"
|
||||
#include "qcocoaapplicationdelegate.h"
|
||||
|
||||
#include <QtGui/QGuiApplication>
|
||||
|
|
@ -84,7 +83,7 @@ QCocoaMenuBar::~QCocoaMenuBar()
|
|||
|
||||
void QCocoaMenuBar::insertNativeMenu(QCocoaMenu *menu, QCocoaMenu *beforeMenu)
|
||||
{
|
||||
QCocoaAutoReleasePool pool;
|
||||
QMacAutoReleasePool pool;
|
||||
|
||||
if (beforeMenu) {
|
||||
NSUInteger nativeIndex = [m_nativeMenu indexOfItem:beforeMenu->nsMenuItem()];
|
||||
|
|
@ -127,7 +126,7 @@ void QCocoaMenuBar::insertMenu(QPlatformMenu *platformMenu, QPlatformMenu *befor
|
|||
|
||||
void QCocoaMenuBar::removeNativeMenu(QCocoaMenu *menu)
|
||||
{
|
||||
QCocoaAutoReleasePool pool;
|
||||
QMacAutoReleasePool pool;
|
||||
|
||||
if (menu->menuBar() == this)
|
||||
menu->setMenuBar(0);
|
||||
|
|
@ -148,7 +147,7 @@ void QCocoaMenuBar::removeMenu(QPlatformMenu *platformMenu)
|
|||
|
||||
void QCocoaMenuBar::syncMenu(QPlatformMenu *menu)
|
||||
{
|
||||
QCocoaAutoReleasePool pool;
|
||||
QMacAutoReleasePool pool;
|
||||
|
||||
QCocoaMenu *cocoaMenu = static_cast<QCocoaMenu *>(menu);
|
||||
Q_FOREACH (QCocoaMenuItem *item, cocoaMenu->items())
|
||||
|
|
@ -261,7 +260,7 @@ void QCocoaMenuBar::resetKnownMenuItemsToQt()
|
|||
|
||||
void QCocoaMenuBar::updateMenuBarImmediately()
|
||||
{
|
||||
QCocoaAutoReleasePool pool;
|
||||
QMacAutoReleasePool pool;
|
||||
QCocoaMenuBar *mb = findGlobalMenubar();
|
||||
QCocoaWindow *cw = findWindowForMenubar();
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@
|
|||
#include "qcocoamenubar.h"
|
||||
#include "messages.h"
|
||||
#include "qcocoahelpers.h"
|
||||
#include "qcocoaautoreleasepool.h"
|
||||
#include "qt_mac_p.h"
|
||||
#include "qcocoaapplication.h" // for custom application category
|
||||
#include "qcocoamenuloader.h"
|
||||
|
|
@ -104,7 +103,7 @@ QCocoaMenuItem::QCocoaMenuItem() :
|
|||
|
||||
QCocoaMenuItem::~QCocoaMenuItem()
|
||||
{
|
||||
QCocoaAutoReleasePool pool;
|
||||
QMacAutoReleasePool pool;
|
||||
|
||||
if (m_menu && COCOA_MENU_ANCESTOR(m_menu) == this)
|
||||
SET_COCOA_MENU_ANCESTOR(m_menu, 0);
|
||||
|
|
@ -139,7 +138,7 @@ void QCocoaMenuItem::setMenu(QPlatformMenu *menu)
|
|||
m_menu->setContainingMenuItem(0);
|
||||
}
|
||||
|
||||
QCocoaAutoReleasePool pool;
|
||||
QMacAutoReleasePool pool;
|
||||
m_menu = static_cast<QCocoaMenu *>(menu);
|
||||
if (m_menu) {
|
||||
SET_COCOA_MENU_ANCESTOR(m_menu, this);
|
||||
|
|
|
|||
|
|
@ -234,7 +234,7 @@ void QCocoaNativeInterface::registerDraggedTypes(const QStringList &types)
|
|||
|
||||
void QCocoaNativeInterface::setDockMenu(QPlatformMenu *platformMenu)
|
||||
{
|
||||
QCocoaAutoReleasePool pool;
|
||||
QMacAutoReleasePool pool;
|
||||
QCocoaMenu *cocoaPlatformMenu = static_cast<QCocoaMenu *>(platformMenu);
|
||||
NSMenu *menu = cocoaPlatformMenu->nsMenu();
|
||||
[NSApp QT_MANGLE_NAMESPACE(qt_setDockMenu): menu];
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@
|
|||
|
||||
#include "qcocoasystemsettings.h"
|
||||
|
||||
#include "qcocoaautoreleasepool.h"
|
||||
#include "qcocoahelpers.h"
|
||||
|
||||
#include <QtCore/private/qcore_mac_p.h>
|
||||
|
|
@ -45,7 +44,7 @@ QT_BEGIN_NAMESPACE
|
|||
|
||||
QColor qt_mac_colorForTheme(ThemeBrush brush)
|
||||
{
|
||||
QCocoaAutoReleasePool pool;
|
||||
QMacAutoReleasePool pool;
|
||||
|
||||
QCFType<CGColorRef> cgClr = 0;
|
||||
HIThemeBrushCreateCGColor(brush, &cgClr);
|
||||
|
|
|
|||
|
|
@ -47,7 +47,6 @@
|
|||
#include "qcocoamenu.h"
|
||||
#include "qcocoamenubar.h"
|
||||
#include "qcocoahelpers.h"
|
||||
#include "qcocoaautoreleasepool.h"
|
||||
|
||||
#include <QtCore/qfileinfo.h>
|
||||
#include <QtGui/private/qguiapplication_p.h>
|
||||
|
|
@ -253,7 +252,7 @@ QPixmap QCocoaTheme::fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &siz
|
|||
QPlatformTheme::IconOptions iconOptions) const
|
||||
{
|
||||
Q_UNUSED(iconOptions);
|
||||
QCocoaAutoReleasePool pool;
|
||||
QMacAutoReleasePool pool;
|
||||
|
||||
NSImage *iconImage = [[NSWorkspace sharedWorkspace] iconForFile:QCFString::toNSString(fileInfo.canonicalFilePath())];
|
||||
if (!iconImage)
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@
|
|||
#include "qcocoawindow.h"
|
||||
#include "qcocoaintegration.h"
|
||||
#include "qnswindowdelegate.h"
|
||||
#include "qcocoaautoreleasepool.h"
|
||||
#include "qcocoaeventdispatcher.h"
|
||||
#ifndef QT_NO_OPENGL
|
||||
#include "qcocoaglcontext.h"
|
||||
|
|
@ -374,7 +373,7 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw)
|
|||
#ifdef QT_COCOA_ENABLE_WINDOW_DEBUG
|
||||
qDebug() << "QCocoaWindow::QCocoaWindow" << this;
|
||||
#endif
|
||||
QCocoaAutoReleasePool pool;
|
||||
QMacAutoReleasePool pool;
|
||||
|
||||
if (tlw->type() == Qt::ForeignWindow) {
|
||||
NSView *foreignView = (NSView *)WId(tlw->property("_q_foreignWinId").value<WId>());
|
||||
|
|
@ -410,7 +409,7 @@ QCocoaWindow::~QCocoaWindow()
|
|||
qDebug() << "QCocoaWindow::~QCocoaWindow" << this;
|
||||
#endif
|
||||
|
||||
QCocoaAutoReleasePool pool;
|
||||
QMacAutoReleasePool pool;
|
||||
[m_nsWindow setContentView:nil];
|
||||
[m_nsWindow.helper detachFromPlatformWindow];
|
||||
if (m_isNSWindowChild) {
|
||||
|
|
@ -492,7 +491,7 @@ QRect QCocoaWindow::geometry() const
|
|||
|
||||
void QCocoaWindow::setCocoaGeometry(const QRect &rect)
|
||||
{
|
||||
QCocoaAutoReleasePool pool;
|
||||
QMacAutoReleasePool pool;
|
||||
|
||||
if (m_contentViewIsEmbedded) {
|
||||
QPlatformWindow::setGeometry(rect);
|
||||
|
|
@ -616,7 +615,7 @@ void QCocoaWindow::setVisible(bool visible)
|
|||
|
||||
m_inSetVisible = true;
|
||||
|
||||
QCocoaAutoReleasePool pool;
|
||||
QMacAutoReleasePool pool;
|
||||
QCocoaWindow *parentCocoaWindow = 0;
|
||||
if (window()->transientParent())
|
||||
parentCocoaWindow = static_cast<QCocoaWindow *>(window()->transientParent()->handle());
|
||||
|
|
@ -887,7 +886,7 @@ void QCocoaWindow::setWindowState(Qt::WindowState state)
|
|||
|
||||
void QCocoaWindow::setWindowTitle(const QString &title)
|
||||
{
|
||||
QCocoaAutoReleasePool pool;
|
||||
QMacAutoReleasePool pool;
|
||||
if (!m_nsWindow)
|
||||
return;
|
||||
|
||||
|
|
@ -898,7 +897,7 @@ void QCocoaWindow::setWindowTitle(const QString &title)
|
|||
|
||||
void QCocoaWindow::setWindowFilePath(const QString &filePath)
|
||||
{
|
||||
QCocoaAutoReleasePool pool;
|
||||
QMacAutoReleasePool pool;
|
||||
if (!m_nsWindow)
|
||||
return;
|
||||
|
||||
|
|
@ -908,7 +907,7 @@ void QCocoaWindow::setWindowFilePath(const QString &filePath)
|
|||
|
||||
void QCocoaWindow::setWindowIcon(const QIcon &icon)
|
||||
{
|
||||
QCocoaAutoReleasePool pool;
|
||||
QMacAutoReleasePool pool;
|
||||
|
||||
NSButton *iconButton = [m_nsWindow standardWindowButton:NSWindowDocumentIconButton];
|
||||
if (iconButton == nil) {
|
||||
|
|
@ -1026,7 +1025,7 @@ bool QCocoaWindow::isOpaque() const
|
|||
|
||||
void QCocoaWindow::propagateSizeHints()
|
||||
{
|
||||
QCocoaAutoReleasePool pool;
|
||||
QMacAutoReleasePool pool;
|
||||
if (!m_nsWindow)
|
||||
return;
|
||||
|
||||
|
|
@ -1367,7 +1366,7 @@ bool QCocoaWindow::shouldUseNSPanel()
|
|||
|
||||
QCocoaNSWindow * QCocoaWindow::createNSWindow()
|
||||
{
|
||||
QCocoaAutoReleasePool pool;
|
||||
QMacAutoReleasePool pool;
|
||||
|
||||
QRect rect = initialGeometry(window(), window()->geometry(), defaultWindowWidth, defaultWindowHeight);
|
||||
NSRect frame = qt_mac_flipRect(rect);
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "qcocoahelpers.h"
|
||||
#include "qcocoaautoreleasepool.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
|
@ -555,7 +554,7 @@ QMacPasteboard::sync() const
|
|||
|
||||
QString qt_mac_get_pasteboardString(PasteboardRef paste)
|
||||
{
|
||||
QCocoaAutoReleasePool pool;
|
||||
QMacAutoReleasePool pool;
|
||||
NSPasteboard *pb = nil;
|
||||
CFStringRef pbname;
|
||||
if (PasteboardCopyName(paste, &pbname) == noErr) {
|
||||
|
|
|
|||
|
|
@ -39,7 +39,6 @@
|
|||
#include "qnsview.h"
|
||||
#include "qcocoawindow.h"
|
||||
#include "qcocoahelpers.h"
|
||||
#include "qcocoaautoreleasepool.h"
|
||||
#include "qmultitouch_mac_p.h"
|
||||
#include "qcocoadrag.h"
|
||||
#include <qpa/qplatformintegration.h>
|
||||
|
|
@ -849,7 +848,7 @@ QT_WARNING_POP
|
|||
{
|
||||
[super updateTrackingAreas];
|
||||
|
||||
QCocoaAutoReleasePool pool;
|
||||
QMacAutoReleasePool pool;
|
||||
|
||||
// NSTrackingInVisibleRect keeps care of updating once the tracking is set up, so bail out early
|
||||
if (m_trackingArea && [[self trackingAreas] containsObject:m_trackingArea])
|
||||
|
|
@ -1786,7 +1785,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
|
|||
|
||||
-(void)registerDragTypes
|
||||
{
|
||||
QCocoaAutoReleasePool pool;
|
||||
QMacAutoReleasePool pool;
|
||||
QStringList customTypes = qt_mac_enabledDraggedTypes();
|
||||
if (currentCustomDragTypes == 0 || *currentCustomDragTypes != customTypes) {
|
||||
if (currentCustomDragTypes == 0)
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@
|
|||
#include <QtCore/qcoreapplication.h>
|
||||
#include <QtCore/qdebug.h>
|
||||
|
||||
#include "qcocoaautoreleasepool.h"
|
||||
|
||||
#ifndef QT_NO_PRINTER
|
||||
|
||||
|
|
@ -230,7 +229,7 @@ void QMacPrintEnginePrivate::initialize()
|
|||
|
||||
q->gccaps = paintEngine->gccaps;
|
||||
|
||||
QCocoaAutoReleasePool pool;
|
||||
QMacAutoReleasePool pool;
|
||||
printInfo = [[NSPrintInfo alloc] initWithDictionary:[NSDictionary dictionary]];
|
||||
|
||||
QList<int> resolutions = m_printDevice->supportedResolutions();
|
||||
|
|
|
|||
|
|
@ -103,17 +103,6 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
class Q_WIDGETS_EXPORT QMacCocoaAutoReleasePool
|
||||
{
|
||||
private:
|
||||
void *pool;
|
||||
public:
|
||||
QMacCocoaAutoReleasePool();
|
||||
~QMacCocoaAutoReleasePool();
|
||||
|
||||
inline void *handle() const { return pool; }
|
||||
};
|
||||
|
||||
QString qt_mac_removeMnemonics(const QString &original); //implemented in qmacstyle_mac.cpp
|
||||
|
||||
class Q_WIDGETS_EXPORT QMacWindowChangeEvent
|
||||
|
|
|
|||
|
|
@ -201,10 +201,9 @@ int QPageSetupDialog::exec()
|
|||
|
||||
QDialog::setVisible(true);
|
||||
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
QMacAutoReleasePool pool;
|
||||
static_cast <QMacPageSetupDialogPrivate*>(d)->openCocoaPageLayout(Qt::ApplicationModal);
|
||||
static_cast <QMacPageSetupDialogPrivate*>(d)->closeCocoaPageLayout();
|
||||
[pool release];
|
||||
|
||||
QDialog::setVisible(false);
|
||||
|
||||
|
|
|
|||
|
|
@ -301,10 +301,9 @@ int QPrintDialog::exec()
|
|||
|
||||
QDialog::setVisible(true);
|
||||
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
QMacAutoReleasePool pool;
|
||||
d->openCocoaPrintPanel(Qt::ApplicationModal);
|
||||
d->closeCocoaPrintPanel();
|
||||
[pool release];
|
||||
|
||||
QDialog::setVisible(false);
|
||||
|
||||
|
|
|
|||
|
|
@ -93,18 +93,6 @@
|
|||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
namespace {
|
||||
class AutoReleasePool
|
||||
{
|
||||
public:
|
||||
AutoReleasePool(): pool([[NSAutoreleasePool alloc] init]) {}
|
||||
~AutoReleasePool() { [pool release]; }
|
||||
|
||||
private:
|
||||
NSAutoreleasePool *pool;
|
||||
};
|
||||
}
|
||||
|
||||
@interface QT_MANGLE_NAMESPACE(NotificationReceiver) : NSObject {
|
||||
QMacStylePrivate *mPrivate;
|
||||
}
|
||||
|
|
@ -1753,7 +1741,7 @@ QMacStylePrivate::QMacStylePrivate()
|
|||
|
||||
QMacStylePrivate::~QMacStylePrivate()
|
||||
{
|
||||
AutoReleasePool pool;
|
||||
QMacAutoReleasePool pool;
|
||||
Q_FOREACH (NSView *b, cocoaControls)
|
||||
[b release];
|
||||
}
|
||||
|
|
@ -2135,7 +2123,7 @@ QMacStyle::QMacStyle()
|
|||
: QCommonStyle(*new QMacStylePrivate)
|
||||
{
|
||||
Q_D(QMacStyle);
|
||||
AutoReleasePool pool;
|
||||
QMacAutoReleasePool pool;
|
||||
|
||||
d->receiver = [[NotificationReceiver alloc] initWithPrivate:d];
|
||||
NotificationReceiver *receiver = static_cast<NotificationReceiver *>(d->receiver);
|
||||
|
|
@ -2152,7 +2140,7 @@ QMacStyle::QMacStyle()
|
|||
QMacStyle::~QMacStyle()
|
||||
{
|
||||
Q_D(QMacStyle);
|
||||
AutoReleasePool pool;
|
||||
QMacAutoReleasePool pool;
|
||||
|
||||
[reinterpret_cast<NSScroller*>(d->nsscroller) release];
|
||||
|
||||
|
|
@ -2169,7 +2157,7 @@ QMacStyle::~QMacStyle()
|
|||
*/
|
||||
QPixmap QMacStylePrivate::generateBackgroundPattern() const
|
||||
{
|
||||
AutoReleasePool pool;
|
||||
QMacAutoReleasePool pool;
|
||||
QPixmap px(4, 4);
|
||||
QMacCGContext cg(&px);
|
||||
HIThemeSetFill(kThemeBrushDialogBackgroundActive, 0, cg, kHIThemeOrientationNormal);
|
||||
|
|
@ -2767,7 +2755,7 @@ QPalette QMacStyle::standardPalette() const
|
|||
int QMacStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w,
|
||||
QStyleHintReturn *hret) const
|
||||
{
|
||||
AutoReleasePool pool;
|
||||
QMacAutoReleasePool pool;
|
||||
|
||||
SInt32 ret = 0;
|
||||
switch (sh) {
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ QT_BEGIN_NAMESPACE
|
|||
|
||||
QPointF QScrollerPrivate::realDpi(int screen)
|
||||
{
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
QMacAutoReleasePool pool;
|
||||
NSArray *nsscreens = [NSScreen screens];
|
||||
|
||||
if (screen < 0 || screen >= int([nsscreens count]))
|
||||
|
|
@ -59,7 +59,6 @@ QPointF QScrollerPrivate::realDpi(int screen)
|
|||
} else {
|
||||
return QPointF();
|
||||
}
|
||||
[pool release];
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -1087,7 +1087,7 @@ void QMainWindow::addDockWidget(Qt::DockWidgetArea area, QDockWidget *dockwidget
|
|||
addDockWidget(area, dockwidget, orientation);
|
||||
|
||||
#ifdef Q_DEAD_CODE_FROM_QT4_MAC //drawer support
|
||||
QMacCocoaAutoReleasePool pool;
|
||||
QMacAutoReleasePool pool;
|
||||
extern bool qt_mac_is_macdrawer(const QWidget *); //qwidget_mac.cpp
|
||||
if (qt_mac_is_macdrawer(dockwidget)) {
|
||||
extern bool qt_mac_set_drawer_preferred_edge(QWidget *, Qt::DockWidgetArea); //qwidget_mac.cpp
|
||||
|
|
|
|||
|
|
@ -72,35 +72,31 @@ void tst_QByteArray_macTypes()
|
|||
}
|
||||
// QByteArray <-> NSData
|
||||
{
|
||||
NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
|
||||
QMacAutoReleasePool pool;
|
||||
QByteArray qtByteArray("test bytearray");
|
||||
const NSData *nsData = qtByteArray.toNSData();
|
||||
QCOMPARE(QByteArray::fromNSData(nsData), qtByteArray);
|
||||
[autoreleasepool release];
|
||||
}
|
||||
{
|
||||
NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
|
||||
QMacAutoReleasePool pool;
|
||||
QByteArray qtByteArray("test bytearray");
|
||||
const NSData *nsData = qtByteArray.toNSData();
|
||||
QByteArray qtByteArrayCopy(qtByteArray);
|
||||
qtByteArray = qtByteArray.toUpper(); // modify
|
||||
QCOMPARE(QByteArray::fromNSData(nsData), qtByteArrayCopy);
|
||||
[autoreleasepool release];
|
||||
}
|
||||
// QByteArray <-> NSData Raw
|
||||
{
|
||||
NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
|
||||
QMacAutoReleasePool pool;
|
||||
QByteArray qtByteArray("test bytearray");
|
||||
const NSData *nsData = qtByteArray.toRawNSData();
|
||||
QCOMPARE([nsData bytes], qtByteArray.constData());
|
||||
[autoreleasepool release];
|
||||
}
|
||||
{
|
||||
NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
|
||||
QMacAutoReleasePool pool;
|
||||
const char data[] = "nsdata test";
|
||||
const NSData *nsData = [NSData dataWithBytes:data length:sizeof(data)];
|
||||
QByteArray qtByteArray = QByteArray::fromRawNSData(nsData);
|
||||
QCOMPARE(qtByteArray.constData(), [nsData bytes]);
|
||||
[autoreleasepool release];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,19 +56,17 @@ void tst_QDateTime_macTypes()
|
|||
}
|
||||
// QDateTime <-> NSDate
|
||||
{
|
||||
NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
|
||||
QMacAutoReleasePool pool;
|
||||
QDateTime qtDateTime = QDateTime::fromMSecsSinceEpoch(0);
|
||||
const NSDate *nsDate = qtDateTime.toNSDate();
|
||||
QCOMPARE(QDateTime::fromNSDate(nsDate), qtDateTime);
|
||||
[autoreleasepool release];
|
||||
}
|
||||
{
|
||||
NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
|
||||
QMacAutoReleasePool pool;
|
||||
QDateTime qtDateTime = QDateTime::fromMSecsSinceEpoch(0);
|
||||
const NSDate *nsDate = qtDateTime.toNSDate();
|
||||
QDateTime qtDateTimeCopy(qtDateTime);
|
||||
qtDateTime.setTime_t(10000); // modify
|
||||
QCOMPARE(QDateTime::fromNSDate(nsDate), qtDateTimeCopy);
|
||||
[autoreleasepool release];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,23 +55,19 @@ void tst_QString_macTypes()
|
|||
}
|
||||
// QString <-> NSString
|
||||
{
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
QMacAutoReleasePool pool;
|
||||
|
||||
QString qtString("test string");
|
||||
const NSString *nsString = qtString.toNSString();
|
||||
QCOMPARE(QString::fromNSString(nsString), qtString);
|
||||
|
||||
[pool release];
|
||||
}
|
||||
{
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
QMacAutoReleasePool pool;
|
||||
|
||||
QString qtString("test string");
|
||||
const NSString *nsString = qtString.toNSString();
|
||||
QString qtStringCopy(qtString);
|
||||
qtString = qtString.toUpper(); // modify
|
||||
QCOMPARE(QString::fromNSString(nsString), qtStringCopy);
|
||||
|
||||
[pool release];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@
|
|||
|
||||
void click_cocoa_button()
|
||||
{
|
||||
QMacCocoaAutoReleasePool pool;
|
||||
QMacAutoReleasePool pool;
|
||||
NSArray *windows = [NSApp windows];
|
||||
for (NSWindow *window in windows) {
|
||||
// This is NOT how one should do RTTI, but since I don't want to leak the class too much...
|
||||
|
|
|
|||
Loading…
Reference in New Issue