fix: Settings sometimes being reset on shutdown
This commit is contained in:
parent
d90a04990b
commit
c28522b7ef
@ -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;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -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()) {
|
||||||
|
@ -216,7 +216,7 @@ namespace hex {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void clearSelection() {
|
void clearSelection() {
|
||||||
impl::s_currentSelection.reset();
|
impl::s_currentSelection->reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setSelection(const Region ®ion, prv::Provider *provider) {
|
void setSelection(const Region ®ion, prv::Provider *provider) {
|
||||||
|
@ -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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user