lmi
[Top][All Lists]
Advanced

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

[lmi] How can I suppress an error message from wx?


From: Greg Chicares
Subject: [lmi] How can I suppress an error message from wx?
Date: Sat, 14 Mar 2009 16:59:32 +0000
User-agent: Thunderbird 2.0.0.19 (Windows/20081209)

To test diagnostics in the 20090314T1609Z change to lmi HEAD, I apply
the first patch below [1] to simulate an error. When I start lmi and
press F1, I see:

| Unable to open
|     file://C:\opt\lmi\data\user_manual.html
| in default browser.
|
| The user...

The '...' ellipsis is copied literally: it doesn't signify any
abbreviation on my part. Clicking "Details" shows this in addition:

| Failed to open URL "C:\opt\lmi\data\user_manual.htmlx" in default browse
| Unable to open    file://C:\opt\lmi\data\user_manual.html in default brows

I can see a little more if I stretch the dialog box horizontally:

| Failed to open URL "C:\opt\lmi\data\user_manual.htmlx" in default browser. 
(error 2: the...
| Unable to open    file://C:\opt\lmi\data\user_manual.html in default browser. 
The user...

but stretching it further doesn't lengthen the abbreviated text.

I know I can see the unabbreviated text by clicking "Copy" and pasting
to an editor, but we cannot ask end users to do that.

The problem is that the two error messages (wx's and lmi's) collide,
so that both are displayed together in abbreviated form. I'd like to
suppress the wx message:

| Failed to open URL "C:\opt\lmi\data\user_manual.htmlx" in default browser. 
(error 2: the system cannot find the file specified.)

completely, and show only lmi's instead:

| Unable to open
|     file://C:\opt\lmi\data\user_manual.html
| in default browser.
|
| The user manual can be read online here:
|     http://lmi.nongnu.org/user_manual.html

I tried suppressing it in the second patch below [2], hoping that
  original = SetActiveTarget(0);
  wxFunctionThatDisplaysAnErrorMessage();
  FlushActive();
  SetActiveTarget(original);
would discard the wx message, but that didn't work. Neither did
an experiment with Suspend() and Resume(). What would work?

---------

[1] "the first patch below":

Index: main_wx.cpp
===================================================================
RCS file: /sources/lmi/lmi/main_wx.cpp,v
retrieving revision 1.130
diff -U 3 -r1.130 main_wx.cpp
--- main_wx.cpp 14 Mar 2009 16:09:17 -0000      1.130
+++ main_wx.cpp 14 Mar 2009 16:20:20 -0000
@@ -537,7 +537,7 @@
         s = canonical_url;
         }

-    if(!wxLaunchDefaultBrowser(s))
+    if(!wxLaunchDefaultBrowser(s + 'x')) // "+ 'x'": simulate an error.
         {
         warning()
             << "Unable to open"

[2] "the second patch below":

Index: main_wx.cpp
===================================================================
RCS file: /sources/lmi/lmi/main_wx.cpp,v
retrieving revision 1.130
diff -U 3 -r1.130 main_wx.cpp
--- main_wx.cpp 14 Mar 2009 16:09:17 -0000      1.130
+++ main_wx.cpp 14 Mar 2009 16:19:41 -0000
@@ -537,8 +537,11 @@
         s = canonical_url;
         }

-    if(!wxLaunchDefaultBrowser(s))
+wxLog* z = wxLog::SetActiveTarget(0);    // Try to inhibit wx error message.
+    if(!wxLaunchDefaultBrowser(s + 'x')) // "+ 'x'": simulate an error.
         {
+wxLog::FlushActive();                    // Try to discard wx error message.
+wxLog::SetActiveTarget(z);
         warning()
             << "Unable to open"
             << "\n    " << s
@@ -554,6 +557,7 @@
             }
         warning() << std::flush;
         }
+wxLog::SetActiveTarget(z);

     fenv_validate(e_fenv_indulge_0x027f);
 }




reply via email to

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