Fix crash after calling EDIT_TOOL::pickCopyReferencePoint()
An instance of STATUS_TEXT_POPUP was created on the stack. But it crashes pcbnew when closing the current main frame, perhaps due to stack switching in coroutines. It is now created on the heap.
This commit is contained in:
parent
bb06e672e7
commit
f6881ce3de
|
@ -1326,33 +1326,36 @@ int EDIT_TOOL::EditFpInFpEditor( const TOOL_EVENT& aEvent )
|
||||||
bool EDIT_TOOL::pickCopyReferencePoint( VECTOR2I& aReferencePoint )
|
bool EDIT_TOOL::pickCopyReferencePoint( VECTOR2I& aReferencePoint )
|
||||||
{
|
{
|
||||||
std::string tool = "pcbnew.InteractiveEdit.selectReferencePoint";
|
std::string tool = "pcbnew.InteractiveEdit.selectReferencePoint";
|
||||||
STATUS_TEXT_POPUP statusPopup( frame() );
|
// Do not create statusPopup on the stack:
|
||||||
|
// it crashes pcbnew when closing the current main frame
|
||||||
|
// (perhaps due to stack switching in coroutines)
|
||||||
|
std::unique_ptr<STATUS_TEXT_POPUP> statusPopup( new STATUS_TEXT_POPUP( frame() ) );
|
||||||
PCBNEW_PICKER_TOOL* picker = m_toolMgr->GetTool<PCBNEW_PICKER_TOOL>();
|
PCBNEW_PICKER_TOOL* picker = m_toolMgr->GetTool<PCBNEW_PICKER_TOOL>();
|
||||||
OPT<VECTOR2I> pickedPoint;
|
OPT<VECTOR2I> pickedPoint;
|
||||||
bool done = false;
|
bool done = false;
|
||||||
|
|
||||||
statusPopup.SetText( _( "Select reference point for the copy..." ) );
|
statusPopup->SetText( _( "Select reference point for the copy..." ) );
|
||||||
|
|
||||||
picker->SetClickHandler(
|
picker->SetClickHandler(
|
||||||
[&]( const VECTOR2D& aPoint ) -> bool
|
[&]( const VECTOR2D& aPoint ) -> bool
|
||||||
{
|
{
|
||||||
pickedPoint = aPoint;
|
pickedPoint = aPoint;
|
||||||
statusPopup.SetText( _( "Selection copied." ) );
|
statusPopup->SetText( _( "Selection copied." ) );
|
||||||
statusPopup.Expire( 800 );
|
statusPopup->Expire( 800 );
|
||||||
return false; // we don't need any more points
|
return false; // we don't need any more points
|
||||||
} );
|
} );
|
||||||
|
|
||||||
picker->SetMotionHandler(
|
picker->SetMotionHandler(
|
||||||
[&] ( const VECTOR2D& aPos )
|
[&] ( const VECTOR2D& aPos )
|
||||||
{
|
{
|
||||||
statusPopup.Move( wxGetMousePosition() + wxPoint( 20, -50 ) );
|
statusPopup->Move( wxGetMousePosition() + wxPoint( 20, -50 ) );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
picker->SetCancelHandler(
|
picker->SetCancelHandler(
|
||||||
[&]()
|
[&]()
|
||||||
{
|
{
|
||||||
statusPopup.SetText( _( "Copy cancelled." ) );
|
statusPopup->SetText( _( "Copy cancelled." ) );
|
||||||
statusPopup.Expire( 800 );
|
statusPopup->Expire( 800 );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
picker->SetFinalizeHandler(
|
picker->SetFinalizeHandler(
|
||||||
|
@ -1361,8 +1364,8 @@ bool EDIT_TOOL::pickCopyReferencePoint( VECTOR2I& aReferencePoint )
|
||||||
done = true;
|
done = true;
|
||||||
} );
|
} );
|
||||||
|
|
||||||
statusPopup.Move( wxGetMousePosition() + wxPoint( 20, -50 ) );
|
statusPopup->Move( wxGetMousePosition() + wxPoint( 20, -50 ) );
|
||||||
statusPopup.Popup();
|
statusPopup->Popup();
|
||||||
|
|
||||||
m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
|
m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue