LIB_LOGGER: fix a crash when closing Kicad, if Libedit was run.

wxLog::SetActiveTarget() was initialised to libedit frame,
but the active target was not released after closing and deleting libedit, thus creating a crash on Kicad exit.
This commit is contained in:
jean-pierre charras 2019-07-14 18:46:58 +02:00
parent 1a7cef2950
commit 9259f3a7c9
1 changed files with 13 additions and 1 deletions

View File

@ -48,10 +48,22 @@ class SYMBOL_LIB_TABLE_ROW;
class LIB_LOGGER : public wxLogGui
{
public:
LIB_LOGGER() : m_previousLogger( nullptr ), m_activated( false )
{
}
~LIB_LOGGER()
{
if( m_activated )
wxLog::SetActiveTarget( m_previousLogger );
}
void Activate()
{
m_activated = true;
m_previousLogger = wxLog::GetActiveTarget();
wxLog::SetActiveTarget( this );
Clear();
}
void Flush() override
@ -62,12 +74,12 @@ public:
"to adjust paths and add or remove libraries." ) );
wxLogGui::Flush();
wxLog::SetActiveTarget( m_previousLogger );
}
}
private:
wxLog* m_previousLogger;
bool m_activated;
};