/**
         Called when the filename has changed. The default implementation
-        constructs a suitable title and sets the title of the view frame (if
-        any).
+        constructs a suitable title and sets the title of the view frame (if any).
     */
     virtual void OnChangeFilename();
 
     /**
         Sets the filename for this document. Usually called by the framework.
 
+        Calls OnChangeFilename() which in turn calls wxView::OnChangeFilename() for
+        all views if @a notifyViews is @true,
+    */
+    void SetFilename(const wxString& filename, bool notifyViews = false);
+
+    /**
         If @a notifyViews is @true, wxView::OnChangeFilename() is called for
         all views.
+
+        @since 2.9.0
     */
-    void SetFilename(const wxString& filename, bool notifyViews = false);
+    virtual void OnChangeFilename(bool notifyViews);
 
     /**
         Sets the title for this document. The document title is used for an
 
     if (defaultDir.IsEmpty())
         defaultDir = wxPathOnly(GetFilename());
 
-    wxString tmp = wxFileSelector(_("Save As"),
+    wxString fileName = wxFileSelector(_("Save As"),
             defaultDir,
             wxFileNameFromPath(GetFilename()),
             docTemplate->GetDefaultExtension(),
             wxFD_SAVE | wxFD_OVERWRITE_PROMPT,
             GetDocumentWindow());
 
-    if (tmp.empty())
+    if (fileName.empty())
         return false;
 
-    wxString fileName(tmp);
-    wxString path, name, ext;
-    wxFileName::SplitPath(fileName, & path, & name, & ext);
+    wxString ext;
+    wxFileName::SplitPath(fileName, NULL, NULL, &ext);
 
     if (ext.empty())
     {
         fileName += docTemplate->GetDefaultExtension();
     }
 
-    SetFilename(fileName);
-    SetTitle(wxFileNameFromPath(fileName));
-
-    // Notify the views that the filename has changed
-    wxList::compatibility_iterator node = m_documentViews.GetFirst();
-    while (node)
-    {
-        wxView *view = (wxView *)node->GetData();
-        view->OnChangeFilename();
-        node = node->GetNext();
-    }
-
     // Files that were not saved correctly are not added to the FileHistory.
-    if (!OnSaveDocument(m_documentFile))
+    if (!OnSaveDocument(fileName))
         return false;
 
+    SetTitle(wxFileNameFromPath(fileName));
+    SetFilename(fileName, true);    // will call OnChangeFileName automatically
+
    // A file that doesn't use the default extension of its document template cannot be opened
    // via the FileHistory, so we do not add it.
    if (docTemplate->FileMatchesTemplate(fileName))
                      GetUserReadableName()
                     ),
                     wxTheApp->GetAppDisplayName(),
-                    wxYES_NO | wxCANCEL | wxICON_QUESTION,
-                    GetDocumentWindow()
+                    wxYES_NO | wxCANCEL | wxICON_QUESTION | wxCENTRE,
+                    wxFindSuitableParent()
                  ) )
         {
             case wxNO:
 void wxDocument::SetFilename(const wxString& filename, bool notifyViews)
 {
     m_documentFile = filename;
+    OnChangeFilename(notifyViews);
+}
+
+void wxDocument::OnChangeFilename(bool notifyViews)
+{
     if ( notifyViews )
     {
         // Notify the views that the filename has changed
             else
                 msgTitle = wxString(_("File error"));
 
-            (void)wxMessageBox(_("Sorry, could not open this file."), msgTitle, wxOK | wxICON_EXCLAMATION,
+            (void)wxMessageBox(_("Sorry, could not open this file."), msgTitle, wxOK | wxICON_EXCLAMATION | wxCENTRE,
                 parent);
 
             path = wxEmptyString;
             // can only happen if the application changes the allowed templates in runtime.
             (void)wxMessageBox(_("Sorry, the format for this file is unknown."),
                                 _("Open File"),
-                                wxOK | wxICON_EXCLAMATION, wxFindSuitableParent());
+                                wxOK | wxICON_EXCLAMATION | wxCENTRE, wxFindSuitableParent());
         }
     }
     else