Bubble cancel up from app to kicad manager when closing.

Fixes https://gitlab.com/kicad/code/kicad/issues/5402
This commit is contained in:
Jeff Young 2020-08-31 00:47:16 +01:00
parent 8945f8865b
commit 34d069ffd8
3 changed files with 29 additions and 11 deletions

View File

@ -144,7 +144,9 @@ void EDA_BASE_FRAME::windowClosing( wxCloseEvent& event )
quasiModal->Raise();
wxBell();
event.Veto();
if( event.CanVeto() )
event.Veto();
return;
}
@ -170,7 +172,8 @@ void EDA_BASE_FRAME::windowClosing( wxCloseEvent& event )
}
else
{
event.Veto();
if( event.CanVeto() )
event.Veto();
}
}

View File

@ -324,6 +324,27 @@ void KICAD_MANAGER_FRAME::OnSize( wxSizeEvent& event )
}
bool KICAD_MANAGER_FRAME::canCloseWindow( wxCloseEvent& aEvent )
{
KICAD_SETTINGS* settings = kicadSettings();
settings->m_OpenProjects = GetSettingsManager()->GetOpenProjects();
// CloseProject will recursively ask all the open editors if they need to save changes.
// If any of them cancel then we need to cancel closing the KICAD_MANAGER_FRAME.
if( CloseProject( true ) )
{
return true;
}
else
{
if( aEvent.CanVeto() )
aEvent.Veto();
return false;
}
}
void KICAD_MANAGER_FRAME::doCloseWindow()
{
#ifdef _WINDOWS_
@ -342,16 +363,9 @@ void KICAD_MANAGER_FRAME::doCloseWindow()
}
#endif
// Save the list of open projects before closing the project
KICAD_SETTINGS* settings = kicadSettings();
settings->m_OpenProjects = GetSettingsManager()->GetOpenProjects();
m_leftWin->Show( false );
if( CloseProject( true ) )
{
m_leftWin->Show( false );
Destroy();
}
Destroy();
#ifdef _WINDOWS_
lock_close_event = 0; // Reenable event management

View File

@ -85,6 +85,7 @@ public:
void OnIdle( wxIdleEvent& event );
bool canCloseWindow( wxCloseEvent& aCloseEvent ) override;
void doCloseWindow() override;
void OnSize( wxSizeEvent& event );