]> Creatis software - bbtkGEditor.git/commitdiff
Bug #1355 The complete tab is not erased from memory. Only the objects are deleted...
authorcorredor <>
Thu, 24 May 2012 13:45:12 +0000 (13:45 +0000)
committercorredor <>
Thu, 24 May 2012 13:45:12 +0000 (13:45 +0000)
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxGEditorTabPanel.cxx
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.cxx
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.h
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx

index ab5c55fba7f909daa7f178dd16653fc291b78d42..682c1193ffecf282544166a111c9487815eac2db 100644 (file)
@@ -62,7 +62,7 @@ printf("EED wxGEditorTabPanel::wxGEditorTabPanel 1\n");
        //=========================================================================
        wxGEditorTabPanel::~wxGEditorTabPanel()
        {
-printf ("EED %p ~wxGEditorTabPanel()\n" , this );
+printf ("EED %p ~wxGEditorTabPanel() START \n" , this );
 //ED02JUIN2010         _sceneManager->disconnectDrop();
 
         _panelsManager->VerifyLastTabPanel();
@@ -70,6 +70,8 @@ printf ("EED %p ~wxGEditorTabPanel()\n" , this );
                delete _panelAUIMgr;
                delete _sceneManager;
 
+               printf ("EED %p ~wxGEditorTabPanel() END\n" , this );
+
        }
 
        //=========================================================================
index 32173e91c291423383f4302615c7f84e8202677e..14f85311b1bacc5f87e8e57b0a6c52b23827bb79 100644 (file)
@@ -48,6 +48,8 @@ namespace bbtk
                _notebook       = _parent->getAuiNotebook();
                addNewTab();
                _notebook->Connect(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED,wxAuiNotebookEventHandler(wxTabPanelsManager::OnTabChanged),0,this);
+               _notebook->Connect(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE,wxAuiNotebookEventHandler(wxTabPanelsManager::OnTabClose),0,this);
+
        }
 
        //=========================================================================
@@ -65,10 +67,16 @@ printf("EED wxTabPanelsManager::addNewTab 0\n");
                newPanel->setPanelsManager(this);
                _panels[_lastId]                    = newPanel;
                _actual                             = newPanel;
+
                _notebook->AddPage(newPanel, tabName  ,true);
+
 printf("EED wxTabPanelsManager::addNewTab 1\n");
        }
 
+
+
+
+
        //=========================================================================
        wxAuiNotebook* wxTabPanelsManager::getAuiNotebook()
        {
@@ -234,6 +242,37 @@ printf("wxTabPanelsManager::VerifyActualTabPanel  %d \n", this->_notebook->GetPa
        }
 
        //=========================================================================
+
+       void wxTabPanelsManager::OnTabClose(wxAuiNotebookEvent& event)
+       {
+
+               std::cout<<"RaC wxTabPanelsManager::OnTabClose Start... "<<_panels.size()<<std::endl;
+               int index = event.GetSelection();
+
+               if(_panels.size()>0)
+               {
+                       wxGEditorTabPanel* tab      = (wxGEditorTabPanel*)_notebook->GetPage(index);
+                       int id                      = tab->getPanelId();
+                       tab->deleteAllBoxes();
+                       _panels.erase(id);
+
+                       _notebook->RemovePage(index);
+
+                       std::cout<<"RaC wxTabPanelsManager::OnTabClose  IMPORTANT. The complete tab is not erased from memory... "<<std::endl;
+                       //////////////////////////////
+                       // TO FIX . RaC May 2012 - IMPORTANT. The complete tab is not erased from memory.
+                       // Only the objects are deleted and the tab is hidden
+                       // Execution problems when a tab is deleted using delete or DeletePage
+                       // delete tab;
+
+                       map<int, wxGEditorTabPanel*>::iterator it = _panels.begin() ;
+                       _actual=(*it).second;
+
+                       std::cout<<"RaC wxTabPanelsManager::OnTabClose End..."<< std::endl;
+               }
+       }
+
+       //=========================================================================
     std::string wxTabPanelsManager::GetCbName()
        {
            return _actual->GetCbName();
index 529699b9c851e2ee23ea51a1a551d70d884abe5f..a42f05edffd65d728e2bee6d16128e2816bc833b 100644 (file)
@@ -101,6 +101,10 @@ namespace bbtk
                int getNumActualSelectedObjects();
 
                void OnTabChanged(wxAuiNotebookEvent& event);
+
+               // Event handler. Runs in the moment of closing but not closed yet (for that exists the CLOSED event, but not working at all)
+               void OnTabClose(wxAuiNotebookEvent& event);
+
         void VerifyLastTabPanel();
 
         void SetCbName(std::string cbName);
index 192100b24a4544e00a3a20f38618f956fa461a25..cba9e89e5d37646d8d8481675f96038135bb42a7 100644 (file)
@@ -87,9 +87,10 @@ void wxVtkSceneManager::disconnectDrop() {
 
 wxVtkSceneManager::~wxVtkSceneManager() {
        //FCY memory leaks
-       printf("EED %p ~wxVtkSceneManager()\n", this);
+       printf("EED %p ~wxVtkSceneManager() START\n", this);
        disconnectDrop();
        delete _baseView;
+       printf("EED %p ~wxVtkSceneManager() END\n", this);
 }
 
 //=========================================================================