]> git.saurik.com Git - wxWidgets.git/commitdiff
extracted GUI-specific part of utilsunx.cpp to a new unix/apptraits.cpp file and...
authorVadim Zeitlin <vadim@wxwidgets.org>
Sat, 22 Mar 2008 03:48:11 +0000 (03:48 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sat, 22 Mar 2008 03:48:11 +0000 (03:48 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@52677 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/unix/apptraits.cpp [new file with mode: 0644]

diff --git a/src/unix/apptraits.cpp b/src/unix/apptraits.cpp
new file mode 100644 (file)
index 0000000..b81b55d
--- /dev/null
@@ -0,0 +1,89 @@
+///////////////////////////////////////////////////////////////////////////////
+// Name:        src/unix/apptraits.cpp
+// Purpose:     implementation of wxGUIAppTraits for Unix systems
+// Author:      Vadim Zeitlin
+// Created:     2008-03-22
+// RCS-ID:      $Id$
+// Copyright:   (c) 2008 Vadim Zeitlin <vadim@wxwindows.org>
+// Licence:     wxWindows licence
+///////////////////////////////////////////////////////////////////////////////
+
+// ============================================================================
+// declarations
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// headers
+// ----------------------------------------------------------------------------
+
+// for compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+    #pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#endif // WX_PRECOMP
+
+#include "wx/apptrait.h"
+#include "wx/unix/execute.h"
+
+// ============================================================================
+// implementation
+// ============================================================================
+
+int wxGUIAppTraits::WaitForChild(wxExecuteData& execData)
+{
+    const int flags = execData.flags;
+    if ( !(flags & wxEXEC_SYNC) || (flags & wxEXEC_NOEVENTS) )
+    {
+        // async or blocking sync cases are already handled by the base class
+        // just fine, no need to duplicate its code here
+        return wxAppTraits::WaitForChild(execData);
+    }
+
+    // here we're dealing with the case of synchronous execution when we want
+    // to process the GUI events while waiting for the child termination
+
+    wxEndProcessData endProcData;
+
+    // we may have process for capturing the program output, but it's
+    // not used in wxEndProcessData in the case of sync execution
+    endProcData.process = NULL;
+
+    // sync execution: indicate it by negating the pid
+    endProcData.pid = -execData.pid;
+
+    endProcData.tag = AddProcessCallback
+                      (
+                         &endProcData,
+                         execData.pipeEndProcDetect.Detach(wxPipe::Read)
+                      );
+
+    execData.pipeEndProcDetect.Close();
+
+
+    // prepare to wait for the child termination: show to the user that we're
+    // busy and refuse all input unless explicitly told otherwise
+    wxBusyCursor bc;
+    wxWindowDisabler wd(!(flags & wxEXEC_NODISABLE));
+
+    // endProcData.pid will be set to 0 from wxHandleProcessTermination() when
+    // the process terminates
+    while ( endProcData.pid != 0 )
+    {
+        // don't consume 100% of the CPU while we're sitting in this
+        // loop
+        if ( !CheckForRedirectedIO(execData) )
+            wxMilliSleep(1);
+
+        // give the toolkit a chance to call wxHandleProcessTermination() here
+        // and also repaint the GUI and handle other accumulated events
+        wxYield();
+    }
+
+    return endProcData.exitcode;
+}
+
+