1
0
mirror of synced 2025-01-11 05:42:15 +01:00

fix: Shortcut migration not working correctly in some cases

Fixes #2045
This commit is contained in:
WerWolv 2025-01-03 10:16:22 +01:00
parent a55df1d111
commit d8fb3f526a
5 changed files with 13 additions and 2 deletions

View File

@ -297,6 +297,7 @@ namespace hex {
EVENT_DEF(RequestChangeTheme, std::string); EVENT_DEF(RequestChangeTheme, std::string);
EVENT_DEF(RequestOpenPopup, std::string); EVENT_DEF(RequestOpenPopup, std::string);
EVENT_DEF(RequestAddVirtualFile, std::fs::path, std::vector<u8>, Region); EVENT_DEF(RequestAddVirtualFile, std::fs::path, std::vector<u8>, Region);
EVENT_DEF(RequestStartMigration);
/** /**
* @brief Creates a provider from it's unlocalized name, and add it to the provider list * @brief Creates a provider from it's unlocalized name, and add it to the provider list

View File

@ -154,6 +154,14 @@ namespace hex {
if (!s_settings.isValid()) if (!s_settings.isValid())
return; return;
for (const auto &category : getSettings()) {
for (const auto &subCategory : category.subCategories) {
for (const auto &entry : subCategory.entries) {
(*s_settings)[category.unlocalizedName][entry.unlocalizedName] = entry.widget->store();
}
}
}
const auto &settingsData = *s_settings; 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.

View File

@ -79,6 +79,7 @@ namespace hex {
EventWindowInitialized::post(); EventWindowInitialized::post();
EventImHexStartupFinished::post(); EventImHexStartupFinished::post();
RequestStartMigration::post();
TutorialManager::init(); TutorialManager::init();

View File

@ -225,7 +225,7 @@ namespace hex::plugin::builtin {
RequestOpenFile::post(path); RequestOpenFile::post(path);
}); });
EventWindowInitialized::subscribe([] { RequestStartMigration::subscribe([] {
const auto currVersion = ImHexApi::System::getImHexVersion(); const auto currVersion = ImHexApi::System::getImHexVersion();
const auto prevLaunchVersion = ContentRegistry::Settings::read<std::string>("hex.builtin.setting.general", "hex.builtin.setting.general.prev_launch_version", ""); const auto prevLaunchVersion = ContentRegistry::Settings::read<std::string>("hex.builtin.setting.general", "hex.builtin.setting.general.prev_launch_version", "");
if (prevLaunchVersion == "") { if (prevLaunchVersion == "") {

View File

@ -359,6 +359,7 @@ namespace hex::plugin::builtin {
m_hasDuplicate = !ShortcutManager::updateShortcut(m_shortcut, m_defaultShortcut, m_view); m_hasDuplicate = !ShortcutManager::updateShortcut(m_shortcut, m_defaultShortcut, m_view);
m_drawShortcut = m_defaultShortcut; m_drawShortcut = m_defaultShortcut;
m_shortcut = m_defaultShortcut;
} }
private: private:
@ -993,7 +994,7 @@ namespace hex::plugin::builtin {
ContentRegistry::Settings::add<ToolbarIconsWidget>("hex.builtin.setting.toolbar", "", "hex.builtin.setting.toolbar.icons"); ContentRegistry::Settings::add<ToolbarIconsWidget>("hex.builtin.setting.toolbar", "", "hex.builtin.setting.toolbar.icons");
} }
ImHexApi::System::addMigrationRoutine("v1.36.1", [] { ImHexApi::System::addMigrationRoutine("v1.36.3", [] {
log::warn("Resetting shortcut key settings for them to work with this version of ImHex"); log::warn("Resetting shortcut key settings for them to work with this version of ImHex");
for (const auto &category : ContentRegistry::Settings::impl::getSettings()) { for (const auto &category : ContentRegistry::Settings::impl::getSettings()) {