From 284917b999886426ee85990e16d5c8ecaa0c21ed Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Sun, 21 Aug 2022 22:31:06 -0400 Subject: [PATCH] Fix assertion when rendering layer editor --- common/pg_properties.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/common/pg_properties.cpp b/common/pg_properties.cpp index b40e650f54..c851a1d25d 100644 --- a/common/pg_properties.cpp +++ b/common/pg_properties.cpp @@ -303,6 +303,10 @@ void PGPROPERTY_COLORENUM::OnCustomPaint( wxDC& aDC, const wxRect& aRect, if( index < 0 ) index = GetIndex(); + // GetIndex can return -1 when the control hasn't been set up yet + if( index < 0 || index >= static_cast( GetChoices().GetCount() ) ) + return; + wxString layer = GetChoices().GetLabel( index ); wxColour color = GetColor( layer ); @@ -312,4 +316,6 @@ void PGPROPERTY_COLORENUM::OnCustomPaint( wxDC& aDC, const wxRect& aRect, aDC.SetPen( *wxTRANSPARENT_PEN ); aDC.SetBrush( wxBrush( color ) ); aDC.DrawRectangle( aRect ); + + aPaintData.m_drawnWidth = aRect.width; }