All: Fix crash on close Kicad, when a quasi modal dialog is open, and Kicad is closed from the Kicad project manager.

This commit is contained in:
jean-pierre charras 2014-08-29 19:49:49 +02:00
parent 3d83434275
commit 020a0ae477
3 changed files with 36 additions and 2 deletions

View File

@ -44,6 +44,7 @@
#include <wxstruct.h>
#include <macros.h>
#include <menus_helpers.h>
#include <dialog_shim.h>
#include <boost/version.hpp>
#include <typeinfo>
@ -107,6 +108,39 @@ EDA_BASE_FRAME::EDA_BASE_FRAME( wxWindow* aParent, FRAME_T aFrameType,
void EDA_BASE_FRAME::windowClosing( wxCloseEvent& event )
{
DIALOG_SHIM* dlg = NULL;
wxWindowList list = GetChildren();
// Quasi modal dialogs create issues (crashes) when closing Kicad.
// I am guessing they are delete too late, when deleting main frames.
// AFAIK, only these DIALOG_SHIM dialogs create such issues.
// The policy is do not allow closing Kicad if a Quasi modal dialog is open.
// (Anyway, closing without prompting the user is certainly bad,
// because an edit is in preogress)
// Therefore, iterate through the child list to find at least
// a DIALOG_SHIM opened in quasi modal mode
for( wxWindowList::iterator iter = list.begin(); iter != list.end(); ++iter )
{
if( (dlg = dynamic_cast<DIALOG_SHIM*> (*iter) ) != NULL )
{
if( dlg->IsQuasiModal() )
break;
else
dlg = NULL;
}
}
if( dlg )
{
// Happens when a quasi modal dialog is currently open.
// For example: if the Kicad manager try to close Kicad.
wxMessageBox( _(
"The program cannot be closed\n"
"A quasi-modal dialog window is currently open, please close it first." ) );
event.Veto();
return;
}
wxConfigBase* cfg = config();
if( cfg )

View File

@ -617,7 +617,7 @@ void SCH_EDIT_FRAME::OnCloseWindow( wxCloseEvent& aEvent )
}
}
// Close the find dialog and perserve it's setting if it is displayed.
// Close the find dialog and preserve it's setting if it is displayed.
if( m_dlgFindReplace )
{
m_findDialogPosition = m_dlgFindReplace->GetPosition();

View File

@ -107,7 +107,7 @@ class EDA_BASE_FRAME : public wxFrame
* SaveSettings(). SaveSettings() is called for all derived wxFrames in this
* base class overload. (Calling it from a destructor is deprecated since the
* wxFrame's position is not available in the destructor on linux.) In other words,
* you should not need to call call SaveSettings() anywhere, except in this
* you should not need to call SaveSettings() anywhere, except in this
* one function found only in this class.
*/
void windowClosing( wxCloseEvent& event );