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(); quasiModal->Raise();
wxBell(); wxBell();
if( event.CanVeto() )
event.Veto(); event.Veto();
return; return;
} }
@ -170,6 +172,7 @@ void EDA_BASE_FRAME::windowClosing( wxCloseEvent& event )
} }
else else
{ {
if( event.CanVeto() )
event.Veto(); 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() void KICAD_MANAGER_FRAME::doCloseWindow()
{ {
#ifdef _WINDOWS_ #ifdef _WINDOWS_
@ -342,16 +363,9 @@ void KICAD_MANAGER_FRAME::doCloseWindow()
} }
#endif #endif
// Save the list of open projects before closing the project
KICAD_SETTINGS* settings = kicadSettings();
settings->m_OpenProjects = GetSettingsManager()->GetOpenProjects();
if( CloseProject( true ) )
{
m_leftWin->Show( false ); m_leftWin->Show( false );
Destroy(); Destroy();
}
#ifdef _WINDOWS_ #ifdef _WINDOWS_
lock_close_event = 0; // Reenable event management lock_close_event = 0; // Reenable event management

View File

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