From 5e3a1de4e6b328a18829b29b3ed265e41fd202bb Mon Sep 17 00:00:00 2001 From: omar Date: Wed, 27 Feb 2019 14:25:37 +0100 Subject: [PATCH] Plot: Fixed divide-by-zero in PlotLines() when passing a count of 1. (#2387) [@Lectem] --- docs/CHANGELOG.txt | 1 + imgui_widgets.cpp | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 2511e4c0..68850768 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -47,6 +47,7 @@ Other Changes: - TabBar: Fixed a crash when using BeginTabBar() recursively (didn't affect docking). (#2371) - TabBar: Added extra mis-usage error recovery. Past the assert, common mis-usage don't lead to hard crashes any more, facilitating integration with scripting languages. (#1651) +- Plot: Fixed divide-by-zero in PlotLines() when passing a count of 1. (#2387) [@Lectem] - Log/Capture: Fixed extraneous leading carriage return. - Log/Capture: Fixed an issue when empty string on a new line would not emit a carriage return. - Log/Capture: Fixed LogXXX functions 'auto_open_depth' parameter being treated as an absolute diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index 946a5dbe..4ed42ec3 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -5343,7 +5343,8 @@ void ImGui::PlotEx(ImGuiPlotType plot_type, const char* label, float (*values_ge RenderFrame(frame_bb.Min, frame_bb.Max, GetColorU32(ImGuiCol_FrameBg), true, style.FrameRounding); - if (values_count > 0) + const int values_count_min = (plot_type == ImGuiPlotType_Lines) ? 2 : 1; + if (values_count >= 1)//values_count_min) { int res_w = ImMin((int)frame_size.x, values_count) + ((plot_type == ImGuiPlotType_Lines) ? -1 : 0); int item_count = values_count + ((plot_type == ImGuiPlotType_Lines) ? -1 : 0);