lmi
[Top][All Lists]
Advanced

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

Re: [lmi] Overriding OnExit()


From: Vadim Zeitlin
Subject: Re: [lmi] Overriding OnExit()
Date: Wed, 20 Nov 2013 17:09:33 +0100

On Wed, 20 Nov 2013 15:12:58 +0000 Greg Chicares <address@hidden> wrote:

GC> Shouldn't wxApp::OnExit() be called from a derived class's override?

 Yes, it should.

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

 This is indeed the right thing to do.

GC> Now, having written that up, I thought this change was so obviously
GC> appropriate that I shouldn't waste your time by posing the question
GC> at all. However, this message seems to give a different answer:
GC> 
GC>   http://forums.wxwidgets.org/viewtopic.php?t=9838&p=44459
GC> 
GC> so perhaps I really should ask.

 No, I think the poster there is just confused. The code he refers to just
ensures that OnExit() is called, even if an exception is thrown, but
doesn't do anything special to call the base class version, it's just a
normal virtual function call, so if you override OnExit() it's still your
responsibility to call the base class version.

 Regards,
VZ

reply via email to

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