1
0
mirror of synced 2024-11-24 07:40:17 +01:00

fix: Remove debug popup function in release mode to avoid build errors

This commit is contained in:
WerWolv 2024-03-02 14:23:52 +01:00
parent ba12f7aec9
commit 54266bf63b

View File

@ -49,81 +49,85 @@ namespace hex::plugin::builtin {
} }
} }
static void drawDebugPopup() { #if defined(DEBUG)
static bool showImGuiDemo = false;
static bool showImPlotDemo = false;
ImGui::SetNextWindowSize(scaled({ 300, 150 }), ImGuiCond_Always); static void drawDebugPopup() {
if (ImGui::BeginPopup("DebugMenu")) { static bool showImGuiDemo = false;
if (ImGui::BeginTabBar("DebugTabBar")) { static bool showImPlotDemo = false;
if (ImGui::BeginTabItem("ImHex")) {
if (ImGui::BeginChild("Scrolling", ImGui::GetContentRegionAvail())) {
ImGui::Checkbox("Show Debug Variables", &dbg::impl::getDebugWindowState());
ImGuiExt::Header("Information"); ImGui::SetNextWindowSize(scaled({ 300, 150 }), ImGuiCond_Always);
ImGuiExt::TextFormatted("Running Tasks: {0}", TaskManager::getRunningTaskCount()); if (ImGui::BeginPopup("DebugMenu")) {
ImGuiExt::TextFormatted("Running Background Tasks: {0}", TaskManager::getRunningBackgroundTaskCount()); if (ImGui::BeginTabBar("DebugTabBar")) {
ImGuiExt::TextFormatted("Last Frame Time: {0:.3f}ms", ImHexApi::System::getLastFrameTime() * 1000.0F); if (ImGui::BeginTabItem("ImHex")) {
if (ImGui::BeginChild("Scrolling", ImGui::GetContentRegionAvail())) {
ImGui::Checkbox("Show Debug Variables", &dbg::impl::getDebugWindowState());
ImGuiExt::Header("Information");
ImGuiExt::TextFormatted("Running Tasks: {0}", TaskManager::getRunningTaskCount());
ImGuiExt::TextFormatted("Running Background Tasks: {0}", TaskManager::getRunningBackgroundTaskCount());
ImGuiExt::TextFormatted("Last Frame Time: {0:.3f}ms", ImHexApi::System::getLastFrameTime() * 1000.0F);
}
ImGui::EndChild();
ImGui::EndTabItem();
} }
ImGui::EndChild(); if (ImGui::BeginTabItem("ImGui")) {
if (ImGui::BeginChild("Scrolling", ImGui::GetContentRegionAvail())) {
auto ctx = ImGui::GetCurrentContext();
ImGui::Checkbox("Show ImGui Demo", &showImGuiDemo);
ImGui::Checkbox("Show ImPlot Demo", &showImPlotDemo);
ImGui::EndTabItem(); if (ImGui::Button("Trigger Breakpoint in Item") || ctx->DebugItemPickerActive)
} ImGui::DebugStartItemPicker();
if (ImGui::BeginTabItem("ImGui")) { }
if (ImGui::BeginChild("Scrolling", ImGui::GetContentRegionAvail())) { ImGui::EndChild();
auto ctx = ImGui::GetCurrentContext();
ImGui::Checkbox("Show ImGui Demo", &showImGuiDemo);
ImGui::Checkbox("Show ImPlot Demo", &showImPlotDemo);
if (ImGui::Button("Trigger Breakpoint in Item") || ctx->DebugItemPickerActive) ImGui::EndTabItem();
ImGui::DebugStartItemPicker();
} }
ImGui::EndChild(); if (ImGui::BeginTabItem("Crashes")) {
if (ImGui::BeginChild("Scrolling", ImGui::GetContentRegionAvail())) {
if (ImGui::Button("Throw Exception")) {
TaskManager::doLater([] {
throw std::runtime_error("Test exception");
});
}
if (ImGui::Button("Access Invalid Memory")) {
TaskManager::doLater([] {
*reinterpret_cast<u32*>(0x10) = 0x10;
std::unreachable();
});
}
if (ImGui::Button("Raise SIGSEGV")) {
TaskManager::doLater([] {
raise(SIGSEGV);
});
}
if (ImGui::Button("Corrupt Memory")) {
TaskManager::doLater([] {
auto bytes = new u8[0xFFFFF];
ImGui::EndTabItem(); delete[] bytes;
} delete[] bytes;
if (ImGui::BeginTabItem("Crashes")) { });
if (ImGui::BeginChild("Scrolling", ImGui::GetContentRegionAvail())) { }
if (ImGui::Button("Throw Exception")) {
TaskManager::doLater([] {
throw std::runtime_error("Test exception");
});
} }
if (ImGui::Button("Access Invalid Memory")) { ImGui::EndChild();
TaskManager::doLater([] {
*reinterpret_cast<u32*>(0x10) = 0x10;
std::unreachable();
});
}
if (ImGui::Button("Raise SIGSEGV")) {
TaskManager::doLater([] {
raise(SIGSEGV);
});
}
if (ImGui::Button("Corrupt Memory")) {
TaskManager::doLater([] {
auto bytes = new u8[0xFFFFF];
delete[] bytes; ImGui::EndTabItem();
delete[] bytes;
});
}
} }
ImGui::EndChild();
ImGui::EndTabItem(); ImGui::EndTabBar();
} }
ImGui::EndPopup();
ImGui::EndTabBar();
} }
ImGui::EndPopup();
if (showImGuiDemo)
ImGui::ShowDemoWindow(&showImGuiDemo);
if (showImPlotDemo)
ImPlot::ShowDemoWindow(&showImPlotDemo);
} }
if (showImGuiDemo) #endif
ImGui::ShowDemoWindow(&showImGuiDemo);
if (showImPlotDemo)
ImPlot::ShowDemoWindow(&showImPlotDemo);
}
static bool s_drawDragDropOverlay = false; static bool s_drawDragDropOverlay = false;
static void drawDragNDropOverlay() { static void drawDragNDropOverlay() {