EDA_BASE_FRAME::windowClosing( wxCloseEvent& event ): fix incorrect behavior.
windowClosing() calls Destroy() when the wxCloseEvent has no veto. This is fine for usual EDA_BASE_FRAME frames, but not for frames shown in modal mode. In modal mode, windowClosing() should not call Destroy(), because the calling frame expects the instance not deleted after closing. (the caller has to call Destroy() only once the frame can be actually deleted)
This commit is contained in:
parent
e6f4e156b6
commit
9fdadcbcf5
|
@ -153,7 +153,7 @@ void EDA_BASE_FRAME::windowClosing( wxCloseEvent& event )
|
|||
}
|
||||
|
||||
|
||||
if( event.GetId() == wxEVT_QUERY_END_SESSION
|
||||
if( event.GetId() == wxEVT_QUERY_END_SESSION
|
||||
|| event.GetId() == wxEVT_END_SESSION )
|
||||
{
|
||||
// End session means the OS is going to terminate us
|
||||
|
@ -170,7 +170,10 @@ void EDA_BASE_FRAME::windowClosing( wxCloseEvent& event )
|
|||
|
||||
doCloseWindow();
|
||||
|
||||
Destroy();
|
||||
// Destroy (safe delete frame) this frame only in non modal mode.
|
||||
// In modal mode, the caller will call Destroy().
|
||||
if( !IsModal() )
|
||||
Destroy();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -125,6 +125,14 @@ class EDA_BASE_FRAME : public wxFrame, public TOOLS_HOLDER, public KIWAY_HOLDER
|
|||
|
||||
wxWindow* findQuasiModalDialog();
|
||||
|
||||
/**
|
||||
* Return true if the frame is shown in our modal mode
|
||||
* and false if the frame is shown as an usual frame
|
||||
* In modal mode, the caller that created the frame is responsible to Destroy()
|
||||
* this frame after closing
|
||||
*/
|
||||
virtual bool IsModal() const { return false; }
|
||||
|
||||
protected:
|
||||
FRAME_T m_Ident; // Id Type (pcb, schematic, library..)
|
||||
wxPoint m_FramePos;
|
||||
|
|
|
@ -173,7 +173,7 @@ public:
|
|||
*/
|
||||
bool Destroy() override;
|
||||
|
||||
bool IsModal() const { return m_modal; }
|
||||
bool IsModal() const override { return m_modal; }
|
||||
void SetModal( bool aIsModal ) { m_modal = aIsModal; }
|
||||
|
||||
/**
|
||||
|
|
|
@ -190,48 +190,48 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||
}
|
||||
}
|
||||
|
||||
auto wizard = (FOOTPRINT_WIZARD_FRAME*) Kiway().Player( FRAME_FOOTPRINT_WIZARD, true,
|
||||
this );
|
||||
FOOTPRINT_WIZARD_FRAME* wizard =
|
||||
(FOOTPRINT_WIZARD_FRAME*) Kiway().Player( FRAME_FOOTPRINT_WIZARD, true, this );
|
||||
|
||||
if( wizard->ShowModal( NULL, this ) )
|
||||
{
|
||||
// Creates the new footprint from python script wizard
|
||||
MODULE* module = wizard->GetBuiltFootprint();
|
||||
|
||||
if( module == NULL ) // i.e. if create module command aborted
|
||||
break;
|
||||
|
||||
Clear_Pcb( false );
|
||||
|
||||
GetCanvas()->GetViewControls()->SetCrossHairCursorPosition( VECTOR2D( 0, 0 ), false );
|
||||
// Add the new object to board
|
||||
AddModuleToBoard( module );
|
||||
|
||||
// Initialize data relative to nets and netclasses (for a new
|
||||
// module the defaults are used)
|
||||
// This is mandatory to handle and draw pads
|
||||
GetBoard()->BuildListOfNets();
|
||||
module->SetPosition( wxPoint( 0, 0 ) );
|
||||
module->ClearFlags();
|
||||
|
||||
Zoom_Automatique( false );
|
||||
GetScreen()->SetModify();
|
||||
|
||||
// If selected from the library tree then go ahead and save it there
|
||||
if( !selected.GetLibNickname().empty() )
|
||||
if( module ) // i.e. if create module command is OK
|
||||
{
|
||||
LIB_ID fpid = module->GetFPID();
|
||||
fpid.SetLibNickname( selected.GetLibNickname() );
|
||||
module->SetFPID( fpid );
|
||||
SaveFootprint( module );
|
||||
GetScreen()->ClrModify();
|
||||
Clear_Pcb( false );
|
||||
|
||||
GetCanvas()->GetViewControls()->SetCrossHairCursorPosition( VECTOR2D( 0, 0 ), false );
|
||||
// Add the new object to board
|
||||
AddModuleToBoard( module );
|
||||
|
||||
// Initialize data relative to nets and netclasses (for a new
|
||||
// module the defaults are used)
|
||||
// This is mandatory to handle and draw pads
|
||||
GetBoard()->BuildListOfNets();
|
||||
module->SetPosition( wxPoint( 0, 0 ) );
|
||||
module->ClearFlags();
|
||||
|
||||
Zoom_Automatique( false );
|
||||
GetScreen()->SetModify();
|
||||
|
||||
// If selected from the library tree then go ahead and save it there
|
||||
if( !selected.GetLibNickname().empty() )
|
||||
{
|
||||
LIB_ID fpid = module->GetFPID();
|
||||
fpid.SetLibNickname( selected.GetLibNickname() );
|
||||
module->SetFPID( fpid );
|
||||
SaveFootprint( module );
|
||||
GetScreen()->ClrModify();
|
||||
}
|
||||
|
||||
updateView();
|
||||
GetCanvas()->Refresh();
|
||||
Update3DView( true );
|
||||
|
||||
SyncLibraryTree( false );
|
||||
}
|
||||
|
||||
updateView();
|
||||
GetCanvas()->Refresh();
|
||||
Update3DView( true );
|
||||
|
||||
SyncLibraryTree( false );
|
||||
}
|
||||
|
||||
wizard->Destroy();
|
||||
|
|
|
@ -255,10 +255,7 @@ void FOOTPRINT_WIZARD_FRAME::doCloseWindow()
|
|||
if( !IsDismissed() )
|
||||
DismissModal( false );
|
||||
}
|
||||
else
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
// else do nothing
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* Copyright (C) 2012 Miguel Angel Ajo Pelayo, miguelangel@nbee.es
|
||||
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2004-2018 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2004-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
|
Loading…
Reference in New Issue