From fda677eecca86499d9ad67a09f2f32b0f10c659a Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Fri, 27 Jan 2017 23:30:13 -0500 Subject: [PATCH] Prevent schematic I/O plugin from setting the library cache to null. Don't call init() when performing library functions as it was always setting the m_cache variable to null which cause the library to be reloaded every time a library command was performed as well as a memory leak. Delete cache object when the plugin is destroyed. --- eeschema/sch_legacy_plugin.cpp | 10 ++++++++-- eeschema/sch_legacy_plugin.h | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/eeschema/sch_legacy_plugin.cpp b/eeschema/sch_legacy_plugin.cpp index c2c346f3aa..b11520f104 100644 --- a/eeschema/sch_legacy_plugin.cpp +++ b/eeschema/sch_legacy_plugin.cpp @@ -470,6 +470,12 @@ SCH_LEGACY_PLUGIN::SCH_LEGACY_PLUGIN() } +SCH_LEGACY_PLUGIN::~SCH_LEGACY_PLUGIN() +{ + delete m_cache; +} + + void SCH_LEGACY_PLUGIN::init( KIWAY* aKiway, const PROPERTIES* aProperties ) { m_version = 0; @@ -3381,7 +3387,7 @@ size_t SCH_LEGACY_PLUGIN::GetSymbolLibCount( const wxString& aLibraryPath, { LOCALE_IO toggle; - init( NULL, aProperties ); + m_props = aProperties; cacheLib( aLibraryPath ); @@ -3395,7 +3401,7 @@ void SCH_LEGACY_PLUGIN::EnumerateSymbolLib( wxArrayString& aAliasNameList, { LOCALE_IO toggle; // toggles on, then off, the C locale. - init( NULL, aProperties ); + m_props = aProperties; cacheLib( aLibraryPath ); diff --git a/eeschema/sch_legacy_plugin.h b/eeschema/sch_legacy_plugin.h index 27db5f133d..fc5d3a19a0 100644 --- a/eeschema/sch_legacy_plugin.h +++ b/eeschema/sch_legacy_plugin.h @@ -63,7 +63,7 @@ class SCH_LEGACY_PLUGIN : public SCH_PLUGIN public: SCH_LEGACY_PLUGIN(); - virtual ~SCH_LEGACY_PLUGIN() {} + virtual ~SCH_LEGACY_PLUGIN(); const wxString GetName() const override {