From 969af7c77369ddf2e8da23f1d4335270d8ac75be Mon Sep 17 00:00:00 2001 From: Teselka Date: Sun, 20 Nov 2022 23:45:55 +0200 Subject: [PATCH] Internal: Disable debug logs macro if IMGUI_DISABLE_DEBUG_TOOLS is defined. (#5901) + needed to rework clipper code to avoid "The 'then' statement is equivalent to the 'else' statement." PVS Studio warning. --- docs/CHANGELOG.txt | 6 ++++-- imgui.cpp | 5 ++++- imgui_internal.h | 4 ++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 123000bb9..00acc1dd9 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -39,8 +39,10 @@ Breaking changes: Other changes: - - Text: Fixed layouting of wrapped-text block when the last source line is above the - clipping region. Regression added in 1.89. (#5720, #5919) +- Text: fixed layouting of wrapped-text block when the last source line is above the + clipping region. Regression added in 1.89. (#5720, #5919) +- Misc: fixed parameters to IMGUI_DEBUG_LOG() not being dead-stripped when building + with IMGUI_DISABLE_DEBUG_TOOLS is used. (#5901) [@Teselka] ----------------------------------------------------------------------- diff --git a/imgui.cpp b/imgui.cpp index 19b6f770d..4eded91de 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -2871,11 +2871,14 @@ bool ImGuiListClipper::Step() if (need_items_height && ItemsHeight > 0.0f) IMGUI_DEBUG_LOG_CLIPPER("Clipper: Step(): computed ItemsHeight: %.2f.\n", ItemsHeight); if (ret) + { IMGUI_DEBUG_LOG_CLIPPER("Clipper: Step(): display %d to %d.\n", DisplayStart, DisplayEnd); + } else + { IMGUI_DEBUG_LOG_CLIPPER("Clipper: Step(): End.\n"); - if (!ret) End(); + } return ret; } diff --git a/imgui_internal.h b/imgui_internal.h index a42fa836f..7fd26e54d 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -211,7 +211,11 @@ namespace ImStb #endif // Debug Logging for ShowDebugLogWindow(). This is designed for relatively rare events so please don't spam. +#ifndef IMGUI_DISABLE_DEBUG_TOOLS #define IMGUI_DEBUG_LOG(...) ImGui::DebugLog(__VA_ARGS__) +#else +#define IMGUI_DEBUG_LOG(...) ((void)0) +#endif #define IMGUI_DEBUG_LOG_ACTIVEID(...) do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventActiveId) IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0) #define IMGUI_DEBUG_LOG_FOCUS(...) do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventFocus) IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0) #define IMGUI_DEBUG_LOG_POPUP(...) do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventPopup) IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)