]> git.saurik.com Git - wxWidgets.git/blame - src/common/process.cpp
fixed bug in wxFileDialog: it tested wxCHANGE_DIR against GetWindowStyle() instead...
[wxWidgets.git] / src / common / process.cpp
CommitLineData
ca7731b7
GL
1/////////////////////////////////////////////////////////////////////////////
2// Name: process.cpp
3// Purpose: Process termination classes
4// Author: Guilhem Lavaux
7e84f02d 5// Modified by: Vadim Zeitlin to check error codes, added Detach() method
ca7731b7
GL
6// Created: 24/06/98
7// RCS-ID: $Id$
8// Copyright: (c) Guilhem Lavaux
7e84f02d 9// Licence: wxWindows license
ca7731b7
GL
10/////////////////////////////////////////////////////////////////////////////
11
12#ifdef __GNUG__
5336ece4 13 #pragma implementation "process.h"
ca7731b7
GL
14#endif
15
16// For compilers that support precompilation, includes "wx.h".
17#include "wx/wxprec.h"
18
19#ifdef __BORLANDC__
5336ece4 20 #pragma hdrstop
ca7731b7
GL
21#endif
22
23#ifndef WX_PRECOMP
5336ece4 24 #include "wx/defs.h"
ca7731b7
GL
25#endif
26
27#include "wx/process.h"
28
eebb848a
KB
29IMPLEMENT_DYNAMIC_CLASS(wxProcess, wxEvtHandler)
30IMPLEMENT_DYNAMIC_CLASS(wxProcessEvent, wxEvent)
ca7731b7 31
cd6ce4a9 32void wxProcess::Init(wxEvtHandler *parent, int id, bool redirect)
ca7731b7 33{
cd6ce4a9 34 if ( parent )
7e84f02d 35 SetNextHandler(parent);
ca7731b7 36
8b33ae2d 37 m_id = id;
cd6ce4a9 38 m_redirect = redirect;
f6bcfd97
BP
39
40#if wxUSE_STREAMS
cd6ce4a9 41 m_inputStream = NULL;
f6bcfd97 42 m_errorStream = NULL;
cd6ce4a9 43 m_outputStream = NULL;
f6bcfd97 44#endif // wxUSE_STREAMS
8b33ae2d
GL
45}
46
47wxProcess::~wxProcess()
48{
f6bcfd97 49#if wxUSE_STREAMS
cd6ce4a9 50 delete m_inputStream;
f6bcfd97 51 delete m_errorStream;
cd6ce4a9 52 delete m_outputStream;
f6bcfd97 53#endif // wxUSE_STREAMS
ca7731b7
GL
54}
55
5336ece4 56void wxProcess::OnTerminate(int pid, int status)
81d66cf3 57{
7e84f02d 58 wxProcessEvent event(m_id, pid, status);
ca7731b7 59
7e84f02d
VZ
60 if ( !ProcessEvent(event) )
61 delete this;
62 //else: the object which processed the event is responsible for deleting
63 // us!
64}
65
66void wxProcess::Detach()
67{
68 SetNextHandler(NULL);
ca7731b7 69}
8b33ae2d 70
f6bcfd97
BP
71#if wxUSE_STREAMS
72
73void wxProcess::SetPipeStreams(wxInputStream *inputSstream,
74 wxOutputStream *outputStream,
75 wxInputStream *errorStream)
8b33ae2d 76{
f6bcfd97
BP
77 m_inputStream = inputSstream;
78 m_errorStream = errorStream;
79 m_outputStream = outputStream;
8b33ae2d
GL
80}
81
f6bcfd97 82#endif // wxUSE_STREAMS