summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qsettings.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/io/qsettings.cpp')
-rw-r--r--src/corelib/io/qsettings.cpp21
1 files 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();
}
}