mirror of
https://github.com/overte-org/overte.git
synced 2025-08-07 16:50:43 +02:00
Don't call virtual method from base dtor
This commit is contained in:
parent
b849316f60
commit
0c32f47f50
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); }
|
||||
|
|
|
@ -78,12 +78,6 @@ namespace Setting {
|
|||
qAddPostRoutine(cleanupPrivateInstance);
|
||||
}
|
||||
|
||||
Interface::~Interface() {
|
||||
if (privateInstance) {
|
||||
privateInstance->removeHandle(_key);
|
||||
}
|
||||
}
|
||||
|
||||
void Interface::init() {
|
||||
if (!privateInstance) {
|
||||
// WARNING: As long as we are using QSettings this should always be triggered for each Setting::Handle
|
||||
|
@ -102,6 +96,16 @@ namespace Setting {
|
|||
}
|
||||
}
|
||||
|
||||
void Interface::deinit() {
|
||||
if (privateInstance) {
|
||||
// Save value to disk
|
||||
save();
|
||||
|
||||
privateInstance->removeHandle(_key);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Interface::maybeInit() {
|
||||
if (!_isInitialized) {
|
||||
init();
|
||||
|
|
|
@ -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