From 68d644fd28681e732bc5ec904174e55d0115d856 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Thu, 12 Dec 2019 10:24:55 +0100 Subject: [PATCH] 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. From master, commit 21dd8db --- pcbnew/router/length_tuner_tool.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/pcbnew/router/length_tuner_tool.cpp b/pcbnew/router/length_tuner_tool.cpp index 207fa2b590..2d95918319 100644 --- a/pcbnew/router/length_tuner_tool.cpp +++ b/pcbnew/router/length_tuner_tool.cpp @@ -165,11 +165,15 @@ void LENGTH_TUNER_TOOL::performTuning() VECTOR2I end( m_startSnapPoint ); - PNS_TUNE_STATUS_POPUP statusPopup( frame() ); - statusPopup.Popup(); + // Create an instance of PNS_TUNE_STATUS_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 statusPopup( new PNS_TUNE_STATUS_POPUP( frame() ) ); + statusPopup->Popup(); m_router->Move( end, NULL ); - updateStatusPopup( statusPopup ); + updateStatusPopup( *statusPopup ); while( OPT_TOOL_EVENT evt = Wait() ) { @@ -179,7 +183,7 @@ void LENGTH_TUNER_TOOL::performTuning() { end = evt->Position(); m_router->Move( end, NULL ); - updateStatusPopup( statusPopup ); + updateStatusPopup( *statusPopup ); } else if( evt->IsClick( BUT_LEFT ) ) { @@ -195,32 +199,32 @@ void LENGTH_TUNER_TOOL::performTuning() { placer->AmplitudeStep( -1 ); m_router->Move( end, NULL ); - updateStatusPopup( statusPopup ); + updateStatusPopup( *statusPopup ); } else if( evt->IsAction( &ACT_AmplIncrease ) ) { placer->AmplitudeStep( 1 ); m_router->Move( end, NULL ); - updateStatusPopup( statusPopup ); + updateStatusPopup( *statusPopup ); } else if(evt->IsAction( &ACT_SpacingDecrease ) ) { placer->SpacingStep( -1 ); m_router->Move( end, NULL ); - updateStatusPopup( statusPopup ); + updateStatusPopup( *statusPopup ); } else if( evt->IsAction( &ACT_SpacingIncrease ) ) { placer->SpacingStep( 1 ); m_router->Move( end, NULL ); - updateStatusPopup( statusPopup ); + updateStatusPopup( *statusPopup ); } else if( evt->IsAction( &ACT_Settings ) ) { - statusPopup.Hide(); + statusPopup->Hide(); TOOL_EVENT dummy; meanderSettingsDialog( dummy ); - statusPopup.Show(); + statusPopup->Show(); } }