From 73d4214fd3cbe69f6685aa0264b042303160ad5c Mon Sep 17 00:00:00 2001 From: WerWolv Date: Sat, 10 Jun 2023 15:08:56 +0200 Subject: [PATCH] fix: Window title being cleared after ImHex exits --- lib/libimhex/include/hex/api/event.hpp | 20 ++++++++++---------- main/source/init/tasks.cpp | 6 +++--- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/libimhex/include/hex/api/event.hpp b/lib/libimhex/include/hex/api/event.hpp index 7556b35f7..048113421 100644 --- a/lib/libimhex/include/hex/api/event.hpp +++ b/lib/libimhex/include/hex/api/event.hpp @@ -13,15 +13,15 @@ #include -#define EVENT_DEF_IMPL(event_name, should_log, ...) \ - struct event_name final : public hex::impl::Event<__VA_ARGS__> { \ - constexpr static auto Id = [] { return hex::impl::EventId(); }(); \ - constexpr static auto ShouldLog = (should_log); \ - explicit event_name(Callback func) noexcept : Event(std::move(func)) { } \ +#define EVENT_DEF_IMPL(event_name, event_name_string, should_log, ...) \ + struct event_name final : public hex::impl::Event<__VA_ARGS__> { \ + constexpr static auto Id = [] { return hex::impl::EventId(event_name_string); }(); \ + constexpr static auto ShouldLog = (should_log); \ + explicit event_name(Callback func) noexcept : Event(std::move(func)) { } \ } -#define EVENT_DEF(event_name, ...) EVENT_DEF_IMPL(event_name, true, __VA_ARGS__) -#define EVENT_DEF_NO_LOG(event_name, ...) EVENT_DEF_IMPL(event_name, false, __VA_ARGS__) +#define EVENT_DEF(event_name, ...) EVENT_DEF_IMPL(event_name, #event_name, true, __VA_ARGS__) +#define EVENT_DEF_NO_LOG(event_name, ...) EVENT_DEF_IMPL(event_name, #event_name, false, __VA_ARGS__) struct GLFWwindow; @@ -31,9 +31,9 @@ namespace hex { class EventId { public: - explicit constexpr EventId(const char *func = __builtin_FUNCTION(), u32 line = __builtin_LINE()) { - this->m_hash = line ^ 987654321; - for (auto c : std::string_view(func)) { + explicit constexpr EventId(const char *eventName) { + this->m_hash = 0x811C'9DC5; + for (auto c : std::string_view(eventName)) { this->m_hash = (this->m_hash >> 5) | (this->m_hash << 27); this->m_hash ^= c; } diff --git a/main/source/init/tasks.cpp b/main/source/init/tasks.cpp index ead3fb43f..41dd01990 100644 --- a/main/source/init/tasks.cpp +++ b/main/source/init/tasks.cpp @@ -227,7 +227,7 @@ namespace hex::init { cfg.MergeMode = true; // Add font awesome and codicons icons to font atlas - cfg.GlyphOffset = ImVec2(0, 3); + cfg.GlyphOffset = ImVec2(0, 3_scaled); fonts->AddFontFromMemoryCompressedTTF(font_awesome_compressed_data, font_awesome_compressed_size, 0, &cfg, fontAwesomeRange); fonts->AddFontFromMemoryCompressedTTF(codicons_compressed_data, codicons_compressed_size, 0, &cfg, codiconsRange); @@ -276,6 +276,8 @@ namespace hex::init { EventManager::post(); + EventManager::clear(); + while (ImHexApi::Provider::isValid()) ImHexApi::Provider::remove(ImHexApi::Provider::get()); ContentRegistry::Provider::impl::getEntries().clear(); @@ -348,8 +350,6 @@ namespace hex::init { fs::setFileBrowserErrorCallback(nullptr); - EventManager::clear(); - return true; }