Fix memory leaks in color theme editor

Fixes https://gitlab.com/kicad/code/kicad/-/issues/4794
This commit is contained in:
Jon Evans 2020-07-03 22:34:16 -04:00
parent 3c0de2b542
commit d143e14694
3 changed files with 32 additions and 0 deletions

View File

@ -211,6 +211,28 @@ COLOR_SETTINGS::COLOR_SETTINGS( std::string aFilename ) :
}
COLOR_SETTINGS::COLOR_SETTINGS( const COLOR_SETTINGS& aOther ) :
JSON_SETTINGS( aOther.m_filename, SETTINGS_LOC::COLORS, colorsSchemaVersion )
{
m_displayName = aOther.m_displayName;
m_overrideSchItemColors = aOther.m_overrideSchItemColors;
m_colors = aOther.m_colors;
m_defaultColors = aOther.m_defaultColors;
}
COLOR_SETTINGS& COLOR_SETTINGS::operator=( const COLOR_SETTINGS &aOther )
{
m_filename = aOther.m_filename;
m_displayName = aOther.m_displayName;
m_overrideSchItemColors = aOther.m_overrideSchItemColors;
m_colors = aOther.m_colors;
m_defaultColors = aOther.m_defaultColors;
return *this;
}
bool COLOR_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg )
{
return false;

View File

@ -105,6 +105,8 @@ PANEL_EESCHEMA_COLOR_SETTINGS::~PANEL_EESCHEMA_COLOR_SETTINGS()
{
delete m_page;
delete m_titleBlock;
delete m_ws;
delete m_currentSettings;
for( EDA_ITEM* item : m_previewItems )
delete item;

View File

@ -64,6 +64,14 @@ public:
virtual ~COLOR_SETTINGS() {}
/**
* Copy ctor provided for temporary manipulation of themes in the theme editor.
* This will not copy the JSON_SETTINGS underlying data.
*/
COLOR_SETTINGS( const COLOR_SETTINGS& aOther );
COLOR_SETTINGS& operator=( const COLOR_SETTINGS &aOther );
bool MigrateFromLegacy( wxConfigBase* aCfg ) override;
bool Migrate() override;