[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lmi] Untimely "save" dialog [Was: wxmsw-2.9.0 regression: crash whe
From: |
Greg Chicares |
Subject: |
Re: [lmi] Untimely "save" dialog [Was: wxmsw-2.9.0 regression: crash when a messagebox should appear] |
Date: |
Fri, 13 Mar 2009 20:03:48 +0000 |
User-agent: |
Thunderbird 2.0.0.19 (Windows/20081209) |
On 2009-03-09 20:23Z, Vadim Zeitlin wrote:
[...]
> Notice that an alternative could be to move Run() inside try/catch clause
> instead but it seems inconsistent to catch only some exceptions and not all
> of them, even if now (i.e. with my latest changes to wx) catching them or
> letting them escape shouldn't change the observable behaviour.
I'm not sure whether this is worth examining, but I'll just report it
and let you decide. I experimentally made a flawed change, and got a
crash. I'm still using snapshot 'wxWidgets-2009-03-12.tar.bz2', BTW.
Index: illustration_view.cpp
===================================================================
RCS file: /sources/lmi/lmi/illustration_view.cpp,v
retrieving revision 1.102
diff -U 3 -r1.102 illustration_view.cpp
--- illustration_view.cpp 6 Jan 2009 15:01:22 -0000 1.102
+++ illustration_view.cpp 13 Mar 2009 19:23:30 -0000
@@ -189,25 +189,34 @@
return ViewEx::OnCreate(doc, flags);
}
+retry:
try
{
if(wxID_OK != EditProperties())
{
return false;
}
+ if(!ViewEx::OnCreate(doc, flags))
+ {
+ return false;
+ }
+
+ Run();
}
catch(...)
{
report_exception();
- return false;
+ goto retry;
+// return false;
}
-
+#if 0
if(!ViewEx::OnCreate(doc, flags))
{
return false;
}
Run();
+#endif // 0
return true;
}
I say this is flawed because it calls OnCreate() repeatedly for the
same document. I believe I should instead refactor Run() into two
private functions, to be used here thus:
EditProperties();
ThePartOfRunThatDetectsInvalidInput(); // validate and calculate
OnCreate(...);
TheOtherPartOfRun(); // show calculation results in wxHtml
But in case you're striving to prevent a crash even in the abusive
case presented by the above patch, here's how to reproduce it:
File | New | Illustration
in "Extra policy fee" field, enter "0,1000" without quotes [invalid]
OK
OK to "Input validation problems" messagebox
[dialog appears anew]
in "Extra policy fee" field, enter "0" without quotes [that's valid]
OK
Now you see two views. Close either one. Say "No" when prompted to save
changes. Then it crashes.
I'll send full "Dr. MinGW" crash reports privately to save bandwidth.