]> Creatis software - bbtkGEditor.git/commitdiff
Bug #1688 RaC 2012 Bug to avoid opening twice the same diagram. Corrected and tested.
authorcorredor <>
Tue, 16 Oct 2012 08:40:18 +0000 (08:40 +0000)
committercorredor <>
Tue, 16 Oct 2012 08:40:18 +0000 (08:40 +0000)
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.cxx
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.h

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);
index 7c29eaefb1e94f887567146803e76d81cec6c4ba..fe453d791a001df2bc4b3f8fa63364a276387727 100644 (file)
@@ -305,6 +305,20 @@ printf("wxTabPanelsManager::VerifyActualTabPanel  %d \n", this->_notebook->GetPa
            //return ( (wxGEditorTabPanel) _notebook->GetPage(id)->GetFullPath( ) );
        }
 
+       //=========================================================================
+
+       int  wxTabPanelsManager::FindTab(std::string filename)
+       {
+               std::map<int, wxGEditorTabPanel*>::iterator it;
+               for (it = _panels.begin(); it != _panels.end(); ++it)
+               {
+                       wxGEditorTabPanel *obj = it->second;
+                       int id = it->first;
+                       if(obj->GetFullPath()==filename)
+                               return id;
+               }
+               return -1;
+       }
 
        //=========================================================================
     std::string wxTabPanelsManager::GetCbPackageName()
index c60e684ac914cf33092b74b737eefd6c01961cc6..432e215906d14582c6ecc08a6006fb268ccdf08e 100644 (file)
@@ -123,6 +123,7 @@ namespace bbtk
            void SetNameTabPanel(wxString tabpanelname);
                std::string GetNameTabPanel();
            std::string GetCurrentTabPanelPath( ); //DFCH
+           int  FindTab(std::string filename);