From 80371134d726f25da23a28334a5fcba9029f0bfd Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Thu, 13 Apr 2017 18:28:16 +0200 Subject: [PATCH] better fix than commit 6c083ebf4c6d1b9ab48973d237986a307e64895a, 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. --- common/widgets/footprint_select_widget.cpp | 15 --------------- pcbnew/modview_frame.cpp | 7 +++++++ 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/common/widgets/footprint_select_widget.cpp b/common/widgets/footprint_select_widget.cpp index c7f2ba7652..430c0849ce 100644 --- a/common/widgets/footprint_select_widget.cpp +++ b/common/widgets/footprint_select_widget.cpp @@ -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; } diff --git a/pcbnew/modview_frame.cpp b/pcbnew/modview_frame.cpp index bcb909eb45..2d22507e79 100644 --- a/pcbnew/modview_frame.cpp +++ b/pcbnew/modview_frame.cpp @@ -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( 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