From 489cc1cb361f024dcffd6db0f3877522cc2b6c6f Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Wed, 12 Feb 2020 17:03:58 +0100 Subject: [PATCH] Fix drawing empty wxPropertyGrid If wxPG doesn't contain any visible items it's entire area should be erased so we need to return -1 as a last drawn line index to ensure that painted area will be clared from 0 y-coordinate. Closes #18666. --- src/propgrid/propgrid.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/propgrid/propgrid.cpp b/src/propgrid/propgrid.cpp index 7898c75b7e..ef4e24f478 100644 --- a/src/propgrid/propgrid.cpp +++ b/src/propgrid/propgrid.cpp @@ -2040,10 +2040,11 @@ int wxPropertyGrid::DoDrawItems( wxDC& dc, const wxRect* itemsRect ) const #endif { - const wxPGProperty* firstItem; - firstItem = DoGetItemAtY(itemsRect->y); + const wxPGProperty* firstItem = DoGetItemAtY(itemsRect->y); + if ( !firstItem ) // Signal a need to clear entire paint area if grid is empty + return -1; - if ( IsFrozen() || m_height < 1 || firstItem == NULL ) + if ( IsFrozen() || m_height < 1 ) return itemsRect->GetBottom(); wxCHECK_MSG( !m_pState->m_itemsAdded, itemsRect->GetBottom(),