Fixed crash upon finished zone drawing in GAL.

In principle, this patch reverts 2eefa117. The difference is removal of
one unused method (SELECTION::clear) and fixing hidden overloaded
virtual methods warnings.

Fixes: lp:1657569
* https://bugs.launchpad.net/kicad/+bug/1657569
This commit is contained in:
Maciej Suminski 2017-01-18 22:04:35 +01:00
parent fbace8e513
commit e5fbd0c442
4 changed files with 49 additions and 76 deletions

View File

@ -195,7 +195,7 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent )
// Add a VIEW_GROUP that serves as a preview for the new item
SELECTION preview;
m_view->Add( preview.ViewGroup() );
m_view->Add( &preview );
m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear, true );
m_controls->ShowCursor( true );
@ -239,13 +239,13 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent )
if( evt->IsAction( &COMMON_ACTIONS::rotate ) )
{
text->Rotate( text->GetPosition(), m_frame->GetRotationAngle() );
m_view->Update( preview.ViewGroup() );
m_view->Update( &preview );
}
// TODO rotate CCW
else if( evt->IsAction( &COMMON_ACTIONS::flip ) )
{
text->Flip( text->GetPosition() );
m_view->Update( preview.ViewGroup() );
m_view->Update( &preview );
}
}
@ -340,7 +340,7 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent )
text->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
// Show a preview of the item
m_view->Update( preview.ViewGroup() );
m_view->Update( &preview );
}
}
@ -349,7 +349,7 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent )
m_controls->SetAutoPan( false );
m_controls->CaptureCursor( false );
m_view->Remove( preview.ViewGroup() );
m_view->Remove( &preview );
m_frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
return 0;
@ -365,7 +365,7 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
// Add a VIEW_GROUP that serves as a preview for the new item
SELECTION preview;
m_view->Add( preview.ViewGroup() );
m_view->Add( &preview );
m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear, true );
m_controls->ShowCursor( true );
@ -409,7 +409,7 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
else if( evt->IsAction( &COMMON_ACTIONS::incWidth ) && step != SET_ORIGIN )
{
dimension->SetWidth( dimension->GetWidth() + WIDTH_STEP );
m_view->Update( preview.ViewGroup() );
m_view->Update( &preview );
}
else if( evt->IsAction( &COMMON_ACTIONS::decWidth ) && step != SET_ORIGIN )
@ -419,7 +419,7 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
if( width > WIDTH_STEP )
{
dimension->SetWidth( width - WIDTH_STEP );
m_view->Update( preview.ViewGroup() );
m_view->Update( &preview );
}
}
@ -523,7 +523,7 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
}
// Show a preview of the item
m_view->Update( preview.ViewGroup() );
m_view->Update( &preview );
}
}
@ -534,7 +534,7 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
m_controls->SetSnapping( false );
m_controls->SetAutoPan( false );
m_controls->CaptureCursor( false );
m_view->Remove( preview.ViewGroup() );
m_view->Remove( &preview );
m_frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
@ -589,7 +589,7 @@ int DRAWING_TOOL::PlaceDXF( const TOOL_EVENT& aEvent )
}
BOARD_ITEM* firstItem = preview.Front();
m_view->Add( preview.ViewGroup() );
m_view->Add( &preview );
m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear, true );
m_controls->ShowCursor( true );
@ -611,7 +611,7 @@ int DRAWING_TOOL::PlaceDXF( const TOOL_EVENT& aEvent )
for( auto item : preview )
item->Move( wxPoint( delta.x, delta.y ) );
m_view->Update( preview.ViewGroup() );
m_view->Update( &preview );
}
else if( evt->Category() == TC_COMMAND )
@ -623,18 +623,18 @@ int DRAWING_TOOL::PlaceDXF( const TOOL_EVENT& aEvent )
item->Rotate( wxPoint( cursorPos.x, cursorPos.y ),
m_frame->GetRotationAngle() );
m_view->Update( preview.ViewGroup() );
m_view->Update( &preview );
}
else if( evt->IsAction( &COMMON_ACTIONS::flip ) )
{
for( auto item : preview )
item->Flip( wxPoint( cursorPos.x, cursorPos.y ) );
m_view->Update( preview.ViewGroup() );
m_view->Update( &preview );
}
else if( evt->IsCancel() || evt->IsActivate() )
{
preview.ViewGroup()->FreeItems();
preview.FreeItems();
break;
}
}
@ -731,7 +731,7 @@ int DRAWING_TOOL::PlaceDXF( const TOOL_EVENT& aEvent )
m_controls->SetSnapping( false );
m_controls->SetAutoPan( false );
m_controls->CaptureCursor( false );
m_view->Remove( preview.ViewGroup() );
m_view->Remove( &preview );
return 0;
}
@ -800,7 +800,7 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic,
// Add a VIEW_GROUP that serves as a preview for the new item
SELECTION preview;
m_view->Add( preview.ViewGroup() );
m_view->Add( &preview );
m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear, true );
m_controls->ShowCursor( true );
@ -962,14 +962,14 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic,
}
if( updatePreview )
m_view->Update( preview.ViewGroup() );
m_view->Update( &preview );
}
m_controls->ShowCursor( false );
m_controls->SetSnapping( false );
m_controls->SetAutoPan( false );
m_controls->CaptureCursor( false );
m_view->Remove( preview.ViewGroup() );
m_view->Remove( &preview );
return started;
}
@ -988,7 +988,7 @@ bool DRAWING_TOOL::drawArc( DRAWSEGMENT*& aGraphic )
// Add a VIEW_GROUP that serves as a preview for the new item
SELECTION preview;
m_view->Add( preview.ViewGroup() );
m_view->Add( &preview );
m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear, true );
m_controls->ShowCursor( true );
@ -1116,13 +1116,13 @@ bool DRAWING_TOOL::drawArc( DRAWSEGMENT*& aGraphic )
}
// Show a preview of the item
m_view->Update( preview.ViewGroup() );
m_view->Update( &preview );
}
else if( evt->IsAction( &COMMON_ACTIONS::incWidth ) )
{
aGraphic->SetWidth( aGraphic->GetWidth() + WIDTH_STEP );
m_view->Update( preview.ViewGroup() );
m_view->Update( &preview );
}
else if( evt->IsAction( &COMMON_ACTIONS::decWidth ) )
@ -1132,7 +1132,7 @@ bool DRAWING_TOOL::drawArc( DRAWSEGMENT*& aGraphic )
if( width > WIDTH_STEP )
{
aGraphic->SetWidth( width - WIDTH_STEP );
m_view->Update( preview.ViewGroup() );
m_view->Update( &preview );
}
}
@ -1144,7 +1144,7 @@ bool DRAWING_TOOL::drawArc( DRAWSEGMENT*& aGraphic )
aGraphic->SetAngle( aGraphic->GetAngle() + 3600.0 );
clockwise = !clockwise;
m_view->Update( preview.ViewGroup() );
m_view->Update( &preview );
}
}
@ -1152,7 +1152,7 @@ bool DRAWING_TOOL::drawArc( DRAWSEGMENT*& aGraphic )
m_controls->SetSnapping( false );
m_controls->SetAutoPan( false );
m_controls->CaptureCursor( false );
m_view->Remove( preview.ViewGroup() );
m_view->Remove( &preview );
return ( step > SET_ORIGIN );
}
@ -1167,7 +1167,7 @@ int DRAWING_TOOL::drawZone( bool aKeepout )
// Add a VIEW_GROUP that serves as a preview for the new item
SELECTION preview;
m_view->Add( preview.ViewGroup() );
m_view->Add( &preview );
m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear, true );
m_controls->ShowCursor( true );
@ -1219,7 +1219,7 @@ int DRAWING_TOOL::drawZone( bool aKeepout )
direction45 = false;
}
preview.ViewGroup()->FreeItems();
preview.FreeItems();
updatePreview = true;
numPoints = 0;
@ -1274,7 +1274,7 @@ int DRAWING_TOOL::drawZone( bool aKeepout )
direction45 = false;
}
preview.ViewGroup()->FreeItems();
preview.FreeItems();
updatePreview = true;
}
else
@ -1357,14 +1357,14 @@ int DRAWING_TOOL::drawZone( bool aKeepout )
}
if( updatePreview )
m_view->Update( preview.ViewGroup() );
m_view->Update( &preview );
}
m_controls->ShowCursor( false );
m_controls->SetSnapping( false );
m_controls->SetAutoPan( false );
m_controls->CaptureCursor( false );
m_view->Remove( preview.ViewGroup() );
m_view->Remove( &preview );
m_frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013-2017 CERN
* Copyright (C) 2013-2015 CERN
* @author Maciej Suminski <maciej.suminski@cern.ch>
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
*
@ -242,7 +242,7 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
}
}
getView()->Update( selection.ViewGroup() );
getView()->Update( &selection );
m_toolMgr->RunAction( COMMON_ACTIONS::editModifiedSelection, true );
}
@ -290,7 +290,7 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
{
// Update dragging offset (distance between cursor and the first dragged item)
m_offset = selection.Front()->GetPosition() - modPoint;
getView()->Update( selection.ViewGroup() );
getView()->Update( &selection );
updateRatsnest( true );
}
}

