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 ),
61 ExitCode
Entry()
override;
64 wxMessageQueue<DIALOG_EXPORT_STEP_LOG::STATE_MESSAGE>&
m_queue;
82 c =
reinterpret_cast<ExitCode
>( 1 );
87 wxMessageQueueError e =
m_queue.ReceiveTimeout( 10, m );
90 if( e == wxMSGQUEUE_NO_ERROR )
95 c =
reinterpret_cast<ExitCode
>( 0 );
101 c =
reinterpret_cast<ExitCode
>( 1 );
105 else if( e == wxMSGQUEUE_TIMEOUT )
122 wxString fromInputStream, fromErrorStream;
123 wxInputStream* stream;
129 fromInputStream << wxString(
m_buffer, stream->LastRead() );
136 fromErrorStream << wxString(
m_buffer, stream->LastRead() );
139 if( !fromInputStream.IsEmpty() )
141 wxThreadEvent*
event =
new wxThreadEvent( wxEVT_THREAD_STDIN );
142 event->SetString( fromInputStream );
146 if( !fromErrorStream.IsEmpty() )
148 wxThreadEvent*
event =
new wxThreadEvent( wxEVT_THREAD_STDERR );
149 event->SetString( fromErrorStream );
175 if( aEvent.GetExitCode() )
227 m_textCtrlLog->AppendText(
"Unable to launch stdstream thread.\n" );
234 wxExecute( aStepCmd, wxEXEC_ASYNC,
m_process );
void appendMessage(const wxString &aMessage)
DIALOG_EXPORT_STEP_LOG(wxWindow *aParent, wxString aStepCmd)
void onThreadInput(wxThreadEvent &)
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)