Codechange: make explicit that virtual functions in a con/destructor are resolved statically

This as during construction the sub class has not been initialized yet, and
during destruction the sub class has already been destroyed, so the overriding
virtual function would be accessing uninitialized data.
pull/332/head
Rubidium 3 years ago committed by rubidium42
parent d7ce61f106
commit 7755f81bb8

@ -216,7 +216,8 @@ TrueTypeFontCache::TrueTypeFontCache(FontSize fs, int pixels) : FontCache(fs), r
*/
TrueTypeFontCache::~TrueTypeFontCache()
{
this->ClearFontCache();
/* Virtual functions get called statically in destructors, so make it explicit to remove any confusion. */
this->TrueTypeFontCache::ClearFontCache();
for (auto &iter : this->font_tables) {
free(iter.second.second);

@ -37,6 +37,7 @@ void ScriptConfig::Change(const char *name, int version, bool force_exact_match,
this->SetSetting(item.name, InteractiveRandomRange(item.max_value + 1 - item.min_value) + item.min_value);
}
}
this->AddRandomDeviation();
}
}
@ -52,7 +53,9 @@ ScriptConfig::ScriptConfig(const ScriptConfig *config)
for (const auto &item : config->settings) {
this->settings[stredup(item.first)] = item.second;
}
this->AddRandomDeviation();
/* Virtual functions get called statically in constructors, so make it explicit to remove any confusion. */
this->ScriptConfig::AddRandomDeviation();
}
ScriptConfig::~ScriptConfig()

@ -1094,7 +1094,8 @@ Window::~Window()
/* Make sure we don't try to access this window as the focused window when it doesn't exist anymore. */
if (_focused_window == this) {
this->OnFocusLost();
/* Virtual functions get called statically in destructors, so make it explicit to remove any confusion. */
this->Window::OnFocusLost();
_focused_window = nullptr;
}

Loading…
Cancel
Save