Don't try and run drawing tools in ModEdit with no module selected.

Fixes: lp:1836673
* https://bugs.launchpad.net/kicad/+bug/1836673

(cherry picked from commit 02eb1d2c62)
This commit is contained in:
Jeff Young 2019-07-19 22:13:52 +01:00
parent 105c9c71ee
commit e4bab37b62
5 changed files with 23 additions and 4 deletions

View File

@ -257,6 +257,14 @@ public:
void ClearFlags( STATUS_FLAGS aMask = EDA_ITEM_ALL_FLAGS ) { m_Flags &= ~aMask; }
STATUS_FLAGS GetFlags() const { return m_Flags; }
STATUS_FLAGS GetEditFlags() const
{
int mask = EDA_ITEM_ALL_FLAGS - ( SELECTED | SELECTEDNODE | HIGHLIGHTED | BRIGHTENED |
STARTPOINT | ENDPOINT |
BEGIN_ONPAD | END_ONPAD | DP_COUPLED );
return m_Flags & mask;
}
/**
* Function IsType
* Checks whether the item is one of the listed types

View File

@ -1193,7 +1193,7 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic,
* of an Arc Geometry Manager
*/
static void updateArcFromConstructionMgr( const KIGFX::PREVIEW::ARC_GEOM_MANAGER& aMgr,
DRAWSEGMENT& aArc )
DRAWSEGMENT& aArc )
{
auto vec = aMgr.GetOrigin();
@ -1378,6 +1378,9 @@ bool DRAWING_TOOL::getSourceZoneForAction( ZONE_MODE aMode, ZONE_CONTAINER*& aZo
int DRAWING_TOOL::drawZone( bool aKeepout, ZONE_MODE aMode )
{
if( m_editModules && !m_frame->GetModel() )
return 0;
// get a source zone, if we need one. We need it for:
// ZONE_MODE::CUTOUT (adding a hole to the source zone)
// ZONE_MODE::SIMILAR (creating a new zone using settings of source zone

View File

@ -99,6 +99,9 @@ void MODULE_EDITOR_TOOLS::Reset( RESET_REASON aReason )
int MODULE_EDITOR_TOOLS::PlacePad( const TOOL_EVENT& aEvent )
{
if( !frame()->GetBoard()->m_Modules )
return 0;
struct PAD_PLACER : public INTERACTIVE_PLACER_BASE
{
std::unique_ptr<BOARD_ITEM> CreateItem() override
@ -129,8 +132,6 @@ int MODULE_EDITOR_TOOLS::PlacePad( const TOOL_EVENT& aEvent )
frame()->SetToolID( ID_MODEDIT_PAD_TOOL, wxCURSOR_PENCIL, _( "Add pads" ) );
wxASSERT( board()->m_Modules );
doInteractiveItemPlacement( &placer, _( "Place pad" ), IPO_REPEAT | IPO_SINGLE_CLICK | IPO_ROTATE | IPO_FLIP );
frame()->SetNoToolSelected();

View File

@ -65,7 +65,8 @@ void PCB_TOOL::doInteractiveItemPlacement( INTERACTIVE_PLACER_BASE* aPlacer,
{
VECTOR2I cursorPos = controls()->GetCursorPosition();
newItem = aPlacer->CreateItem();
if( frame()->GetModel() )
newItem = aPlacer->CreateItem();
if( newItem )
{

View File

@ -594,6 +594,9 @@ int PCBNEW_CONTROL::GridSetOrigin( const TOOL_EVENT& aEvent )
}
else
{
if( m_editModules && !getEditFrame<PCB_BASE_EDIT_FRAME>()->GetModel() )
return 0;
Activate();
PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
@ -683,6 +686,9 @@ static bool deleteItem( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition )
int PCBNEW_CONTROL::DeleteItemCursor( const TOOL_EVENT& aEvent )
{
if( m_editModules && !m_frame->GetBoard()->m_Modules )
return 0;
Activate();
PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();