27#include <wx/textctrl.h>
28#include <wx/process.h>
31#include <wx/txtstrm.h>
46 wxMessageQueue<DIALOG_EXPORT_STEP_LOG::STATE_MESSAGE>& aMsgQueue ) :
47 wxThread( wxTHREAD_JOINABLE ),
62 ExitCode
Entry()
override;
65 wxMessageQueue<DIALOG_EXPORT_STEP_LOG::STATE_MESSAGE>&
m_queue;
82 wxProcess::Kill(
m_process->GetPid(), wxSIGKILL );
83 c =
reinterpret_cast<ExitCode
>( 1 );
88 wxMessageQueueError e =
m_queue.ReceiveTimeout( 10, m );
91 if( e == wxMSGQUEUE_NO_ERROR )
96 c =
reinterpret_cast<ExitCode
>( 0 );
101 wxProcess::Kill(
m_process->GetPid(), wxSIGKILL );
102 c =
reinterpret_cast<ExitCode
>( 1 );
106 else if( e == wxMSGQUEUE_TIMEOUT )
123 wxString fromInputStream, fromErrorStream;
124 wxInputStream* stream;
130 fromInputStream << wxString(
m_buffer, stream->LastRead() );
137 fromErrorStream << wxString(
m_buffer, stream->LastRead() );
140 if( !fromInputStream.IsEmpty() )
142 wxThreadEvent*
event =
new wxThreadEvent( wxEVT_THREAD_STDIN );
143 event->SetString( fromInputStream );
147 if( !fromErrorStream.IsEmpty() )
149 wxThreadEvent*
event =
new wxThreadEvent( wxEVT_THREAD_STDERR );
150 event->SetString( fromErrorStream );
183 int exitCode = aEvent.GetExitCode();
194 wxString::Format(
_(
"Process failed with exit code %d" ), exitCode ) );
227 if( !
path.IsEmpty() && wxFileExists(
path ) )
228 wxRemoveFile(
path );
245 if( aEvent.CanVeto() )
247 wxMessageDialog dlg(
this,
_(
"Do you want to cancel the export process?" ),
248 _(
"Cancel Export" ), wxYES_NO );
250 if( dlg.ShowModal() == wxID_NO )
318 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)