X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/de56f24082e4b66dada7bfe4033e1ef7328052ca..7b6fefbed1ef1cb879b72950d9f8fa35da128827:/src/common/docview.cpp diff --git a/src/common/docview.cpp b/src/common/docview.cpp index dbc0e56630..4d2d3c49e8 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