1
0
mirror of synced 2024-11-24 15:50:16 +01:00

fix: Settings sometimes being reset on shutdown

This commit is contained in:
WerWolv 2024-05-16 19:00:31 +02:00
parent d90a04990b
commit c28522b7ef
4 changed files with 17 additions and 4 deletions

View File

@ -58,6 +58,13 @@ namespace hex {
return m_value; return m_value;
} }
bool isValid() const {
return m_valid;
}
private:
friend void ImHexApi::System::impl::cleanup();
void reset() override { void reset() override {
if constexpr (requires { m_value.reset(); }) { if constexpr (requires { m_value.reset(); }) {
m_value.reset(); m_value.reset();
@ -68,9 +75,12 @@ namespace hex {
} else { } else {
m_value = { }; m_value = { };
} }
m_valid = false;
} }
private: private:
bool m_valid = true;
T m_value; T m_value;
}; };

View File

@ -128,7 +128,10 @@ namespace hex {
} }
void store() { void store() {
const auto &settingsData = getSettingsData(); if (!s_settings.isValid())
return;
const auto &settingsData = *s_settings;
// During a crash settings can be empty, causing them to be overwritten. // During a crash settings can be empty, causing them to be overwritten.
if (settingsData.empty()) { if (settingsData.empty()) {

View File

@ -216,7 +216,7 @@ namespace hex {
} }
void clearSelection() { void clearSelection() {
impl::s_currentSelection.reset(); impl::s_currentSelection->reset();
} }
void setSelection(const Region &region, prv::Provider *provider) { void setSelection(const Region &region, prv::Provider *provider) {

View File

@ -134,8 +134,8 @@ namespace hex {
} }
void LayoutManager::reset() { void LayoutManager::reset() {
s_layoutPathToLoad.reset(); s_layoutPathToLoad->reset();
s_layoutStringToLoad.reset(); s_layoutStringToLoad->reset();
s_layouts->clear(); s_layouts->clear();
} }