1
0
mirror of synced 2025-02-21 12:29:47 +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(RequestChangeWindowTitle, std::string);
EVENT_DEF(RequestCloseImHex, bool);
EVENT_DEF(RequestRestartImHex);
EVENT_DEF(RequestOpenFile, std::fs::path);
EVENT_DEF(RequestChangeTheme, u32);
EVENT_DEF(RequestOpenPopup, std::string);

View File

@ -20,11 +20,8 @@ namespace hex {
}
void restartImHex() {
EventManager::post<RequestRestartImHex>();
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;
}
static float s_fontSize = 13.0;
static float s_fontSize = DefaultFontSize;
void setFontSize(float size) {
s_fontSize = size;
}

View File

@ -221,6 +221,7 @@ namespace hex::init {
ContentRegistry::DataFormatter::getEntries().clear();
ContentRegistry::FileHandler::getEntries().clear();
ContentRegistry::Hashes::impl::getHashes().clear();
{
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);
#endif
bool shouldRestart = false;
EventManager::subscribe<RequestRestartImHex>([&]{ shouldRestart = true; });
do {
shouldRestart = false;
// Initialization
{
Window::initNative();
@ -55,5 +62,7 @@ int main(int argc, char **argv, char **envp) {
window.loop();
}
} while (shouldRestart);
return EXIT_SUCCESS;
}