[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [5830] Yield to Cancel before calling wxExecute()
From: |
Greg Chicares |
Subject: |
[lmi-commits] [5830] Yield to Cancel before calling wxExecute() |
Date: |
Thu, 14 Nov 2013 14:31:38 +0000 |
Revision: 5830
http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=5830
Author: chicares
Date: 2013-11-14 14:31:37 +0000 (Thu, 14 Nov 2013)
Log Message:
-----------
Yield to Cancel before calling wxExecute()
Modified Paths:
--------------
lmi/trunk/ChangeLog
lmi/trunk/system_command_wx.cpp
Modified: lmi/trunk/ChangeLog
===================================================================
--- lmi/trunk/ChangeLog 2013-11-14 13:17:12 UTC (rev 5829)
+++ lmi/trunk/ChangeLog 2013-11-14 14:31:37 UTC (rev 5830)
@@ -32908,3 +32908,8 @@
Make do_dawdle() message generic. It's not necessarily only for
printing.
+20131114T1431Z <address@hidden> [542]
+
+ system_command_wx.cpp
+Yield to Cancel before calling wxExecute().
+
Modified: lmi/trunk/system_command_wx.cpp
===================================================================
--- lmi/trunk/system_command_wx.cpp 2013-11-14 13:17:12 UTC (rev 5829)
+++ lmi/trunk/system_command_wx.cpp 2013-11-14 14:31:37 UTC (rev 5830)
@@ -32,11 +32,12 @@
#include "null_stream.hpp"
#include "timer.hpp"
-#include <wx/app.h> // wxTheApp
+#include <wx/app.h> // wxTheApp
+#include <wx/evtloop.h> // class wxEventLoopBase
#include <wx/frame.h>
#include <wx/utils.h>
-#include <cstddef> // std::size_t
+#include <cstddef> // std::size_t
#include <ostream>
namespace
@@ -74,6 +75,11 @@
/// exit code and the command itself.
///
/// Show elapsed time on statusbar iff statusbar is available.
+///
+/// Before calling wxExecute(), yield for UI events so that Cancel is
+/// recognized when this function is called from a wxProgressDialog
+/// loop. See the discussion thread starting here:
+/// http://lists.nongnu.org/archive/html/lmi/2013-11/msg00009.html
void concrete_system_command(std::string const& command_line)
{
@@ -85,13 +91,12 @@
&& dynamic_cast<wxFrame*>(wxTheApp->GetTopWindow())
&& dynamic_cast<wxFrame*>(wxTheApp->GetTopWindow())->GetStatusBar()
;
- std::ostream& statusbar_if_available =
- b
- ? status()
- : null_stream()
- ;
+ std::ostream& statusbar_if_available = b ? status() : null_stream();
+ statusbar_if_available << "Running..." << std::flush;
- statusbar_if_available << "Running..." << std::flush;
+ wxEventLoopBase* e = wxEventLoopBase::GetActive();
+ e && e->YieldFor(wxEVT_CATEGORY_UI);
+
wxArrayString output;
wxArrayString errors;
long int exit_code = wxExecute(command_line, output, errors);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [lmi-commits] [5830] Yield to Cancel before calling wxExecute(),
Greg Chicares <=