mirror of
https://github.com/overte-org/overte.git
synced 2025-04-18 02:52:04 +02:00
Merge pull request #7732 from Atlante45/fix/settings-crash
Fix crash on exit in Settings
This commit is contained in:
commit
e827a99222
3 changed files with 13 additions and 8 deletions
|
@ -46,7 +46,7 @@ namespace Setting {
|
|||
Handle(const QString& key, const T& defaultValue) : Interface(key), _defaultValue(defaultValue) {}
|
||||
Handle(const QStringList& path, const T& defaultValue) : Handle(path.join("/"), defaultValue) {}
|
||||
|
||||
virtual ~Handle() { save(); }
|
||||
virtual ~Handle() { deinit(); }
|
||||
|
||||
// Returns setting value, returns its default value if not found
|
||||
T get() { return get(_defaultValue); }
|
||||
|
|
|
@ -76,12 +76,6 @@ namespace Setting {
|
|||
|
||||
// Register cleanupPrivateInstance to run inside QCoreApplication's destructor.
|
||||
qAddPostRoutine(cleanupPrivateInstance);
|
||||
}
|
||||
|
||||
Interface::~Interface() {
|
||||
if (privateInstance) {
|
||||
privateInstance->removeHandle(_key);
|
||||
}
|
||||
}
|
||||
|
||||
void Interface::init() {
|
||||
|
@ -101,6 +95,16 @@ namespace Setting {
|
|||
load();
|
||||
}
|
||||
}
|
||||
|
||||
void Interface::deinit() {
|
||||
if (privateInstance) {
|
||||
// Save value to disk
|
||||
save();
|
||||
|
||||
privateInstance->removeHandle(_key);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Interface::maybeInit() {
|
||||
if (!_isInitialized) {
|
||||
|
|
|
@ -30,10 +30,11 @@ namespace Setting {
|
|||
|
||||
protected:
|
||||
Interface(const QString& key) : _key(key) {}
|
||||
virtual ~Interface();
|
||||
virtual ~Interface() = default;
|
||||
|
||||
void init();
|
||||
void maybeInit();
|
||||
void deinit();
|
||||
|
||||
void save();
|
||||
void load();
|
||||
|
|
Loading…
Reference in a new issue