lmi
[Top][All Lists]
Advanced

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

[lmi] Overriding OnExit()


From: Greg Chicares
Subject: [lmi] Overriding OnExit()
Date: Wed, 20 Nov 2013 15:12:58 +0000
User-agent: Mozilla/5.0 (Windows NT 5.1; rv:24.0) Gecko/20100101 Thunderbird/24.1.0

Shouldn't wxApp::OnExit() be called from a derived class's override?
In particular, in lmi HEAD today:

  
http://svn.savannah.nongnu.org/viewvc/lmi/trunk/main_wx.cpp?annotate=5802&root=lmi

610 : int Skeleton::OnExit()
611 : {
612 :     doc_manager_->FileHistorySave(*config_);
613 :     delete doc_manager_;
614 :     delete config_;
615 :     return 0;
616 : }
617 :

Instead of my line 614 above, wxAppConsoleBase::OnExit() does this:
    // delete the config object if any (don't use Get() here, but Set()
    // because Get() could create a new config object)
    delete wxConfigBase::Set(NULL);
and my less careful line 614 could cause a problem if my upstream
initialization:
    config_ = wxConfigBase::Get();
failed. And, of course, calling the base class version secures the
advantages of any future wx enhancements. So I think I should make
this change:

Index: main_wx.cpp
===================================================================
--- main_wx.cpp (revision 5802)
+++ main_wx.cpp (working copy)
@@ -611,8 +611,7 @@
 {
     doc_manager_->FileHistorySave(*config_);
     delete doc_manager_;
-    delete config_;
-    return 0;
+    return wxApp::OnExit(); // Deletes config_.
 }

Now, having written that up, I thought this change was so obviously
appropriate that I shouldn't waste your time by posing the question
at all. However, this message seems to give a different answer:

  http://forums.wxwidgets.org/viewtopic.php?t=9838&p=44459

so perhaps I really should ask.



reply via email to

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