From b66fcdb3f71484315e77e021ca180330e5008a2e Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Mon, 19 Oct 2020 22:03:06 -0700 Subject: [PATCH] [sim] Fix Field2D GUI crash when collapsed (#2786) Collapsed windows result in a vertical content size of 0. --- simulation/halsim_gui/src/main/native/cpp/Field2D.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/simulation/halsim_gui/src/main/native/cpp/Field2D.cpp b/simulation/halsim_gui/src/main/native/cpp/Field2D.cpp index ee577d5f2a..b1e4f0c35f 100644 --- a/simulation/halsim_gui/src/main/native/cpp/Field2D.cpp +++ b/simulation/halsim_gui/src/main/native/cpp/Field2D.cpp @@ -565,7 +565,10 @@ static void DisplayField2D() { // for dragging to work, there needs to be a button (otherwise the window is // dragged) - ImGui::InvisibleButton("field", ImGui::GetContentRegionAvail()); + ImVec2 contentSize = + ImGui::GetWindowContentRegionMax() - ImGui::GetWindowContentRegionMin(); + if (contentSize.x <= 0 || contentSize.y <= 0) return; + ImGui::InvisibleButton("field", contentSize); // allow dragging the robot around ImVec2 cursor = ImGui::GetIO().MousePos - windowPos;