- if (m_documentTitle != wxT(""))
- {
- buf = m_documentTitle;
- return TRUE;
- }
- else if (m_documentFile != wxT(""))
- {
- buf = wxFileNameFromPath(m_documentFile);
- return TRUE;
- }
- else
- {
- buf = _("unnamed");
- return TRUE;
- }
+ // this function can not only be overridden by the user code but also
+ // called by it so we need to ensure that we return the same thing as
+ // GetUserReadableName() but we can't call it because this would result in
+ // an infinite recursion, hence we use the helper DoGetUserReadableName()
+ buf = DoGetUserReadableName();
+
+ return true;
+}
+#endif // WXWIN_COMPATIBILITY_2_8
+
+wxString wxDocument::GetUserReadableName() const
+{
+#if WXWIN_COMPATIBILITY_2_8
+ // we need to call the old virtual function to ensure that the overridden
+ // version of it is still called
+ wxString name;
+ if ( GetPrintableName(name) )
+ return name;
+#endif // WXWIN_COMPATIBILITY_2_8
+
+ return DoGetUserReadableName();
+}
+
+wxString wxDocument::DoGetUserReadableName() const
+{
+ if ( !m_documentTitle.empty() )
+ return m_documentTitle;
+
+ if ( !m_documentFile.empty() )
+ return wxFileNameFromPath(m_documentFile);
+
+ return _("unnamed");