27#include <wx/textctrl.h>
28#include <wx/process.h>
31#include <wx/txtstrm.h>
44 wxMessageQueue<DIALOG_EXPORT_STEP_LOG::STATE_MESSAGE>& aMsgQueue ) :
45 wxThread( wxTHREAD_JOINABLE ),
60 ExitCode
Entry()
override;
63 wxMessageQueue<DIALOG_EXPORT_STEP_LOG::STATE_MESSAGE>&
m_queue;
81 c =
reinterpret_cast<ExitCode
>( 1 );
86 wxMessageQueueError e =
m_queue.ReceiveTimeout( 10, m );
89 if( e == wxMSGQUEUE_NO_ERROR )
94 c =
reinterpret_cast<ExitCode
>( 0 );
100 c =
reinterpret_cast<ExitCode
>( 1 );
104 else if( e == wxMSGQUEUE_TIMEOUT )
121 wxString fromInputStream, fromErrorStream;
122 wxInputStream* stream;
128 fromInputStream << wxString(
m_buffer, stream->LastRead() );
135 fromErrorStream << wxString(
m_buffer, stream->LastRead() );
138 if( !fromInputStream.IsEmpty() )
140 wxThreadEvent*
event =
new wxThreadEvent( wxEVT_THREAD_STDIN );
141 event->SetString( fromInputStream );
145 if( !fromErrorStream.IsEmpty() )
147 wxThreadEvent*
event =
new wxThreadEvent( wxEVT_THREAD_STDERR );
148 event->SetString( fromErrorStream );
172 int exitCode = aEvent.GetExitCode();
183 wxString::Format(
_(
"Process failed with exit code %d" ), exitCode ) );
255 m_textCtrlLog->AppendText(
"Unable to launch stdstream thread.\n" );
262 wxExecute( aStepCmd, wxEXEC_ASYNC,
m_process );
void appendMessage(const wxString &aMessage)
DIALOG_EXPORT_STEP_LOG(wxWindow *aParent, wxString aStepCmd)
void onThreadInput(wxThreadEvent &)
~DIALOG_EXPORT_STEP_LOG() override
void onProcessTerminate(wxProcessEvent &aEvent)
@ 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
Class DIALOG_EXPORT_STEP_PROCESS_BASE.
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)