]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/docview.cpp
Add missing WXK constants for the control keys
[wxWidgets.git] / src / common / docview.cpp
index 5df20303415862c9abaf33c29b9518b869c96a3d..8ed6b129aaf1deb94fd699058af14ef691ef78c4 100644 (file)
@@ -60,6 +60,7 @@
 #include "wx/vector.h"
 #include "wx/scopedarray.h"
 #include "wx/scopedptr.h"
 #include "wx/vector.h"
 #include "wx/scopedarray.h"
 #include "wx/scopedptr.h"
+#include "wx/scopeguard.h"
 #include "wx/except.h"
 
 #if wxUSE_STD_IOSTREAM
 #include "wx/except.h"
 
 #if wxUSE_STD_IOSTREAM
@@ -859,17 +860,19 @@ wxDocument *wxDocTemplate::CreateDocument(const wxString& path, long flags)
 bool
 wxDocTemplate::InitDocument(wxDocument* doc, const wxString& path, long flags)
 {
 bool
 wxDocTemplate::InitDocument(wxDocument* doc, const wxString& path, long flags)
 {
+    wxScopeGuard g = wxMakeObjGuard(*doc, &wxDocument::DeleteAllViews);
+
     doc->SetFilename(path);
     doc->SetDocumentTemplate(this);
     GetDocumentManager()->AddDocument(doc);
     doc->SetCommandProcessor(doc->OnCreateCommandProcessor());
 
     doc->SetFilename(path);
     doc->SetDocumentTemplate(this);
     GetDocumentManager()->AddDocument(doc);
     doc->SetCommandProcessor(doc->OnCreateCommandProcessor());
 
-    if (doc->OnCreate(path, flags))
-        return true;
+    if ( !doc->OnCreate(path, flags) )
+        return false;
 
 
-    if (GetDocumentManager()->GetDocuments().Member(doc))
-        doc->DeleteAllViews();
-    return false;
+    g.Dismiss(); // no need to call DeleteAllViews() anymore
+
+    return true;
 }
 
 wxView *wxDocTemplate::CreateView(wxDocument *doc, long flags)
 }
 
 wxView *wxDocTemplate::CreateView(wxDocument *doc, long flags)
@@ -1414,7 +1417,7 @@ void wxDocManager::ActivateDocument(wxDocument *doc)
 
     view->Activate(true);
     if ( wxWindow *win = view->GetFrame() )
 
     view->Activate(true);
     if ( wxWindow *win = view->GetFrame() )
-        win->SetFocus();
+        win->Raise();
 }
 
 wxDocument *wxDocManager::CreateDocument(const wxString& pathOrig, long flags)
 }
 
 wxDocument *wxDocManager::CreateDocument(const wxString& pathOrig, long flags)