1
0
mirror of synced 2025-02-22 04:49:44 +01:00

fix: Restarting ImHex not working correctly

This commit is contained in:
WerWolv 2022-08-16 11:48:37 +02:00
parent 7e01ff451f
commit 0c0caf6942
4 changed files with 40 additions and 32 deletions

View File

@ -126,6 +126,7 @@ namespace hex {
EVENT_DEF(RequestSetPatternLanguageCode, std::string); EVENT_DEF(RequestSetPatternLanguageCode, std::string);
EVENT_DEF(RequestChangeWindowTitle, std::string); EVENT_DEF(RequestChangeWindowTitle, std::string);
EVENT_DEF(RequestCloseImHex, bool); EVENT_DEF(RequestCloseImHex, bool);
EVENT_DEF(RequestRestartImHex);
EVENT_DEF(RequestOpenFile, std::fs::path); EVENT_DEF(RequestOpenFile, std::fs::path);
EVENT_DEF(RequestChangeTheme, u32); EVENT_DEF(RequestChangeTheme, u32);
EVENT_DEF(RequestOpenPopup, std::string); EVENT_DEF(RequestOpenPopup, std::string);

View File

@ -20,11 +20,8 @@ namespace hex {
} }
void restartImHex() { void restartImHex() {
EventManager::post<RequestRestartImHex>();
EventManager::post<RequestCloseImHex>(false); EventManager::post<RequestCloseImHex>(false);
std::atexit([] {
auto &programArgs = ImHexApi::System::getProgramArguments();
execve(programArgs.argv[0], programArgs.argv, programArgs.envp);
});
} }
} }
@ -393,7 +390,7 @@ namespace hex {
s_customFontPath = path; s_customFontPath = path;
} }
static float s_fontSize = 13.0; static float s_fontSize = DefaultFontSize;
void setFontSize(float size) { void setFontSize(float size) {
s_fontSize = size; s_fontSize = size;
} }

View File

@ -221,6 +221,7 @@ namespace hex::init {
ContentRegistry::DataFormatter::getEntries().clear(); ContentRegistry::DataFormatter::getEntries().clear();
ContentRegistry::FileHandler::getEntries().clear(); ContentRegistry::FileHandler::getEntries().clear();
ContentRegistry::Hashes::impl::getHashes().clear();
{ {
auto &visualizers = ContentRegistry::HexEditor::impl::getVisualizers(); auto &visualizers = ContentRegistry::HexEditor::impl::getVisualizers();

View File

@ -18,6 +18,13 @@ int main(int argc, char **argv, char **envp) {
ImHexApi::System::impl::setBorderlessWindowMode(true); ImHexApi::System::impl::setBorderlessWindowMode(true);
#endif #endif
bool shouldRestart = false;
EventManager::subscribe<RequestRestartImHex>([&]{ shouldRestart = true; });
do {
shouldRestart = false;
// Initialization // Initialization
{ {
Window::initNative(); Window::initNative();
@ -55,5 +62,7 @@ int main(int argc, char **argv, char **envp) {
window.loop(); window.loop();
} }
} while (shouldRestart);
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }