Eeschema: fix crash when undo called during item edit.

Add EDA_DRAW_FRAME::isBusy() method to test if the current item is being
edited or a block operation is in progress.

Ignore undo and redo commands when editor is busy.

Fixes lp:1718656

https://bugs.launchpad.net/kicad/+bug/1718656
This commit is contained in:
Wayne Stambaugh 2017-09-21 12:37:12 -04:00
parent cb764d73c5
commit 427e5ec461
3 changed files with 24 additions and 8 deletions

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2004-2017 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2004-2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2008-2015 Wayne Stambaugh <stambaughw@verizon.net> * Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 2004-2017 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2004-2017 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
@ -1370,3 +1370,14 @@ void EDA_DRAW_FRAME::GeneralControlKeyMovement( int aHotKey, wxPoint *aPos,
} }
} }
bool EDA_DRAW_FRAME::isBusy() const
{
const BASE_SCREEN* screen = const_cast< BASE_SCREEN* >( GetScreen() );
if( !screen )
return false;
return ( screen->GetCurItem() && screen->GetCurItem()->GetFlags() )
|| ( screen->m_BlockLocate.GetState() != STATE_NO_BLOCK );
}

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com * Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 2004-2017 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -338,7 +338,7 @@ void SCH_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed
void SCH_EDIT_FRAME::GetSchematicFromUndoList( wxCommandEvent& event ) void SCH_EDIT_FRAME::GetSchematicFromUndoList( wxCommandEvent& event )
{ {
if( GetScreen()->GetUndoCommandCount() <= 0 ) if( GetScreen()->GetUndoCommandCount() <= 0 || isBusy() )
return; return;
/* Get the old list */ /* Get the old list */
@ -361,7 +361,7 @@ void SCH_EDIT_FRAME::GetSchematicFromUndoList( wxCommandEvent& event )
void SCH_EDIT_FRAME::GetSchematicFromRedoList( wxCommandEvent& event ) void SCH_EDIT_FRAME::GetSchematicFromRedoList( wxCommandEvent& event )
{ {
if( GetScreen()->GetRedoCommandCount() == 0 ) if( GetScreen()->GetRedoCommandCount() == 0 || isBusy() )
return; return;
/* Get the old list */ /* Get the old list */

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com * Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2011-2017 Wayne Stambaugh <stambaughw@gmail.com> * Copyright (C) 2011 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
@ -154,11 +154,16 @@ protected:
* cursor keys (i.e. cursor movement by keyboard) */ * cursor keys (i.e. cursor movement by keyboard) */
void GeneralControlKeyMovement( int aHotKey, wxPoint *aPos, bool aSnapToGrid ); void GeneralControlKeyMovement( int aHotKey, wxPoint *aPos, bool aSnapToGrid );
/* Function RefreshCrosshair /**
* Move and refresh the crosshair after movement; also call the * Move and refresh the crosshair after movement and call the mouse capture function.
* mouse capture function, if active.
*/ */
void RefreshCrossHair( const wxPoint &aOldPos, const wxPoint &aEvtPos, wxDC* aDC ); void RefreshCrossHair( const wxPoint &aOldPos, const wxPoint &aEvtPos, wxDC* aDC );
/**
* @return true if an item edit or a block operation is in progress.
*/
bool isBusy() const;
public: public:
EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent, EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent,
FRAME_T aFrameType, FRAME_T aFrameType,