diff --git a/lib/external/pattern_language b/lib/external/pattern_language index 303204a37..842227ba4 160000 --- a/lib/external/pattern_language +++ b/lib/external/pattern_language @@ -1 +1 @@ -Subproject commit 303204a37e07fc2556d476b06acbbdb1e648840e +Subproject commit 842227ba459e4387b6208bc4c6686ba423802188 diff --git a/lib/libimhex/include/hex/api/content_registry.hpp b/lib/libimhex/include/hex/api/content_registry.hpp index 657c139dd..3f527b93d 100644 --- a/lib/libimhex/include/hex/api/content_registry.hpp +++ b/lib/libimhex/include/hex/api/content_registry.hpp @@ -20,10 +20,6 @@ using ImGuiDataType = int; using ImGuiInputTextFlags = int; -namespace pl { - class Evaluator; -} - namespace hex { class View; @@ -61,7 +57,7 @@ namespace hex { return name < other.name; } - operator const std::string &() const { + explicit operator const std::string &() const { return name; } }; @@ -435,7 +431,7 @@ namespace hex { class Hash { public: - Hash(std::string unlocalizedName) : m_unlocalizedName(std::move(unlocalizedName)) {} + explicit Hash(std::string unlocalizedName) : m_unlocalizedName(std::move(unlocalizedName)) {} class Function { public: @@ -498,6 +494,6 @@ namespace hex { } } - }; + } } diff --git a/lib/libimhex/include/hex/api/task.hpp b/lib/libimhex/include/hex/api/task.hpp index 81d33024c..74aa34e00 100644 --- a/lib/libimhex/include/hex/api/task.hpp +++ b/lib/libimhex/include/hex/api/task.hpp @@ -52,7 +52,7 @@ namespace hex { mutable std::mutex m_mutex; std::string m_unlocalizedName; - u64 m_currValue, m_maxValue; + u64 m_currValue = 0, m_maxValue = 0; std::thread m_thread; std::function m_interruptCallback; diff --git a/lib/libimhex/include/hex/helpers/utils.hpp b/lib/libimhex/include/hex/helpers/utils.hpp index 99dfbe6a9..4753e2a92 100644 --- a/lib/libimhex/include/hex/helpers/utils.hpp +++ b/lib/libimhex/include/hex/helpers/utils.hpp @@ -335,7 +335,7 @@ namespace hex { namespace first_time_exec { -#define FIRST_TIME [[maybe_unused]] static auto ANONYMOUS_VARIABLE(FIRST_TIME_) = ::hex::first_time_exec::FirstTimeExecutor() + [&]() + #define FIRST_TIME [[maybe_unused]] static auto ANONYMOUS_VARIABLE(FIRST_TIME_) = ::hex::first_time_exec::FirstTimeExecutor() + [&]() template class FirstTimeExecute { @@ -358,7 +358,7 @@ namespace hex { namespace final_cleanup { -#define FINAL_CLEANUP [[maybe_unused]] static auto ANONYMOUS_VARIABLE(ON_EXIT_) = ::hex::final_cleanup::FinalCleanupExecutor() + [&]() + #define FINAL_CLEANUP [[maybe_unused]] static auto ANONYMOUS_VARIABLE(ON_EXIT_) = ::hex::final_cleanup::FinalCleanupExecutor() + [&]() template class FinalCleanupExecute { diff --git a/lib/libimhex/include/hex/providers/provider.hpp b/lib/libimhex/include/hex/providers/provider.hpp index 87b452f0e..c0cfe47b8 100644 --- a/lib/libimhex/include/hex/providers/provider.hpp +++ b/lib/libimhex/include/hex/providers/provider.hpp @@ -97,7 +97,7 @@ namespace hex::prv { void markDirty(bool dirty = true) { this->m_dirty = dirty; } [[nodiscard]] bool isDirty() const { return this->m_dirty; } - virtual std::pair getRegionValidity(u64 address) const; + [[nodiscard]] virtual std::pair getRegionValidity(u64 address) const; void skipLoadInterface() { this->m_skipLoadInterface = true; } [[nodiscard]] bool shouldSkipLoadInterface() const { return this->m_skipLoadInterface; } diff --git a/lib/libimhex/include/hex/ui/imgui_imhex_extensions.h b/lib/libimhex/include/hex/ui/imgui_imhex_extensions.h index c34715f5d..d7d9c52f5 100644 --- a/lib/libimhex/include/hex/ui/imgui_imhex_extensions.h +++ b/lib/libimhex/include/hex/ui/imgui_imhex_extensions.h @@ -35,14 +35,14 @@ namespace ImGui { public: Texture() = default; Texture(const ImU8 *buffer, int size); - Texture(const char *path); + explicit Texture(const char *path); Texture(const Texture&) = delete; Texture(Texture&& other) noexcept; ~Texture(); - void operator=(const Texture&) = delete; - void operator=(Texture&& other) noexcept; + Texture& operator=(const Texture&) = delete; + Texture& operator=(Texture&& other) noexcept; [[nodiscard]] constexpr bool isValid() const noexcept { return this->m_textureId != nullptr; diff --git a/lib/libimhex/source/helpers/fs.cpp b/lib/libimhex/source/helpers/fs.cpp index c695ce2e2..352ba642c 100644 --- a/lib/libimhex/source/helpers/fs.cpp +++ b/lib/libimhex/source/helpers/fs.cpp @@ -194,7 +194,7 @@ namespace hex::fs { path = path / folder; return paths; - }; + } std::vector getPluginPaths() { std::vector paths = getDataPaths(); diff --git a/lib/libimhex/source/ui/imgui_imhex_extensions.cpp b/lib/libimhex/source/ui/imgui_imhex_extensions.cpp index 5d56f91cc..908e331c5 100644 --- a/lib/libimhex/source/ui/imgui_imhex_extensions.cpp +++ b/lib/libimhex/source/ui/imgui_imhex_extensions.cpp @@ -1,7 +1,6 @@ #include #include -#include #define IMGUI_DEFINE_MATH_OPERATORS #include #undef IMGUI_DEFINE_MATH_OPERATORS @@ -69,12 +68,14 @@ namespace ImGui { other.m_textureId = nullptr; } - void Texture::operator=(Texture&& other) noexcept { + Texture& Texture::operator=(Texture&& other) noexcept { this->m_textureId = other.m_textureId; this->m_width = other.m_width; this->m_height = other.m_height; other.m_textureId = nullptr; + + return *this; } Texture::~Texture() { @@ -103,8 +104,8 @@ namespace ImGui { ImGuiContext &g = *GImGui; const ImGuiID id = window->GetID(label); - ImVec2 label_size = CalcTextSize(icon, NULL, false); - label_size.x += CalcTextSize(" ", NULL, false).x + CalcTextSize(label, NULL, false).x; + ImVec2 label_size = CalcTextSize(icon, nullptr, false); + label_size.x += CalcTextSize(" ", nullptr, false).x + CalcTextSize(label, nullptr, false).x; ImVec2 pos = window->DC.CursorPos; ImVec2 size = CalcItemSize(size_arg, label_size.x, label_size.y); @@ -137,7 +138,7 @@ namespace ImGui { ImGuiContext &g = *GImGui; const ImGuiID id = window->GetID(label); - const ImVec2 label_size = CalcTextSize(label, NULL, true); + const ImVec2 label_size = CalcTextSize(label, nullptr, true); ImVec2 pos = window->DC.CursorPos; ImVec2 size = CalcItemSize(size_arg, label_size.x, label_size.y); @@ -154,7 +155,7 @@ namespace ImGui { // Render const ImU32 col = hovered ? GetColorU32(ImGuiCol_ButtonHovered) : GetColorU32(ImGuiCol_ButtonActive); PushStyleColor(ImGuiCol_Text, ImU32(col)); - TextEx(label, NULL, ImGuiTextFlags_NoWidthForLargeClippedText); // Skip formatting + TextEx(label, nullptr, ImGuiTextFlags_NoWidthForLargeClippedText); // Skip formatting GetWindowDrawList()->AddLine(ImVec2(pos.x, pos.y + size.y), pos + size, ImU32(col)); PopStyleColor(); @@ -170,7 +171,7 @@ namespace ImGui { ImGuiContext &g = *GImGui; const ImGuiStyle &style = g.Style; const ImGuiID id = window->GetID(label); - const ImVec2 label_size = CalcTextSize(label, NULL, true); + const ImVec2 label_size = CalcTextSize(label, nullptr, true); ImVec2 pos = window->DC.CursorPos; ImVec2 size = CalcItemSize(size_arg, label_size.x, label_size.y) + ImVec2(g.FontSize + style.FramePadding.x * 2, 0.0f); @@ -205,8 +206,8 @@ namespace ImGui { ImGuiContext &g = *GImGui; const ImGuiStyle &style = g.Style; const ImGuiID id = window->GetID(label); - const ImVec2 text_size = CalcTextSize((std::string(label) + "\n " + std::string(description)).c_str(), NULL, true); - const ImVec2 label_size = CalcTextSize(label, NULL, true); + const ImVec2 text_size = CalcTextSize((std::string(label) + "\n " + std::string(description)).c_str(), nullptr, true); + const ImVec2 label_size = CalcTextSize(label, nullptr, true); ImVec2 pos = window->DC.CursorPos; if ((flags & ImGuiButtonFlags_AlignTextBaseLine) && style.FramePadding.y < window->DC.CurrLineTextBaseOffset) // Try to vertically align buttons that are smaller/have no padding so that text baseline matches (bit hacky, since it shouldn't be a flag) @@ -234,7 +235,7 @@ namespace ImGui { RenderTextWrapped(bb.Min + style.FramePadding * 2, label, nullptr, CalcWrapWidthForPos(window->DC.CursorPos, window->DC.TextWrapPos)); PopStyleColor(); PushStyleColor(ImGuiCol_Text, GetColorU32(ImGuiCol_Text)); - RenderTextClipped(bb.Min + style.FramePadding * 2 + ImVec2(style.FramePadding.x * 2, label_size.y), bb.Max - style.FramePadding, description, NULL, &text_size, style.ButtonTextAlign, &bb); + RenderTextClipped(bb.Min + style.FramePadding * 2 + ImVec2(style.FramePadding.x * 2, label_size.y), bb.Max - style.FramePadding, description, nullptr, &text_size, style.ButtonTextAlign, &bb); PopStyleColor(); ImGui::PopStyleVar(); @@ -250,13 +251,13 @@ namespace ImGui { void UnderlinedText(const char *label, ImColor color, const ImVec2 &size_arg) { ImGuiWindow *window = GetCurrentWindow(); - const ImVec2 label_size = CalcTextSize(label, NULL, true); + const ImVec2 label_size = CalcTextSize(label, nullptr, true); ImVec2 pos = window->DC.CursorPos; ImVec2 size = CalcItemSize(size_arg, label_size.x, label_size.y); PushStyleColor(ImGuiCol_Text, ImU32(color)); - TextEx(label, NULL, ImGuiTextFlags_NoWidthForLargeClippedText); // Skip formatting + TextEx(label, nullptr, ImGuiTextFlags_NoWidthForLargeClippedText); // Skip formatting GetWindowDrawList()->AddLine(ImVec2(pos.x, pos.y + size.y), pos + size, ImU32(color)); PopStyleColor(); } @@ -382,7 +383,7 @@ namespace ImGui { ImGuiContext &g = *GImGui; const ImGuiStyle &style = g.Style; const ImGuiID id = window->GetID(label); - const ImVec2 label_size = CalcTextSize(label, NULL, true); + const ImVec2 label_size = CalcTextSize(label, nullptr, true); ImVec2 pos = window->DC.CursorPos; @@ -401,7 +402,7 @@ namespace ImGui { : ImGuiCol_Button); RenderNavHighlight(bb, id); RenderFrame(bb.Min, bb.Max, col, true, style.FrameRounding); - RenderTextClipped(bb.Min + style.FramePadding * ImVec2(1, 2), bb.Max - style.FramePadding, label, NULL, &label_size, style.ButtonTextAlign, &bb); + RenderTextClipped(bb.Min + style.FramePadding * ImVec2(1, 2), bb.Max - style.FramePadding, label, nullptr, &label_size, style.ButtonTextAlign, &bb); // Automatically close popups // if (pressed && !(flags & ImGuiButtonFlags_DontClosePopups) && (window->Flags & ImGuiWindowFlags_Popup)) @@ -421,7 +422,7 @@ namespace ImGui { ImGuiContext &g = *GImGui; const ImGuiStyle &style = g.Style; const ImGuiID id = window->GetID(symbol); - const ImVec2 label_size = CalcTextSize(symbol, NULL, true); + const ImVec2 label_size = CalcTextSize(symbol, nullptr, true); ImVec2 pos = window->DC.CursorPos; @@ -442,7 +443,7 @@ namespace ImGui { : ImGuiCol_MenuBarBg); RenderNavHighlight(bb, id); RenderFrame(bb.Min, bb.Max, col, false, style.FrameRounding); - RenderTextClipped(bb.Min + style.FramePadding * ImVec2(1, 2), bb.Max - style.FramePadding, symbol, NULL, &label_size, style.ButtonTextAlign, &bb); + RenderTextClipped(bb.Min + style.FramePadding * ImVec2(1, 2), bb.Max - style.FramePadding, symbol, nullptr, &label_size, style.ButtonTextAlign, &bb); PopStyleColor(); @@ -464,7 +465,7 @@ namespace ImGui { ImGuiContext &g = *GImGui; const ImGuiStyle &style = g.Style; const ImGuiID id = window->GetID(symbol); - const ImVec2 label_size = CalcTextSize(symbol, NULL, true); + const ImVec2 label_size = CalcTextSize(symbol, nullptr, true); ImVec2 pos = window->DC.CursorPos; @@ -485,7 +486,7 @@ namespace ImGui { : ImGuiCol_Button); RenderNavHighlight(bb, id); RenderFrame(bb.Min, bb.Max, col, false, style.FrameRounding); - RenderTextClipped(bb.Min + style.FramePadding * ImVec2(1, 2), bb.Max - style.FramePadding, symbol, NULL, &label_size, style.ButtonTextAlign, &bb); + RenderTextClipped(bb.Min + style.FramePadding * ImVec2(1, 2), bb.Max - style.FramePadding, symbol, nullptr, &label_size, style.ButtonTextAlign, &bb); PopStyleColor(); @@ -609,7 +610,7 @@ namespace ImGui { ImGuiContext& g = *GImGui; - if (format == NULL) + if (format == nullptr) format = DataTypeGetInfo(data_type)->PrintFmt; char buf[64]; @@ -648,7 +649,7 @@ namespace ImGui { ImGuiContext& g = *GImGui; const ImGuiStyle& style = g.Style; const ImGuiID id = window->GetID(label); - const ImVec2 label_size = CalcTextSize(label, NULL, true); + const ImVec2 label_size = CalcTextSize(label, nullptr, true); const ImVec2 size = ImVec2(CalcTextSize("0").x + style.FramePadding.x * 2, GetFrameHeight()); const ImVec2 pos = window->DC.CursorPos; diff --git a/main/include/window.hpp b/main/include/window.hpp index 6959c5fb4..a27b904ad 100644 --- a/main/include/window.hpp +++ b/main/include/window.hpp @@ -50,7 +50,7 @@ namespace hex { double m_lastFrameTime = 0; - ImGui::Texture m_logoTexture = { nullptr }; + ImGui::Texture m_logoTexture; std::mutex m_popupMutex; std::list m_popupsToOpen; diff --git a/main/source/window/window.cpp b/main/source/window/window.cpp index 1bc14cc90..4765efe89 100644 --- a/main/source/window/window.cpp +++ b/main/source/window/window.cpp @@ -80,7 +80,7 @@ namespace hex { #else std::raise(signalNumber); #endif - }; + } Window::Window() { { @@ -199,9 +199,16 @@ namespace hex { } } - this->frameBegin(); - this->frame(); + + try { + this->frame(); + } catch (const std::exception &e) { + log::error("Exception thrown in main loop: {}", e.what()); + } catch (...) { + log::error("Unknown exception thrown in main loop!"); + } + this->frameEnd(); const auto targetFps = ImHexApi::System::getTargetFPS(); diff --git a/plugins/builtin/include/content/helpers/pattern_drawer.hpp b/plugins/builtin/include/content/helpers/pattern_drawer.hpp index 19c239e46..6272bf089 100644 --- a/plugins/builtin/include/content/helpers/pattern_drawer.hpp +++ b/plugins/builtin/include/content/helpers/pattern_drawer.hpp @@ -40,4 +40,4 @@ namespace hex { private: std::map m_displayEnd; }; -}; \ No newline at end of file +} \ No newline at end of file diff --git a/plugins/builtin/include/content/providers/disk_provider.hpp b/plugins/builtin/include/content/providers/disk_provider.hpp index db79d8cee..d24c3c7a2 100644 --- a/plugins/builtin/include/content/providers/disk_provider.hpp +++ b/plugins/builtin/include/content/providers/disk_provider.hpp @@ -45,7 +45,7 @@ namespace hex::plugin::builtin::prv { return "hex.builtin.provider.disk"; } - std::pair getRegionValidity(u64 address) const override; + [[nodiscard]] std::pair getRegionValidity(u64 address) const override; protected: void reloadDrives(); diff --git a/plugins/builtin/include/content/providers/file_provider.hpp b/plugins/builtin/include/content/providers/file_provider.hpp index 82f0268ad..39f9ace8f 100644 --- a/plugins/builtin/include/content/providers/file_provider.hpp +++ b/plugins/builtin/include/content/providers/file_provider.hpp @@ -48,8 +48,8 @@ namespace hex::plugin::builtin::prv { [[nodiscard]] std::string getName() const override; [[nodiscard]] std::vector> getDataInformation() const override; - bool hasFilePicker() const override { return true; } - bool handleFilePicker() override; + [[nodiscard]] bool hasFilePicker() const override { return true; } + [[nodiscard]] bool handleFilePicker() override; void setPath(const std::fs::path &path); diff --git a/plugins/builtin/include/content/providers/gdb_provider.hpp b/plugins/builtin/include/content/providers/gdb_provider.hpp index 2291dc4a2..3557c4f03 100644 --- a/plugins/builtin/include/content/providers/gdb_provider.hpp +++ b/plugins/builtin/include/content/providers/gdb_provider.hpp @@ -49,7 +49,7 @@ namespace hex::plugin::builtin::prv { return "hex.builtin.provider.gdb"; } - std::pair getRegionValidity(u64 address) const override; + [[nodiscard]] std::pair getRegionValidity(u64 address) const override; protected: hex::Socket m_socket; diff --git a/plugins/builtin/include/content/providers/intel_hex_provider.hpp b/plugins/builtin/include/content/providers/intel_hex_provider.hpp index 4e101115f..5a0e8a64f 100644 --- a/plugins/builtin/include/content/providers/intel_hex_provider.hpp +++ b/plugins/builtin/include/content/providers/intel_hex_provider.hpp @@ -36,8 +36,8 @@ namespace hex::plugin::builtin::prv { return "hex.builtin.provider.intel_hex"; } - bool hasFilePicker() const override { return true; } - bool handleFilePicker() override; + [[nodiscard]] bool hasFilePicker() const override { return true; } + [[nodiscard]] bool handleFilePicker() override; std::pair getRegionValidity(u64 address) const override; diff --git a/plugins/builtin/source/content/data_visualizers.cpp b/plugins/builtin/source/content/data_visualizers.cpp index 51d342eae..73eab85d1 100644 --- a/plugins/builtin/source/content/data_visualizers.cpp +++ b/plugins/builtin/source/content/data_visualizers.cpp @@ -107,7 +107,7 @@ namespace hex::plugin::builtin { const static inline auto FormattingUpperCase = hex::format("%0{}X", CharCount); const static inline auto FormattingLowerCase = hex::format("%0{}x", CharCount); - const char *getFormatString(bool upperCase) { + static const char *getFormatString(bool upperCase) { if (upperCase) return FormattingUpperCase.c_str(); else @@ -237,7 +237,7 @@ namespace hex::plugin::builtin { const static inline auto FormatStringUpperCase = hex::format("%{}G", CharCount); const static inline auto FormatStringLowerCase = hex::format("%{}g", CharCount); - const char *getFormatString(bool upperCase) { + static const char *getFormatString(bool upperCase) { if (upperCase) return FormatStringUpperCase.c_str(); else diff --git a/plugins/builtin/source/content/helpers/pattern_drawer.cpp b/plugins/builtin/source/content/helpers/pattern_drawer.cpp index 87d3c01a2..c32924f4f 100644 --- a/plugins/builtin/source/content/helpers/pattern_drawer.cpp +++ b/plugins/builtin/source/content/helpers/pattern_drawer.cpp @@ -430,4 +430,4 @@ namespace hex { auto [value, success] = this->m_displayEnd.emplace(&pattern, DisplayEndDefault); return value->second; } -}; +} diff --git a/plugins/builtin/source/content/settings_entries.cpp b/plugins/builtin/source/content/settings_entries.cpp index 33548fce3..3f4d0cddb 100644 --- a/plugins/builtin/source/content/settings_entries.cpp +++ b/plugins/builtin/source/content/settings_entries.cpp @@ -14,8 +14,10 @@ #include namespace { - static std::vector userFolders; - static void loadUserFoldersFromSetting(nlohmann::json &setting) { + + std::vector userFolders; + + void loadUserFoldersFromSetting(nlohmann::json &setting) { userFolders.clear(); std::vector paths = setting; for (const auto &path : paths) { @@ -24,7 +26,8 @@ namespace { userFolders.emplace_back(uString); } } -}; + +} namespace hex::plugin::builtin { diff --git a/plugins/builtin/source/content/views/view_find.cpp b/plugins/builtin/source/content/views/view_find.cpp index 1957b1034..f899a09ff 100644 --- a/plugins/builtin/source/content/views/view_find.cpp +++ b/plugins/builtin/source/content/views/view_find.cpp @@ -183,7 +183,7 @@ namespace hex::plugin::builtin { case F64: return parseNumericValue(input); default: return { false, { }, 0 }; } - }; + } template static std::string formatBytes(const std::vector &bytes) { diff --git a/plugins/builtin/source/content/views/view_hex_editor.cpp b/plugins/builtin/source/content/views/view_hex_editor.cpp index 11b0c4bf9..e230b20c3 100644 --- a/plugins/builtin/source/content/views/view_hex_editor.cpp +++ b/plugins/builtin/source/content/views/view_hex_editor.cpp @@ -1016,13 +1016,13 @@ namespace hex::plugin::builtin { if ((ImGui::IsMouseDown(ImGuiMouseButton_Left) && providerData.selectionStart != providerData.selectionEnd)) { auto fractionPerLine = 1.0 / (this->m_visibleRowCount + 1); - if (y == u64(clipper.DisplayStart + 3)) { + if (y == (u64(clipper.DisplayStart) + 3)) { if (i128(*providerData.selectionEnd - provider->getBaseAddress() - provider->getCurrentPageAddress()) <= (i64(clipper.DisplayStart + 3) * this->m_bytesPerRow)) { this->m_shouldScrollToSelection = false; ImGui::SetScrollHereY(fractionPerLine * 5); } - } else if (y == u64(clipper.DisplayEnd - 3)) { + } else if (y == (u64(clipper.DisplayStart) - 3)) { if (i128(*providerData.selectionEnd - provider->getBaseAddress() - provider->getCurrentPageAddress()) >= (i64(clipper.DisplayEnd - 3) * this->m_bytesPerRow)) { this->m_shouldScrollToSelection = false; ImGui::SetScrollHereY(fractionPerLine * (this->m_visibleRowCount - 1)); diff --git a/plugins/builtin/source/content/views/view_information.cpp b/plugins/builtin/source/content/views/view_information.cpp index a23f45e33..7421afa0f 100644 --- a/plugins/builtin/source/content/views/view_information.cpp +++ b/plugins/builtin/source/content/views/view_information.cpp @@ -35,7 +35,7 @@ namespace hex::plugin::builtin { EventManager::subscribe(this, [this](Region region) { if (this->m_blockSize != 0) - this->m_entropyHandlePosition = region.getStartAddress() / this->m_blockSize; + this->m_entropyHandlePosition = region.getStartAddress() / double(this->m_blockSize); }); EventManager::subscribe(this, [this](const auto*) { diff --git a/plugins/builtin/source/content/views/view_pattern_editor.cpp b/plugins/builtin/source/content/views/view_pattern_editor.cpp index 56e39e461..0f73ed64a 100644 --- a/plugins/builtin/source/content/views/view_pattern_editor.cpp +++ b/plugins/builtin/source/content/views/view_pattern_editor.cpp @@ -642,11 +642,11 @@ namespace hex::plugin::builtin { ImGui::InputScalar(label.c_str(), ImGuiDataType_U64, &value); variable.value = u128(value); } else if (pl::core::Token::isFloatingPoint(variable.type)) { - double value = hex::get_or(variable.value, 0.0); + auto value = hex::get_or(variable.value, 0.0); ImGui::InputScalar(label.c_str(), ImGuiDataType_Double, &value); variable.value = value; } else if (variable.type == pl::core::Token::ValueType::Boolean) { - bool value = hex::get_or(variable.value, false); + auto value = hex::get_or(variable.value, false); ImGui::Checkbox(label.c_str(), &value); variable.value = value; } else if (variable.type == pl::core::Token::ValueType::Character) { diff --git a/plugins/builtin/source/content/views/view_settings.cpp b/plugins/builtin/source/content/views/view_settings.cpp index 66f9d8b8e..ef4f46a04 100644 --- a/plugins/builtin/source/content/views/view_settings.cpp +++ b/plugins/builtin/source/content/views/view_settings.cpp @@ -50,10 +50,11 @@ namespace hex::plugin::builtin { for (auto &it : sortedCategories) { auto &[category, settings] = *it; - if (ImGui::BeginTabItem(LangEntry(category))) { - const std::string &categoryDesc = descriptions.count(category) ? descriptions.at(category) : category.name; + if (ImGui::BeginTabItem(LangEntry(category.name))) { + const std::string &categoryDesc = descriptions.contains(category.name) ? descriptions.at(category.name) : category.name; + LangEntry descriptionEntry{categoryDesc}; - ImGui::TextWrapped("%s", static_cast(descriptionEntry)); + ImGui::TextFormattedWrapped("{}", descriptionEntry); ImGui::InfoTooltip(descriptionEntry); ImGui::Separator(); @@ -85,7 +86,7 @@ namespace hex::plugin::builtin { } else this->getWindowOpenState() = false; - if (this->getWindowOpenState() == false && this->m_restartRequested) { + if (!this->getWindowOpenState() && this->m_restartRequested) { View::showYesNoQuestionPopup("hex.builtin.view.settings.restart_question"_lang, ImHexApi::Common::restartImHex, [] {}); } } diff --git a/plugins/windows/source/views/view_tty_console.cpp b/plugins/windows/source/views/view_tty_console.cpp index f7d9068de..0208f52d1 100644 --- a/plugins/windows/source/views/view_tty_console.cpp +++ b/plugins/windows/source/views/view_tty_console.cpp @@ -191,7 +191,7 @@ namespace hex::plugin::windows { View::showErrorPopup("hex.windows.view.tty_console.no_available_port"_lang); return true; // If false, connect_error error popup will override this error popup } - this->m_portHandle = ::CreateFile(("\\\\.\\" + this->m_comPorts[this->m_selectedPort].first).c_str(), + this->m_portHandle = ::CreateFile((R"(\\.\)" + this->m_comPorts[this->m_selectedPort].first).c_str(), GENERIC_READ | GENERIC_WRITE, 0, nullptr,