From 3f3b5a621da7ce39f82c4706aae58c83f3eb74a2 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Mon, 8 Apr 2024 12:21:02 +0200 Subject: [PATCH] #11334 Fix cvf::Viewport assert triggered for small contour map/2d intersection Size of the overlay is could become negative, and would overflow for small views. Fixes #11334. --- ApplicationLibCode/UserInterface/RiuViewer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ApplicationLibCode/UserInterface/RiuViewer.cpp b/ApplicationLibCode/UserInterface/RiuViewer.cpp index c929010946..dbbe9b31e2 100644 --- a/ApplicationLibCode/UserInterface/RiuViewer.cpp +++ b/ApplicationLibCode/UserInterface/RiuViewer.cpp @@ -790,7 +790,7 @@ void RiuViewer::updateLegendLayout() { int legendWidth = prefSize.x(); legend->setLayoutFixedPosition( cvf::Vec2i( xPos, yPos ) ); - legend->setRenderSize( cvf::Vec2ui( legendWidth, viewPortHeight - 2 * border - 2 * edgeAxisBorderHeight ) ); + legend->setRenderSize( cvf::Vec2ui( legendWidth, std::max( 0, viewPortHeight - 2 * border - 2 * edgeAxisBorderHeight ) ) ); xPos += legendWidth + border; } else @@ -858,7 +858,7 @@ void RiuViewer::updateLegendLayout() { int legendWidth = prefSize.x(); legend->setLayoutFixedPosition( cvf::Vec2i( xPos - legendWidth, yPos ) ); - legend->setRenderSize( cvf::Vec2ui( legendWidth, viewPortHeight - yPosStart - border - edgeAxisBorderHeight ) ); + legend->setRenderSize( cvf::Vec2ui( legendWidth, std::max( 0, viewPortHeight - yPosStart - border - edgeAxisBorderHeight ) ) ); xPos -= legendWidth + border; } else