Separated creation and initialisation of a document via its doc template.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27600 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2004-06-03 14:19:39 +00:00
parent 971562cb51
commit 217b71400f
3 changed files with 29 additions and 2 deletions

View File

@@ -691,18 +691,31 @@ wxDocument *wxDocTemplate::CreateDocument(const wxString& path, long flags)
if (!m_docClassInfo)
return (wxDocument *) NULL;
wxDocument *doc = (wxDocument *)m_docClassInfo->CreateObject();
if (InitDocument(doc, path, flags))
{
return doc;
}
else
{
return (wxDocument *) NULL;
}
}
bool wxDocTemplate::InitDocument(wxDocument* doc, const wxString& path, long flags)
{
doc->SetFilename(path);
doc->SetDocumentTemplate(this);
GetDocumentManager()->AddDocument(doc);
doc->SetCommandProcessor(doc->OnCreateCommandProcessor());
if (doc->OnCreate(path, flags))
return doc;
return true;
else
{
if (GetDocumentManager()->GetDocuments().Member(doc))
doc->DeleteAllViews();
return (wxDocument *) NULL;
return false;
}
}