lmi
[Top][All Lists]
Advanced

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

Re: [lmi] wx-2.9.2: "bug in wxDatePickerCtrl: m_date not in sync"


From: Vadim Zeitlin
Subject: Re: [lmi] wx-2.9.2: "bug in wxDatePickerCtrl: m_date not in sync"
Date: Mon, 20 Jun 2011 16:09:17 +0200

On Sun, 19 Jun 2011 23:23:16 +0000 Greg Chicares <address@hidden> wrote:

GC> On 2011-06-19 22:47Z, Vadim Zeitlin wrote:
GC> > On Wed, 15 Jun 2011 21:41:21 +0000 Greg Chicares <address@hidden> wrote:
GC> > 
GC> > GC>   /opt/lmi/skeleton/bin[0]$./skeleton.exe --unit_test
GC> > 
GC> >  In any case, with these changes the test passes correctly for me. I 
notice
GC> > that it still exits with 127 code but I'm not sure whether this indicates
GC> > a real problem.
GC> 
GC> It's not a wx problem at all:
GC> 
GC> bool Skeleton::OnInitTryBlock()
GC> ...
GC>     if(run_unit_tests_and_exit_immediately_)
GC>         {
GC> ... [PLEASE SEE THE COMMENTS HERE]
GC>         return false;
GC>         }

 It is a wx problem, in fact, as our current wxApp interface doesn't
provide any simple and straightforward way to successfully exit the
application without running an event loop.

GC> but it does obstruct my hope of running this test automatically and
GC> capturing a useful indicator that it succeeded.

 There is a however a relatively simple, albeit not really straightforward,
way to do this: instead of returning false from OnInit() you can return
true from it and then simply immediately return from OnRun() instead of
entering the normal GUI event loop. In LMI case this is especially simple
to do as it already has the boolean variable that needs to be tested in
OnRun() (run_unit_tests_and_exit_immediately_) and it already overrides
OnRun(), too. So just this patch is enough to correct the problem:

diff --git a/main_wx.cpp b/main_wx.cpp
index 5e6693c..b562800 100644
--- a/main_wx.cpp
+++ b/main_wx.cpp
@@ -430,55 +430,23 @@ bool Skeleton::OnInitTryBlock()
     if(run_unit_tests_and_exit_immediately_)
         {
         MvcTest(frame_, 0).Test();
-        // The wx documentation for OnInit() says "Return true to
-        // continue processing, false to exit the application
-        // immediately." Then, however, upon exit, MinGW gdb displays
-        // this message:
-        //   warning: [timestamp]: Debug:
-        // In file ../../src/msw/app.cpp at line 447:
-        // 'UnregisterClass(no redraw MDI parent frame)' failed
-        // with error 0x00000584 (class still has open windows.).
-        //
-        // The wx documentation for OnExit() says "Note that it is not
-        // called at all if OnInit failed." Experimentally, try
-        // calling it explicitly, even though that seems weird.
-//        OnExit();
-        // That doesn't help: the same message is displayed.
-//        wxApp::OnExit();
-        // Same outcome again.
-        //
-        // This doesn't prevent that message either:
-//        ExitMainLoop();
-        // But the wx documentation for ExitMainLoop() says "You
-        // should normally exit the main loop (and the application)
-        // by deleting the top window.
-//        delete GetTopWindow();
-        // That does seem to work, but explicitly to delete a window
-        // managed by wx seems strange. And the wx documentation says
-        // "When deleting a frame or dialog, use Destroy rather than
-        // delete", so instead try:
-//        GetTopWindow()->Destroy();
-        // That seems to work as well. However, the wx documentation
-        // elsewhere suggests using Close() instead: "The advantage of
-        // using Close instead of Destroy is that it will call any
-        // clean-up code defined by the EVT_CLOSE handler; for example
-        // it may close a document contained in a window after first
-        // asking the user whether the work should be saved.
-        GetTopWindow()->Close();
-        // That seems to work as well, and seems best of all according
-        // to the wx documentation.
-
-        return false;
         }
-
-    wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED, wxID_ABOUT);
-    wxPostEvent(frame_, event);
+    else
+        {
+        wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED, wxID_ABOUT);
+        wxPostEvent(frame_, event);
+        }
 
     return true;
 }
 
 int Skeleton::OnRun()
 {
+    if(run_unit_tests_and_exit_immediately_)
+        {
+        return EXIT_SUCCESS;
+        }
+
     int result = EXIT_FAILURE;
     try
         {

 As you can see, deleting/destroying/closing the main window becomes
unnecessary as well because OnExit() will be called now and it does this
anyhow so it takes care of another problem as a side effect.

 Also, unlike the previous patch this one should be safe to apply to any wx
version (although I didn't test it with 2.8) so I may commit it to svn if
you'd like, please let me know if I should do it.

 Thanks,
VZ

reply via email to

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