From 4d593aa21e77d5fa764384fec76879f2927c1952 Mon Sep 17 00:00:00 2001
From: jean-pierre charras <jp.charras@wanadoo.fr>
Date: Fri, 27 Oct 2023 08:54:38 +0200
Subject: [PATCH] PG_CELL_RENDERER, PGPROPERTY_COLOR4D: clear DC before drawing
 the color swatch. Otherwise the previous background can be displayed on the
 not redrawn area. Fixes #15955
 https://gitlab.com/kicad/code/kicad/-/issues/15955

---
 common/properties/pg_cell_renderer.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/properties/pg_cell_renderer.cpp b/common/properties/pg_cell_renderer.cpp
index ac97e55a1c..56aca57f32 100644
--- a/common/properties/pg_cell_renderer.cpp
+++ b/common/properties/pg_cell_renderer.cpp
@@ -46,6 +46,7 @@ bool PG_CELL_RENDERER::Render( wxDC &aDC, const wxRect &aRect, const wxPropertyG
             int offset = ( aRect.GetHeight() - swatchSize.GetHeight() ) / 2;
             wxRect swatch( aRect.GetPosition() + wxPoint( offset, offset ), swatchSize );
 
+            aDC.Clear();    // Ensure the "old" background is erased.
             COLOR_SWATCH::RenderToDC( &aDC, color, colorProp->GetBackgroundColor(), swatch,
                                       aGrid->ConvertDialogToPixels( CHECKERBOARD_SIZE_DU ),
                                       aGrid->GetBackgroundColour() );