23#include <wx/textctrl.h>
24#include <wx/process.h>
27#include <wx/txtstrm.h>
42 wxMessageQueue<DIALOG_EXPORT_STEP_LOG::STATE_MESSAGE>& aMsgQueue ) :
43 wxThread( wxTHREAD_JOINABLE ),
58 ExitCode
Entry()
override;
61 wxMessageQueue<DIALOG_EXPORT_STEP_LOG::STATE_MESSAGE>&
m_queue;
78 wxProcess::Kill(
m_process->GetPid(), wxSIGKILL );
79 c =
reinterpret_cast<ExitCode
>( 1 );
84 wxMessageQueueError e =
m_queue.ReceiveTimeout( 10, m );
87 if( e == wxMSGQUEUE_NO_ERROR )
92 c =
reinterpret_cast<ExitCode
>( 0 );
97 wxProcess::Kill(
m_process->GetPid(), wxSIGKILL );
98 c =
reinterpret_cast<ExitCode
>( 1 );
102 else if( e == wxMSGQUEUE_TIMEOUT )
119 wxString fromInputStream, fromErrorStream;
120 wxInputStream* stream;
126 fromInputStream << wxString(
m_buffer, stream->LastRead() );
133 fromErrorStream << wxString(
m_buffer, stream->LastRead() );
136 if( !fromInputStream.IsEmpty() )
138 wxThreadEvent*
event =
new wxThreadEvent( wxEVT_THREAD_STDIN );
139 event->SetString( fromInputStream );
143 if( !fromErrorStream.IsEmpty() )
145 wxThreadEvent*
event =
new wxThreadEvent( wxEVT_THREAD_STDERR );
146 event->SetString( fromErrorStream );
179 int exitCode = aEvent.GetExitCode();
190 wxString::Format(
_(
"Process failed with exit code %d" ), exitCode ) );
223 if( !
path.IsEmpty() && wxFileExists(
path ) )
224 wxRemoveFile(
path );
241 if( aEvent.CanVeto() )
243 wxMessageDialog dlg(
this,
_(
"Do you want to cancel the export process?" ),
244 _(
"Cancel Export" ), wxYES_NO );
246 if( dlg.ShowModal() == wxID_NO )
314 wxExecute( aStepCmd, wxEXEC_ASYNC,
m_process );
void appendMessage(const wxString &aMessage)
void SetTempFilesToCleanup(std::vector< wxString > aPaths)
Register files that should be removed once the subprocess is known to have terminated (or been repare...
void onThreadInput(wxThreadEvent &)
std::vector< wxString > m_tempFiles
~DIALOG_EXPORT_STEP_LOG() override
DIALOG_EXPORT_STEP_LOG(wxWindow *aParent, const wxString &aStepCmd)
void onProcessTerminate(wxProcessEvent &aEvent)
bool TransferDataToWindow() override
@ PROCESS_COMPLETE
Informs the thread the process terminate event was received from wx.
@ REQUEST_EXIT
Asks the thread to exit and kill the process.
@ SENTINEL
Just a dummy entry for end of list.
void onClose(wxCloseEvent &event)
wxMessageQueue< STATE_MESSAGE > m_msgQueue
DIALOG_EXPORT_STEP_PROCESS_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("3D Export"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
wxGauge * m_activityGauge
wxTextCtrl * m_textCtrlLog
This thread handles consuming the input streams from the launched process.
ExitCode Entry() override
STDSTREAM_THREAD(wxEvtHandler *aEventHandler, wxProcess *aProcess, wxMessageQueue< DIALOG_EXPORT_STEP_LOG::STATE_MESSAGE > &aMsgQueue)
wxMessageQueue< DIALOG_EXPORT_STEP_LOG::STATE_MESSAGE > & m_queue
wxDEFINE_EVENT(wxEVT_THREAD_STDIN, wxThreadEvent)