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

Freeing userSettings and defaultSettings in the destructor of
VConfigManager will cause crash in macOS.
This commit is contained in:
Le Tan 2017-08-26 21:50:14 +08:00
parent b47982ab25
commit e1befc1038
2 changed files with 6 additions and 11 deletions

View File

@ -33,16 +33,6 @@ VConfigManager::VConfigManager()
{ {
} }
VConfigManager::~VConfigManager()
{
if (userSettings) {
delete userSettings;
}
if (defaultSettings) {
delete defaultSettings;
}
}
void VConfigManager::migrateIniFile() void VConfigManager::migrateIniFile()
{ {
const QString originalFolder = "tamlok"; const QString originalFolder = "tamlok";

View File

@ -27,11 +27,16 @@ struct VColor
QString rgb; // 'FFFFFF', without '#' 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 class VConfigManager
{ {
public: public:
VConfigManager(); VConfigManager();
~VConfigManager();
void initialize(); void initialize();
// Read config from the directory config json file into a QJsonObject. // Read config from the directory config json file into a QJsonObject.