From 658d181ec7dc9c1ae92f6a5b873cf198ea621b76 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 1 Jan 2018 21:14:08 +0000 Subject: [PATCH] Don't capture cursor if zone or polygon cancelled. If the client tool indicates it isn't happy for us to continue (because, for instance, the user has cancelled the Zone Properties dialog), then make sure we don't capture the mouse. Fixes: lp: 1740780 * https://bugs.launchpad.net/kicad/+bug/1740780 --- common/preview_items/polygon_geom_manager.cpp | 5 +++-- include/preview_items/polygon_geom_manager.h | 2 +- pcbnew/tools/drawing_tool.cpp | 5 ++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/common/preview_items/polygon_geom_manager.cpp b/common/preview_items/polygon_geom_manager.cpp index cbd910b345..6b26c1d91f 100644 --- a/common/preview_items/polygon_geom_manager.cpp +++ b/common/preview_items/polygon_geom_manager.cpp @@ -32,12 +32,12 @@ POLYGON_GEOM_MANAGER::POLYGON_GEOM_MANAGER( CLIENT& aClient ): {} -void POLYGON_GEOM_MANAGER::AddPoint( const VECTOR2I& aPt ) +bool POLYGON_GEOM_MANAGER::AddPoint( const VECTOR2I& aPt ) { // if this is the first point, make sure the client is happy // for us to continue if( !IsPolygonInProgress() && !m_client.OnFirstPoint() ) - return; + return false; if( m_leaderPts.size() > 1 ) { @@ -53,6 +53,7 @@ void POLYGON_GEOM_MANAGER::AddPoint( const VECTOR2I& aPt ) } m_client.OnGeometryChange( *this ); + return true; } diff --git a/include/preview_items/polygon_geom_manager.h b/include/preview_items/polygon_geom_manager.h index aaeda2b869..9e66d89047 100644 --- a/include/preview_items/polygon_geom_manager.h +++ b/include/preview_items/polygon_geom_manager.h @@ -78,7 +78,7 @@ public: /** * Lock in a polygon point. */ - void AddPoint( const VECTOR2I& aPt ); + bool AddPoint( const VECTOR2I& aPt ); /** * Mark the polygon finished and update the client diff --git a/pcbnew/tools/drawing_tool.cpp b/pcbnew/tools/drawing_tool.cpp index d63aaae2a9..280ab77055 100644 --- a/pcbnew/tools/drawing_tool.cpp +++ b/pcbnew/tools/drawing_tool.cpp @@ -1309,10 +1309,9 @@ void DRAWING_TOOL::runPolygonEventLoop( POLYGON_GEOM_MANAGER& polyGeomMgr ) controls.SetAutoPan( false ); controls.CaptureCursor( false ); } - else // adding a corner + // adding a corner + else if( polyGeomMgr.AddPoint( cursorPos ) ) { - polyGeomMgr.AddPoint( cursorPos ); - if( !started ) { started = true;