View File

@ -77,7 +77,7 @@ SELECTION_TOOL::SELECTION_TOOL() :
SELECTION_TOOL::~SELECTION_TOOL()
{
getView()->Remove( m_selection.ViewGroup() );
getView()->Remove( &m_selection );
}
@ -123,8 +123,8 @@ void SELECTION_TOOL::Reset( RESET_REASON aReason )
clearSelection();
// Reinsert the VIEW_GROUP, in case it was removed from the VIEW
getView()->Remove( m_selection.ViewGroup() );
getView()->Add( m_selection.ViewGroup() );
getView()->Remove( &m_selection );
getView()->Add( &m_selection );
}
@ -1384,9 +1384,9 @@ VECTOR2I SELECTION::GetCenter() const
}
const KIGFX::VIEW_GROUP::ITEMS SELECTION::SELECTION_VIEW_GROUP::updateDrawList() const
const KIGFX::VIEW_GROUP::ITEMS SELECTION::updateDrawList() const
{
std::vector<KIGFX::VIEW_ITEM*> items;
std::vector<VIEW_ITEM*> items;
for( auto item : m_items )
{

View File

@ -45,7 +45,7 @@ namespace KIGFX
class GAL;
}
struct SELECTION
struct SELECTION : public KIGFX::VIEW_GROUP
{
public:
using ITER = std::set<BOARD_ITEM*>::iterator;
@ -56,35 +56,27 @@ public:
CITER begin() const { return m_items.cbegin(); }
CITER end() const { return m_items.cend(); }
SELECTION()
: m_viewGroup( m_items )
{
}
void Add( BOARD_ITEM* aItem )
virtual void Add( BOARD_ITEM* aItem )
{
m_items.insert( aItem );
m_viewGroup.Add( aItem );
}
void Remove( BOARD_ITEM *aItem )
virtual void Remove( BOARD_ITEM *aItem )
{
m_items.erase( aItem );
m_viewGroup.Remove( aItem );
}
void Clear()
virtual void Clear() override
{
m_items.clear();
m_viewGroup.Clear();
}
unsigned int GetSize() const
virtual unsigned int GetSize() const override
{
return m_items.size();
}
KIGFX::VIEW_ITEM* GetItem( unsigned int idx ) const
virtual KIGFX::VIEW_ITEM* GetItem( unsigned int idx ) const override
{
auto iter = m_items.begin();
@ -141,34 +133,16 @@ public:
return m_items;
}
KIGFX::VIEW_GROUP* ViewGroup()
{
return &m_viewGroup;
}
virtual const VIEW_GROUP::ITEMS updateDrawList() const override;
private:
class SELECTION_VIEW_GROUP : public KIGFX::VIEW_GROUP
{
public:
SELECTION_VIEW_GROUP( std::set<BOARD_ITEM*>& aItemSet )
: m_items( aItemSet )
{
}
protected:
virtual const VIEW_GROUP::ITEMS updateDrawList() const override;
private:
std::set<BOARD_ITEM*>& m_items;
};
/// VIEW_GROUP keeping the selected items
SELECTION_VIEW_GROUP m_viewGroup;
/// Set of selected items
std::set<BOARD_ITEM*> m_items;
};
// mute hidden overloaded virtual function warnings
using VIEW_GROUP::Add;
using VIEW_GROUP::Remove;
};
enum SELECTION_LOCK_FLAGS
{
@ -177,7 +151,6 @@ enum SELECTION_LOCK_FLAGS
SELECTION_LOCKED = 2
};
/**
* Class SELECTION_TOOL
*