better fix than commit 6c083ebf4c, because the issue was existing in other dialogs

Fix incorrect frame deletion, only noticeable when eeschema is run in stand alone mode.
After selecting a footprint using the footprint viewer, the application cannot be closed.
Reason:
the footprint viewer ctor creates an instance (not shown) of a FRAME_PCB.
Unfortunately, this pcb frame was not deleted by Eeschema, in stand alone mode,
preventing the application to be closed because a frame was still active after closing the schematic editor frame.
Now the footprint viewer ctor delete this instance after use, if it was not previously existing.
This commit is contained in:
jean-pierre charras 2017-04-13 18:28:16 +02:00
parent 6c083ebf4c
commit 80371134d7
2 changed files with 7 additions and 15 deletions

View File

@ -202,11 +202,6 @@ wxString FOOTPRINT_SELECT_WIDGET::ShowPicker()
// event loop goes all silly.
wxASSERT( !dsparent || dsparent->IsQuasiModal() );
// Now open the footprint viewer.
// However, this viewer creates a not shown PCB_EDIT_FRAME_NAME, if
// it does not exist previously.
// We must delete it when exiting, if it is not existing
auto pcbframe = m_kiway->Player( FRAME_PCB, false ); // return nullptr if not yet existing.
auto frame = m_kiway->Player( FRAME_PCB_MODULE_VIEWER_MODAL, true );
if( !frame->ShowModal( &fpname, parent ) )
@ -216,16 +211,6 @@ wxString FOOTPRINT_SELECT_WIDGET::ShowPicker()
frame->Destroy();
// If the PCB_EDIT_FRAME was not previoulsy existing, delete the newly created one:
if( !pcbframe )
{
pcbframe = m_kiway->Player( FRAME_PCB, false );
if( pcbframe )
pcbframe->Destroy();
}
return fpname;
}

View File

@ -186,6 +186,10 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent
ReCreateLibraryList();
UpdateTitle();
// See for an existing board editor frame opened
// (we need it just to know some settings )
bool isBordEditorRunning = Kiway().Player( FRAME_PCB, false ) != nullptr;
PCB_BASE_FRAME* parentFrame = static_cast<PCB_BASE_FRAME*>( Kiway().Player( FRAME_PCB, true ) );
// Create GAL canvas
@ -287,6 +291,9 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent
UseGalCanvas( parentFrame->IsGalCanvasActive() );
if( !isBordEditorRunning && IsModal() )
parentFrame->Destroy();
if( !IsModal() ) // For modal mode, calling ShowModal() will show this frame
{
Raise(); // On some window managers, this is needed