From aaba8c808d02bfd8a5208260320ce522b84954a1 Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Fri, 29 Oct 2010 13:57:18 +0200 Subject: Fix memory leak on exit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The confFile was lost if the cache was already gone (e.g. on app exit). This patch ensures that the confFile is always deleted. Reviewed-by: João Abecasis --- src/corelib/io/qsettings.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp index 53af822..8ee42e7 100644 --- a/src/corelib/io/qsettings.cpp +++ b/src/corelib/io/qsettings.cpp @@ -1231,16 +1231,21 @@ QConfFileSettingsPrivate::~QConfFileSettingsPrivate() if (confFiles[i] && !confFiles[i]->ref.deref()) { if (confFiles[i]->size == 0) { delete confFiles[i].take(); - } else if (unusedCache) { + } else { if (usedHash) usedHash->remove(confFiles[i]->name); - QT_TRY { - // compute a better size? - unusedCache->insert(confFiles[i]->name, confFiles[i].data(), - 10 + (confFiles[i]->originalKeys.size() / 4)); - confFiles[i].take(); - } QT_CATCH(...) { - // out of memory. Do not cache the file. + if (unusedCache) { + QT_TRY { + // compute a better size? + unusedCache->insert(confFiles[i]->name, confFiles[i].data(), + 10 + (confFiles[i]->originalKeys.size() / 4)); + confFiles[i].take(); + } QT_CATCH(...) { + // out of memory. Do not cache the file. + delete confFiles[i].take(); + } + } else { + // unusedCache is gone - delete the entry to prevent a memory leak delete confFiles[i].take(); } } -- cgit v0.12 From 66b9f79a9577ee50ca0a9ef8a2ac7a09a3e68a50 Mon Sep 17 00:00:00 2001 From: Lorn Potter Date: Sat, 30 Oct 2010 05:15:30 +1000 Subject: dbus does not use this. fix build. Reviewed-by: trust me --- src/plugins/bearer/connman/qconnmanservice_linux.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/plugins/bearer/connman/qconnmanservice_linux.cpp b/src/plugins/bearer/connman/qconnmanservice_linux.cpp index 46b6e80..952a444 100644 --- a/src/plugins/bearer/connman/qconnmanservice_linux.cpp +++ b/src/plugins/bearer/connman/qconnmanservice_linux.cpp @@ -79,7 +79,7 @@ if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) { QLatin1String(CONNMAN_MANAGER_PATH), QLatin1String(CONNMAN_MANAGER_INTERFACE), QLatin1String("PropertyChanged"), - this,SIGNAL(propertyChanged(const QString &, const QDBusVariant & ))), Qt::UniqueConnection) { + this,SIGNAL(propertyChanged(const QString &, const QDBusVariant & )))) { qWarning() << "PropertyCHanged not connected"; } } @@ -89,7 +89,7 @@ if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) { QLatin1String(CONNMAN_MANAGER_PATH), QLatin1String(CONNMAN_MANAGER_INTERFACE), QLatin1String("StateChanged"), - this,SIGNAL(stateChanged(const QString&))), Qt::UniqueConnection) { + this,SIGNAL(stateChanged(const QString&)))) { qWarning() << "StateChanged not connected"; } @@ -338,7 +338,7 @@ void QConnmanNetworkInterface::connectNotify(const char *signal) this->path(), QLatin1String(CONNMAN_NETWORK_INTERFACE), QLatin1String("PropertyChanged"), - this,SIGNAL(propertyChanged(QString,QDBusVariant))), Qt::UniqueConnection) { + this,SIGNAL(propertyChanged(QString,QDBusVariant)))) { qWarning() << "network properties not connected"; } } @@ -350,7 +350,7 @@ void QConnmanNetworkInterface::connectNotify(const char *signal) this->path(), QLatin1String(CONNMAN_NETWORK_INTERFACE), QLatin1String("PropertyChanged"), - helper,SLOT(propertyChanged(QString,QDBusVariant))), Qt::UniqueConnection; + helper,SLOT(propertyChanged(QString,QDBusVariant))); QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), Qt::UniqueConnection); -- cgit v0.12