From 7047d7981f42dd0921485819ace49bd79718902b Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 30 Dec 2008 16:36:39 +0000 Subject: [PATCH] handle exceptions thrown from overridden wxView::OnCreate() gracefully git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57671 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + src/common/docview.cpp | 16 ++++++---------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 680a4bd..746013b 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -324,6 +324,7 @@ All: - Added wxArray::swap(). - Added wxSHUTDOWN_LOGOFF and wxSHUTDOWN_FORCE wxShutdown() flags (troelsk). - Added wxSocket::ShutdownOutput(). +- Handle exceptions thrown from overridden wxView::OnCreate() gracefully. All (Unix): diff --git a/src/common/docview.cpp b/src/common/docview.cpp index dbc0e56..4d2d3c4 100644 --- a/src/common/docview.cpp +++ b/src/common/docview.cpp @@ -57,6 +57,7 @@ #include "wx/tokenzr.h" #include "wx/filename.h" #include "wx/vector.h" +#include "wx/ptr_scpd.h" #if wxUSE_STD_IOSTREAM #include "wx/ioswrap.h" @@ -779,20 +780,15 @@ wxDocTemplate::InitDocument(wxDocument* doc, const wxString& path, long flags) wxView *wxDocTemplate::CreateView(wxDocument *doc, long flags) { - wxView *view = DoCreateView(); - if ( view == NULL ) + wxScopedPtr view(DoCreateView()); + if ( !view ) return NULL; view->SetDocument(doc); - if (view->OnCreate(doc, flags)) - { - return view; - } - else - { - delete view; + if ( !view->OnCreate(doc, flags) ) return NULL; - } + + return view.release(); } // The default (very primitive) format detection: check is the extension is -- 2.7.4