lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi] wxProgressDialog resists interruption with Cancel


From: Greg Chicares
Subject: [lmi] wxProgressDialog resists interruption with Cancel
Date: Wed, 13 Nov 2013 20:35:00 +0000
User-agent: Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130801 Thunderbird/17.0.8

With lmi HEAD revision 5827, a progress dialog cannot be interrupted
in this situation:
  File | Open [any census with several cells]
  Census | Print case to disk
For example: using a census with five cells, I issue the command above;
immediately, while the progress dialog still says "Completed 0 of 5",
I press the Cancel key and hold it down; but the process continues
uninterrupted until normal completion, even though I'm still holding the
Cancel key down. That would be unwelcome with a thousand-life census.

This is reproducible with a May 2013 release, so recent changes are not
the cause. Only "Print case to disk" has this problem; other commands
that use a progress dialog do not.

What's so special about this command? My guess is that it uses
wxExecute() to run a command line like this:
  CMD /c C:/path/to/fop -fo file1 -pdf file2
and wx doesn't detect the Cancel event due to the external process.

Inserting this code from 'wx/src/generic/progdlgg.cpp':
  wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI);
into the main loop that uses the progress dialog didn't help much.
Inserting it into the code that calls wxExecute() (patch below[0])
is much more effective: I can break out of the loop with a single
press of the Cancel key, as long as I press it when the busy cursor
is not displayed. Questions:

- Is there any hidden danger in this patch? (I suspect not, based
on our earlier discussion.)

- Is there a better way to do this? (A commented-out line in the
patch shows an unsuccessful SafeYieldFor() idea that I tried.)

---------

[0] "patch below":

Index: system_command_wx.cpp
===================================================================
--- system_command_wx.cpp       (revision 5768)
+++ system_command_wx.cpp       (working copy)
@@ -33,6 +33,7 @@
 #include "timer.hpp"

 #include <wx/app.h> // wxTheApp
+#include <wx/evtloop.h>
 #include <wx/frame.h>
 #include <wx/utils.h>

@@ -77,6 +78,8 @@

 void concrete_system_command(std::string const& command_line)
 {
+    wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI);
+//    wxTheApp->SafeYieldFor(NULL, wxEVT_CATEGORY_UI); // <-- This alternative 
doesn't work.
     Timer timer;
     wxBusyCursor wait;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]