From 13544ff975c55615cd5c0313795b3eb12c84f3b9 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Tue, 16 Jan 2024 13:17:57 -0800 Subject: [PATCH] Avoid crash on step export Detach the wxProcess from the chain before closing Fixes https://gitlab.com/kicad/code/kicad/-/issues/16608 --- pcbnew/dialogs/dialog_export_step_process.cpp | 16 +++++++++++++--- pcbnew/dialogs/dialog_export_step_process.h | 1 + 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/pcbnew/dialogs/dialog_export_step_process.cpp b/pcbnew/dialogs/dialog_export_step_process.cpp index 65c3d2f35c..af18fd2b79 100644 --- a/pcbnew/dialogs/dialog_export_step_process.cpp +++ b/pcbnew/dialogs/dialog_export_step_process.cpp @@ -54,7 +54,6 @@ public: ~STDSTREAM_THREAD() { delete[] m_buffer; - delete m_process; } private: @@ -210,10 +209,21 @@ void DIALOG_EXPORT_STEP_LOG::onClose( wxCloseEvent& aEvent ) { m_msgQueue.Post( STATE_MESSAGE::REQUEST_EXIT ); m_stdioThread->Wait(); - delete m_stdioThread; + + m_process->DeletePendingEvents(); + m_process->Unlink(); + m_process->CloseOutput(); + m_process->Detach(); + + m_stdioThread->Delete(); } - Destroy(); + aEvent.Skip(); +} + +DIALOG_EXPORT_STEP_LOG::~DIALOG_EXPORT_STEP_LOG() +{ + delete m_stdioThread; } diff --git a/pcbnew/dialogs/dialog_export_step_process.h b/pcbnew/dialogs/dialog_export_step_process.h index 7ee41feed4..8a74a78f2f 100644 --- a/pcbnew/dialogs/dialog_export_step_process.h +++ b/pcbnew/dialogs/dialog_export_step_process.h @@ -41,6 +41,7 @@ public: }; DIALOG_EXPORT_STEP_LOG( wxWindow* aParent, wxString aStepCmd ); + ~DIALOG_EXPORT_STEP_LOG() override; private: void appendMessage( const wxString& aMessage );