P&S router: length tuning tool: fix a crash after trying to tune a track.

It happens on Windows, and wxWidgets 3.1.3.
It is created by PNS_TUNE_STATUS_POPUP instance used in tool.
I am pretty sure this crash is created by the stack switching
when managing events, due to some changes in wxWidgets code.
the fix creates the instance on the heap, instead of on the stack.
This is not the first time I see this kind of issue.
This commit is contained in:
jean-pierre charras 2019-12-12 09:39:51 +01:00
parent ed025972ab
commit 21dd8db7a9
1 changed files with 20 additions and 16 deletions

View File

@ -182,11 +182,15 @@ void LENGTH_TUNER_TOOL::performTuning()
VECTOR2I end( m_startSnapPoint ); VECTOR2I end( m_startSnapPoint );
PNS_TUNE_STATUS_POPUP statusPopup( frame() ); // Create an instance of PNS_TUNE_STATUS_POPUP.
statusPopup.Popup(); // DO NOT create it on the stack: otherwise on Windows, wxWidgets 3.1.3
// it creates a crash. I am pretty sure this crash is created by the stack switching
// when managing events (JPC).
std::unique_ptr<PNS_TUNE_STATUS_POPUP> statusPopup( new PNS_TUNE_STATUS_POPUP( frame() ) );
statusPopup->Popup();
m_router->Move( end, NULL ); m_router->Move( end, NULL );
updateStatusPopup( statusPopup ); updateStatusPopup( *statusPopup );
while( TOOL_EVENT* evt = Wait() ) while( TOOL_EVENT* evt = Wait() )
{ {
@ -198,7 +202,7 @@ void LENGTH_TUNER_TOOL::performTuning()
{ {
end = evt->Position(); end = evt->Position();
m_router->Move( end, NULL ); m_router->Move( end, NULL );
updateStatusPopup( statusPopup ); updateStatusPopup( *statusPopup );
} }
else if( evt->IsClick( BUT_LEFT ) ) else if( evt->IsClick( BUT_LEFT ) )
{ {
@ -214,32 +218,32 @@ void LENGTH_TUNER_TOOL::performTuning()
{ {
placer->AmplitudeStep( -1 ); placer->AmplitudeStep( -1 );
m_router->Move( end, NULL ); m_router->Move( end, NULL );
updateStatusPopup( statusPopup ); updateStatusPopup( *statusPopup );
} }
else if( evt->IsAction( &ACT_AmplIncrease ) ) else if( evt->IsAction( &ACT_AmplIncrease ) )
{ {
placer->AmplitudeStep( 1 ); placer->AmplitudeStep( 1 );
m_router->Move( end, NULL ); m_router->Move( end, NULL );
updateStatusPopup( statusPopup ); updateStatusPopup( *statusPopup );
} }
else if(evt->IsAction( &ACT_SpacingDecrease ) ) else if(evt->IsAction( &ACT_SpacingDecrease ) )
{ {
placer->SpacingStep( -1 ); placer->SpacingStep( -1 );
m_router->Move( end, NULL ); m_router->Move( end, NULL );
updateStatusPopup( statusPopup ); updateStatusPopup( *statusPopup );
} }
else if( evt->IsAction( &ACT_SpacingIncrease ) ) else if( evt->IsAction( &ACT_SpacingIncrease ) )
{ {
placer->SpacingStep( 1 ); placer->SpacingStep( 1 );
m_router->Move( end, NULL ); m_router->Move( end, NULL );
updateStatusPopup( statusPopup ); updateStatusPopup( *statusPopup );
} }
else if( evt->IsAction( &ACT_Settings ) ) else if( evt->IsAction( &ACT_Settings ) )
{ {
statusPopup.Hide(); statusPopup->Hide();
TOOL_EVENT dummy; TOOL_EVENT dummy;
meanderSettingsDialog( dummy ); meanderSettingsDialog( dummy );
statusPopup.Show(); statusPopup->Show();
} }
} }