[Pkg-owncloud-commits] [owncloud-client] 226/333: Fix leak: don't leak the settings
Sandro Knauß
hefee-guest at moszumanska.debian.org
Thu Apr 17 23:16:57 UTC 2014
This is an automated email from the git hooks/post-receive script.
hefee-guest pushed a commit to branch master
in repository owncloud-client.
commit 588633a0f247423e0ca98dc4ce828fb998528737
Author: Olivier Goffart <ogoffart at woboq.com>
Date: Wed Mar 26 17:08:34 2014 +0100
Fix leak: don't leak the settings
---
src/creds/httpcredentials.cpp | 1 +
src/creds/shibbolethcredentials.cpp | 8 ++++----
src/mirall/account.cpp | 4 ++--
src/mirall/account.h | 5 ++++-
4 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/src/creds/httpcredentials.cpp b/src/creds/httpcredentials.cpp
index ffea942..6a8512a 100644
--- a/src/creds/httpcredentials.cpp
+++ b/src/creds/httpcredentials.cpp
@@ -209,6 +209,7 @@ void HttpCredentials::fetch(Account *account)
}
if (_ready) {
+ settings->deleteLater();
Q_EMIT fetched();
} else {
ReadPasswordJob *job = new ReadPasswordJob(Theme::instance()->appName());
diff --git a/src/creds/shibbolethcredentials.cpp b/src/creds/shibbolethcredentials.cpp
index 443528a..4190432 100644
--- a/src/creds/shibbolethcredentials.cpp
+++ b/src/creds/shibbolethcredentials.cpp
@@ -204,7 +204,7 @@ void ShibbolethCredentials::fetch(Account *account)
_url = account->url();
}
ReadPasswordJob *job = new ReadPasswordJob(Theme::instance()->appName());
- job->setSettings(account->settingsWithGroup(Theme::instance()->appName()));
+ job->setSettings(account->settingsWithGroup(Theme::instance()->appName(), job));
job->setInsecureFallback(false);
job->setKey(keychainKey(account->url().toString(), "shibAssertion"));
job->setProperty("account", QVariant::fromValue(account));
@@ -277,7 +277,7 @@ void ShibbolethCredentials::invalidateAndFetch(Account* account)
// delete the credentials, then in the slot fetch them again (which will trigger browser)
DeletePasswordJob *job = new DeletePasswordJob(Theme::instance()->appName());
job->setProperty("account", QVariant::fromValue(account));
- job->setSettings(account->settingsWithGroup(Theme::instance()->appName()));
+ job->setSettings(account->settingsWithGroup(Theme::instance()->appName(), job));
connect(job, SIGNAL(finished(QKeychain::Job*)), SLOT(slotInvalidateAndFetchInvalidateDone(QKeychain::Job*)));
job->setKey(keychainKey(account->url().toString(), "shibAssertion"));
job->start();
@@ -314,7 +314,7 @@ void ShibbolethCredentials::slotReadJobDone(QKeychain::Job *job)
if (cookies.count() > 0) {
_shibCookie = cookies.first();
}
- job->setSettings(account->settingsWithGroup(Theme::instance()->appName()));
+ job->setSettings(account->settingsWithGroup(Theme::instance()->appName(), job));
_ready = true;
_stillValid = true;
@@ -348,7 +348,7 @@ void ShibbolethCredentials::showLoginWindow(Account* account)
void ShibbolethCredentials::storeShibCookie(const QNetworkCookie &cookie, Account *account)
{
WritePasswordJob *job = new WritePasswordJob(Theme::instance()->appName());
- job->setSettings(account->settingsWithGroup(Theme::instance()->appName()));
+ job->setSettings(account->settingsWithGroup(Theme::instance()->appName(), job));
// we don't really care if it works...
//connect(job, SIGNAL(finished(QKeychain::Job*)), SLOT(slotWriteJobDone(QKeychain::Job*)));
job->setKey(keychainKey(account->url().toString(), "shibAssertion"));
diff --git a/src/mirall/account.cpp b/src/mirall/account.cpp
index 8740527..f04c063 100644
--- a/src/mirall/account.cpp
+++ b/src/mirall/account.cpp
@@ -265,14 +265,14 @@ QUrl Account::concatUrlPath(const QUrl &url, const QString &concatPath)
QString Account::_configFileName;
-QSettings *Account::settingsWithGroup(const QString& group)
+QSettings *Account::settingsWithGroup(const QString& group, QObject *parent)
{
if (_configFileName.isEmpty()) {
// cache file name
MirallConfigFile cfg;
_configFileName = cfg.configFile();
}
- QSettings *settings = new QSettings(_configFileName, QSettings::IniFormat);
+ QSettings *settings = new QSettings(_configFileName, QSettings::IniFormat, parent);
settings->beginGroup(group);
return settings;
}
diff --git a/src/mirall/account.h b/src/mirall/account.h
index a7bcead..e358ba9 100644
--- a/src/mirall/account.h
+++ b/src/mirall/account.h
@@ -128,7 +128,10 @@ public:
// static helper function
static QUrl concatUrlPath(const QUrl &url, const QString &concatPath);
- static QSettings* settingsWithGroup(const QString &group);
+
+ /** Returns a new settings pre-set in a specific group. The Settings will be created
+ with the given parent. If no parents is specified, the caller must destroy the settings */
+ static QSettings* settingsWithGroup(const QString &group, QObject *parent = 0);
// to be called by credentials only
QVariant credentialSetting(const QString& key) const;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git
More information about the Pkg-owncloud-commits
mailing list