]> Creatis software - bbtkGEditor.git/blobdiff - lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx
Bug #1688 RaC 2012 Bug to avoid opening twice the same diagram. Corrected and tested.
[bbtkGEditor.git] / lib / EditorGraphicBBS / bbsWxGUIEditorGraphic / bbtkwxGUIEditorGraphicBBS.cxx
index a26f9ddf12a32ba145b9b6f468d54cae00dd5c61..e7a93620d5d2595955f55a1ad5f0c3eff37b481b 100644 (file)
@@ -980,13 +980,21 @@ void wxGUIEditorGraphicBBS::OnOpenDiagram(wxCommandEvent& event) {
                        wxEmptyString, wxT(""), wxT("*.bbg"), wxOPEN | wxFILE_MUST_EXIST);
        printf("SCP: wxGUIEditorGraphicBBS::OnOpenDiagram  \n");
        if (openFileDialog->ShowModal() == wxID_OK) {
-               wxString fileName = openFileDialog->GetPath();
+               wxString filePath = openFileDialog->GetPath();
                ifstream inputStream;
-               std::string fName = (const char*) (fileName.mb_str());
+               std::string fName = (const char*) (filePath.mb_str());
 
                inputStream.open(fName.c_str());
                assert(inputStream.good()); // fails
-               _tabsMgr->addNewTab(openFileDialog->GetFilename());
+
+               if(_tabsMgr->FindTab(crea::wx2std(filePath))!=-1) //RaC2012 avoid opening same diagram twice
+               {
+                       inputStream.close();
+                       printf("RaC: Diagram already opened\n");
+                       return;
+               }
+               wxString fileName = openFileDialog->GetFilename();
+               _tabsMgr->addNewTab(fileName);
                _tabsMgr->loadDiagram(inputStream, fName);
                _tabsMgr->saveTempActualDiagram("load diagram");
                GetToolBar()->EnableTool(ID_UNDO, false);