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;
|
||||
}
|
||||
|
||||
bool isValid() const {
|
||||
return m_valid;
|
||||
}
|
||||
|
||||
private:
|
||||
friend void ImHexApi::System::impl::cleanup();
|
||||
|
||||
void reset() override {
|
||||
if constexpr (requires { m_value.reset(); }) {
|
||||
m_value.reset();
|
||||
@ -68,9 +75,12 @@ namespace hex {
|
||||
} else {
|
||||
m_value = { };
|
||||
}
|
||||
|
||||
m_valid = false;
|
||||
}
|
||||
|
||||
private:
|
||||
bool m_valid = true;
|
||||
T m_value;
|
||||
};
|
||||
|
||||
|
@ -128,7 +128,10 @@ namespace hex {
|
||||
}
|
||||
|
||||
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.
|
||||
if (settingsData.empty()) {
|
||||
|
@ -216,7 +216,7 @@ namespace hex {
|
||||
}
|
||||
|
||||
void clearSelection() {
|
||||
impl::s_currentSelection.reset();
|
||||
impl::s_currentSelection->reset();
|
||||
}
|
||||
|
||||
void setSelection(const Region ®ion, prv::Provider *provider) {
|
||||
|
@ -134,8 +134,8 @@ namespace hex {
|
||||
}
|
||||
|
||||
void LayoutManager::reset() {
|
||||
s_layoutPathToLoad.reset();
|
||||
s_layoutStringToLoad.reset();
|
||||
s_layoutPathToLoad->reset();
|
||||
s_layoutStringToLoad->reset();
|
||||
s_layouts->clear();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user