Browse Source

bug-fix: do not free userSettings and defaultSettings in destructor

Freeing userSettings and defaultSettings in the destructor of
VConfigManager will cause crash in macOS.
Le Tan 8 years ago
parent
commit
e1befc1038
2 changed files with 6 additions and 11 deletions
  1. 0 10
      src/vconfigmanager.cpp
  2. 6 1
      src/vconfigmanager.h

+ 0 - 10
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";

+ 6 - 1
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.