lmi
[Top][All Lists]
Advanced

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

[lmi] Inhibiting wxLog message buffering


From: Greg Chicares
Subject: [lmi] Inhibiting wxLog message buffering
Date: Wed, 08 Apr 2009 14:19:27 +0000
User-agent: Thunderbird 2.0.0.21 (Windows/20090302)

I strive to flush wxLog messages immediately, because our users are
unlikely to click "Details" when multiple warnings are presented in
a single messagebox. Here's a case where wxLog::FlushActive() doesn't
seem to have any effect with lmi HEAD as of 20090408T0126Z or later:

- Load lmi, using the (greppable) 'One password to rule them all'
- Test | Test floating point environment

After clicking through a few messages, this appears:
  Expect a messagebox complaining about '0x007f', and \
  'Resetting floating-point control word.' on statusbar.
Then I'd like the two following messages to be shown in separate
messageboxes:
  The floating-point control word was unexpectedly '0x007f'...
and
  Expect statusbar to be cleared.
However, they're shown together in the same messagebox. Is there an
elegant way to force each to appear in its own messagebox?

I've found a way that seems inelegant--see the first patch below [0].
The symptom seems to arise from logging a message inside a wxTimer
callback, and I can work around it by calling wxLog::FlushActive()
again after the main program regains control from the callback. This
seems fragile because I could easily forget to do so.

Another solution is given in the second patch below [1]: call
wxLog::FlushActive() both before and after displaying a warning()
message. That's better because I don't have to remember anything.
It still doesn't separate distinct warnings emitted inside a wxTimer
callback, but I can live with that.

Ideally, though, I'd like to flush every log message immediately. This
documentation:

  http://docs.wxwidgets.org/stable/wx_wxapp.html#wxappyield
| If you do wish to flush the log messages immediately
| (otherwise it will be done during the next idle loop
| iteration), call wxLog::FlushActive.

would seem to suggest that wxLog::FlushActive() should have that
effect--but it doesn't always. Is there a more general solution?
I do understand the rationale for message buffering:

  http://docs.wxwidgets.org/stable/wx_wxlog.html
| to avoid showing the user a zillion of modal message boxes

but in the particular case of lmi I never want buffering at all.

---------

[0] "the first patch below":

Index: main_wx.cpp
===================================================================
RCS file: /sources/lmi/lmi/main_wx.cpp,v
retrieving revision 1.137
diff -U 3 -r1.137 main_wx.cpp
--- main_wx.cpp 6 Apr 2009 18:44:26 -0000       1.137
+++ main_wx.cpp 8 Apr 2009 12:27:20 -0000
@@ -952,7 +952,9 @@
         ;
     x87_control_word(0x007f);
     wxMilliSleep(500); wxSafeYield();
-
+// Uncommenting this line causes the pending message (from UponTimer())
+// to be flushed separately from the following warning() message.
+//wxLog::FlushActive();
     warning() << "Expect statusbar to be cleared." << std::flush;
     status() << "" << std::flush;
     wxMilliSleep(500); wxSafeYield();
@@ -1076,6 +1078,13 @@
         if(!fenv_is_valid())
             {
             status() << "Resetting floating-point control word. " << 
std::flush;
+// These messages always appear together in the same messagebox:
+// they are not flushed separately despite FlushActive().
+// I don't really want to show multiple messages here; this serves
+// only to demonstrate that FlushActive() doesn't seem to flush
+// the log inside a timer callback.
+wxLogWarning("%s", "First warning" ); wxLog::FlushActive();
+wxLogWarning("%s", "Second warning"); wxLog::FlushActive();
             }
         fenv_validate(e_fenv_indulge_0x027f);
         }

[1] "the second patch below":

Index: alert_wx.cpp
===================================================================
RCS file: /sources/lmi/lmi/alert_wx.cpp,v
retrieving revision 1.24
diff -U 3 -r1.24 alert_wx.cpp
--- alert_wx.cpp        7 Apr 2009 17:17:26 -0000       1.24
+++ alert_wx.cpp        8 Apr 2009 12:41:08 -0000
@@ -80,6 +80,7 @@
 {
     if(dynamic_cast<wxLogGui*>(wxLog::GetActiveTarget()))
         {
+        wxLog::FlushActive();
         wxLogWarning("%s", s.c_str());
         wxLog::FlushActive();
         }




reply via email to

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