27#include <wx/textctrl.h>
28#include <wx/process.h>
31#include <wx/txtstrm.h>
45 wxMessageQueue<DIALOG_EXPORT_STEP_LOG::STATE_MESSAGE>& aMsgQueue ) :
46 wxThread( wxTHREAD_JOINABLE ),
61 ExitCode
Entry()
override;
64 wxMessageQueue<DIALOG_EXPORT_STEP_LOG::STATE_MESSAGE>&
m_queue;
81 wxProcess::Kill(
m_process->GetPid(), wxSIGKILL );
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 );
100 wxProcess::Kill(
m_process->GetPid(), wxSIGKILL );
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 );
173 int exitCode = aEvent.GetExitCode();
184 wxString::Format(
_(
"Process failed with exit code %d" ), exitCode ) );
211 if( aEvent.CanVeto() )
213 wxMessageDialog dlg(
this,
_(
"Do you want to cancel the export process?" ),
214 _(
"Cancel Export" ), wxYES_NO );
216 if( dlg.ShowModal() == wxID_NO )
266 m_textCtrlLog->AppendText(
"Unable to launch stdstream thread.\n" );
273 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)