From e1befc10385758dfc73f0ee8e40dce24145aeb72 Mon Sep 17 00:00:00 2001 From: Le Tan Date: Sat, 26 Aug 2017 21:50:14 +0800 Subject: [PATCH] bug-fix: do not free userSettings and defaultSettings in destructor Freeing userSettings and defaultSettings in the destructor of VConfigManager will cause crash in macOS. --- src/vconfigmanager.cpp | 10 ---------- src/vconfigmanager.h | 7 ++++++- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/vconfigmanager.cpp b/src/vconfigmanager.cpp index d44609af..91d0c8c2 100644 --- a/src/vconfigmanager.cpp +++ b/src/vconfigmanager.cpp @@ -33,16 +33,6 @@ VConfigManager::VConfigManager() { } -VConfigManager::~VConfigManager() -{ - if (userSettings) { - delete userSettings; - } - if (defaultSettings) { - delete defaultSettings; - } -} - void VConfigManager::migrateIniFile() { const QString originalFolder = "tamlok"; diff --git a/src/vconfigmanager.h b/src/vconfigmanager.h index a7e9df01..4f3f5180 100644 --- a/src/vconfigmanager.h +++ b/src/vconfigmanager.h @@ -27,11 +27,16 @@ struct VColor QString rgb; // 'FFFFFF', without '#' }; +// FIXME: we do not free userSettings and defaultSettings here since there will +// be only one global instance of VConfigManager. Freeing them in the destructor +// causes crash in macOS. +// One solution is to make the global variable a pointer, which causes too many +// modifications. For now, we just choose the simple way. class VConfigManager { public: VConfigManager(); - ~VConfigManager(); + void initialize(); // Read config from the directory config json file into a QJsonObject.