7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-20 00:21:31 +00:00

Fix memory leak in DRC_TEST_PROVIDER_CLEARANCE_BASE

We really shouldn't be getting the colors here (they need to be when
drawn) but if we do, we shouldn't allocate a whole new palette for each
object.
This commit is contained in:
Seth Hillbrand 2025-01-14 15:25:53 -08:00
parent baa0beec4d
commit a77c9463e4

View File

@ -24,16 +24,23 @@
*/
#include <drc/drc_test_provider_clearance_base.h>
#include <pgm_base.h>
#include <settings/settings_manager.h>
DRC_CUSTOM_MARKER_HANDLER
DRC_TEST_PROVIDER_CLEARANCE_BASE::GetGraphicsHandler( const std::vector<PCB_SHAPE>& aShapes,
const VECTOR2I& aStart, const VECTOR2I& aEnd,
int aLength )
{
COLOR_SETTINGS* colorSettings = new COLOR_SETTINGS( COLOR_SETTINGS::COLOR_BUILTIN_DEFAULT );
COLOR_SETTINGS* defaultSettings = colorSettings->CreateBuiltinColorSettings()[0];
COLOR4D errorColor = defaultSettings->GetColor( LAYER_DRC_ERROR );
delete colorSettings;
// todo: Move this to a board-level object instead of getting it from the DRC Engine
PGM_BASE* pgm = PgmOrNull();
COLOR4D errorColor = COLOR4D( RED );
if( pgm )
{
COLOR_SETTINGS* colorSettings = pgm->GetSettingsManager().GetColorSettings();
errorColor = colorSettings->GetColor( LAYER_DRC_ERROR );
}
std::vector<PCB_SHAPE> shortestPathShapes1, shortestPathShapes2;