Skip to content

Commit

Permalink
Internal: Disable debug logs macro if IMGUI_DISABLE_DEBUG_TOOLS is de…
Browse files Browse the repository at this point in the history
…fined. (#5901)

+ needed to rework clipper code to avoid "The 'then' statement is equivalent to the 'else' statement." PVS Studio warning.
  • Loading branch information
Teselka authored and ocornut committed Nov 28, 2022
1 parent bd96f6e commit 969af7c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
6 changes: 4 additions & 2 deletions docs/CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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]


-----------------------------------------------------------------------
Expand Down
5 changes: 4 additions & 1 deletion imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
4 changes: 4 additions & 0 deletions imgui_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 969af7c

Please sign in to comment.