Fix memory leaks in QFseventsFileSystemWatcherEngine
Sprinkle in some NSAutoReleasePools. Task-number: QTBUG-38637 Change-Id: I0cb42d9d1cbcc4e9d273d0d43e4925fc02885b66 Reviewed-by: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
parent
432aaf05da
commit
cb68607fee
@ -64,6 +64,25 @@
|
|||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
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,
|
static void callBackFunction(ConstFSEventStreamRef streamRef,
|
||||||
void *clientCallBackInfo,
|
void *clientCallBackInfo,
|
||||||
size_t numEvents,
|
size_t numEvents,
|
||||||
@ -71,6 +90,8 @@ static void callBackFunction(ConstFSEventStreamRef streamRef,
|
|||||||
const FSEventStreamEventFlags eventFlags[],
|
const FSEventStreamEventFlags eventFlags[],
|
||||||
const FSEventStreamEventId eventIds[])
|
const FSEventStreamEventId eventIds[])
|
||||||
{
|
{
|
||||||
|
Q_AUTORELEASE_POOL(pool)
|
||||||
|
|
||||||
char **paths = static_cast<char **>(eventPaths);
|
char **paths = static_cast<char **>(eventPaths);
|
||||||
QFseventsFileSystemWatcherEngine *engine = static_cast<QFseventsFileSystemWatcherEngine *>(clientCallBackInfo);
|
QFseventsFileSystemWatcherEngine *engine = static_cast<QFseventsFileSystemWatcherEngine *>(clientCallBackInfo);
|
||||||
engine->processEvent(streamRef, numEvents, paths, eventFlags, eventIds);
|
engine->processEvent(streamRef, numEvents, paths, eventFlags, eventIds);
|
||||||
@ -283,6 +304,7 @@ void QFseventsFileSystemWatcherEngine::doEmitDirectoryChanged(const QString path
|
|||||||
|
|
||||||
void QFseventsFileSystemWatcherEngine::restartStream()
|
void QFseventsFileSystemWatcherEngine::restartStream()
|
||||||
{
|
{
|
||||||
|
Q_AUTORELEASE_POOL(pool)
|
||||||
QMutexLocker locker(&lock);
|
QMutexLocker locker(&lock);
|
||||||
stopStream();
|
stopStream();
|
||||||
startStream();
|
startStream();
|
||||||
@ -313,6 +335,8 @@ QFseventsFileSystemWatcherEngine::QFseventsFileSystemWatcherEngine(QObject *pare
|
|||||||
|
|
||||||
QFseventsFileSystemWatcherEngine::~QFseventsFileSystemWatcherEngine()
|
QFseventsFileSystemWatcherEngine::~QFseventsFileSystemWatcherEngine()
|
||||||
{
|
{
|
||||||
|
Q_AUTORELEASE_POOL(pool)
|
||||||
|
|
||||||
if (stream)
|
if (stream)
|
||||||
FSEventStreamStop(stream);
|
FSEventStreamStop(stream);
|
||||||
|
|
||||||
@ -327,6 +351,8 @@ QStringList QFseventsFileSystemWatcherEngine::addPaths(const QStringList &paths,
|
|||||||
QStringList *files,
|
QStringList *files,
|
||||||
QStringList *directories)
|
QStringList *directories)
|
||||||
{
|
{
|
||||||
|
Q_AUTORELEASE_POOL(pool)
|
||||||
|
|
||||||
if (stream) {
|
if (stream) {
|
||||||
DEBUG("Flushing, last id is %llu", FSEventStreamGetLatestEventId(stream));
|
DEBUG("Flushing, last id is %llu", FSEventStreamGetLatestEventId(stream));
|
||||||
FSEventStreamFlushSync(stream);
|
FSEventStreamFlushSync(stream);
|
||||||
@ -413,6 +439,8 @@ QStringList QFseventsFileSystemWatcherEngine::removePaths(const QStringList &pat
|
|||||||
QStringList *files,
|
QStringList *files,
|
||||||
QStringList *directories)
|
QStringList *directories)
|
||||||
{
|
{
|
||||||
|
Q_AUTORELEASE_POOL(pool)
|
||||||
|
|
||||||
QMutexLocker locker(&lock);
|
QMutexLocker locker(&lock);
|
||||||
|
|
||||||
bool needsRestart = false;
|
bool needsRestart = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user