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.
This commit is contained in:
Teselka 2022-11-20 23:45:55 +02:00 committed by ocornut
parent bd96f6eac4
commit 969af7c773
3 changed files with 12 additions and 3 deletions

View File

@ -39,8 +39,10 @@ Breaking changes:
Other changes: Other changes:
- Text: Fixed layouting of wrapped-text block when the last source line is above the - Text: fixed layouting of wrapped-text block when the last source line is above the
clipping region. Regression added in 1.89. (#5720, #5919) 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]
----------------------------------------------------------------------- -----------------------------------------------------------------------

View File

@ -2871,11 +2871,14 @@ bool ImGuiListClipper::Step()
if (need_items_height && ItemsHeight > 0.0f) if (need_items_height && ItemsHeight > 0.0f)
IMGUI_DEBUG_LOG_CLIPPER("Clipper: Step(): computed ItemsHeight: %.2f.\n", ItemsHeight); IMGUI_DEBUG_LOG_CLIPPER("Clipper: Step(): computed ItemsHeight: %.2f.\n", ItemsHeight);
if (ret) if (ret)
{
IMGUI_DEBUG_LOG_CLIPPER("Clipper: Step(): display %d to %d.\n", DisplayStart, DisplayEnd); IMGUI_DEBUG_LOG_CLIPPER("Clipper: Step(): display %d to %d.\n", DisplayStart, DisplayEnd);
}
else else
{
IMGUI_DEBUG_LOG_CLIPPER("Clipper: Step(): End.\n"); IMGUI_DEBUG_LOG_CLIPPER("Clipper: Step(): End.\n");
if (!ret)
End(); End();
}
return ret; return ret;
} }

View File

@ -211,7 +211,11 @@ namespace ImStb
#endif #endif
// Debug Logging for ShowDebugLogWindow(). This is designed for relatively rare events so please don't spam. // 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__) #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_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_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) #define IMGUI_DEBUG_LOG_POPUP(...) do { if (g.DebugLogFlags & ImGuiDebugLogFlags_EventPopup) IMGUI_DEBUG_LOG(__VA_ARGS__); } while (0)