From 6489e7ee028debbcdb8aae980b503fce7482538b Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Wed, 30 Mar 2005 16:35:07 +0000 Subject: [PATCH] Applied patch [ 1163322 ] Patch to prevent MDI app from opening the same file twice git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@33185 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/docview.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/common/docview.cpp b/src/common/docview.cpp index 850a940..9946ac2 100644 --- a/src/common/docview.cpp +++ b/src/common/docview.cpp @@ -1288,6 +1288,28 @@ wxDocument *wxDocManager::CreateDocument(const wxString& path, long flags) } } + //see if this file is already open + for (size_t i = 0; i < GetDocuments().GetCount(); ++i) + { + wxDocument* currentDoc = (wxDocument*)(GetDocuments().Item(i)->GetData()); +#ifdef __WXMSW__ + //file paths are case-insensitive on Windows + if (path2.CmpNoCase(currentDoc->GetFilename()) == 0) +#else + if (path2.Cmp(currentDoc->GetFilename()) == 0) +#endif + { + //file already open. Just activate it and return + if (currentDoc->GetFirstView()) + { + ActivateView(currentDoc->GetFirstView(), true); + if (currentDoc->GetDocumentWindow()) + currentDoc->GetDocumentWindow()->SetFocus(); + return currentDoc; + } + } + } + wxDocument *newDoc = temp->CreateDocument(path2, flags); if (newDoc) { -- 2.7.4