Salome HOME
21948: EDF SMESH : Memory is not freed when deleting a mesh
authoreap <eap@opencascade.com>
Fri, 14 Dec 2012 10:36:00 +0000 (10:36 +0000)
committereap <eap@opencascade.com>
Fri, 14 Dec 2012 10:36:00 +0000 (10:36 +0000)
  Remove dependency on CORBA

+  SALOMEDSImpl_AbstractCallback* _genObjRegister;

+  static void RegisterGenObj  (const std::string& theIOR, DF_Label label);
+  static void UnRegisterGenObj(const std::string& theIOR, DF_Label label);
+  void setGenObjRegister(SALOMEDSImpl_AbstractCallback* theRegister);

src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx
src/SALOMEDSImpl/SALOMEDSImpl_Study.hxx

index f98ca5e055e034601fd930888739c05068b46e67..ddd38c5cfb53583e27a8f035f491241cf72a984e 100644 (file)
@@ -73,6 +73,7 @@ SALOMEDSImpl_Study::SALOMEDSImpl_Study(const DF_Document* doc,
   _builder = new SALOMEDSImpl_StudyBuilder(this);
   _cb = new SALOMEDSImpl_Callback(_useCaseBuilder);
   _notifier=0;
+  _genObjRegister=0;
   //Put on the root label a StudyHandle attribute to store the address of this object
   //It will be used to retrieve the study object by DF_Label that belongs to the study
   SALOMEDSImpl_StudyHandle::Set(_doc->Main().Root(), this);
@@ -296,7 +297,7 @@ SALOMEDSImpl_SObject SALOMEDSImpl_Study::CreateObjectID(const std::string& anObj
  */
 //============================================================================
 std::vector<SALOMEDSImpl_SObject> SALOMEDSImpl_Study::FindObjectByName(const std::string& anObjectName,
-                                                                      const std::string& aComponentName)
+                                                                       const std::string& aComponentName)
 {
   _errorCode = "";
 
@@ -825,8 +826,8 @@ void SALOMEDSImpl_Study::URL(const std::string& url)
  */
 //============================================================================
 SALOMEDSImpl_SObject SALOMEDSImpl_Study::_FindObject(const SALOMEDSImpl_SObject& SO,
-                                                    const std::string& theObjectName,
-                                                    bool& _find)
+                                                     const std::string& theObjectName,
+                                                     bool& _find)
 {
   SALOMEDSImpl_SObject RefSO;
   if(!SO) return RefSO;
@@ -1093,6 +1094,7 @@ SALOMEDSImpl_UseCaseBuilder* SALOMEDSImpl_Study::GetUseCaseBuilder()
 void SALOMEDSImpl_Study::Close()
 {
   _errorCode = "";
+  _notifier = 0;
   _doc->GetApplication()->Close(_doc);
   _doc = NULL;
   _mapOfSO.clear();
@@ -1371,9 +1373,9 @@ bool SALOMEDSImpl_Study::DumpStudy(const std::string& thePath,
 #endif
       
       if(!isOpened) {
-       _errorCode = std::string("Can't create a file ")+aFileName;
-       SALOMEDSImpl_Tool::RemoveTemporaryFiles(thePath, aSeqOfFileNames, false);
-       return false;
+        _errorCode = std::string("Can't create a file ")+aFileName;
+        SALOMEDSImpl_Tool::RemoveTemporaryFiles(thePath, aSeqOfFileNames, false);
+        return false;
       }
      
       // replace '\t' symbols
@@ -1680,8 +1682,8 @@ void SALOMEDSImpl_Study::SetVariable(const std::string& theVarName,
  */
 //============================================================================
 void SALOMEDSImpl_Study::SetStringVariable(const std::string& theVarName,
-                                          const std::string& theValue,
-                                          const SALOMEDSImpl_GenericVariable::VariableTypes theType)
+                                           const std::string& theValue,
+                                           const SALOMEDSImpl_GenericVariable::VariableTypes theType)
 {
   bool modified = false;
   SALOMEDSImpl_GenericVariable* aGVar = GetVariable(theVarName);
@@ -1710,8 +1712,8 @@ void SALOMEDSImpl_Study::SetStringVariable(const std::string& theVarName,
  */
 //============================================================================
 void SALOMEDSImpl_Study::SetStringVariableAsDouble(const std::string& theVarName,
-                                                  const double theValue,
-                                                  const SALOMEDSImpl_GenericVariable::VariableTypes theType)
+                                                   const double theValue,
+                                                   const SALOMEDSImpl_GenericVariable::VariableTypes theType)
 {
   SALOMEDSImpl_GenericVariable* aGVar = GetVariable(theVarName);
   if(SALOMEDSImpl_ScalarVariable* aSVar = dynamic_cast<SALOMEDSImpl_ScalarVariable*>(aGVar))
@@ -2099,3 +2101,46 @@ void SALOMEDSImpl_Study::setNotifier(SALOMEDSImpl_AbstractCallback* notifier)
 {
   _notifier=notifier;
 }
+
+static SALOMEDSImpl_AbstractCallback* & getGenObjRegister( DF_Document* doc )
+{
+  static std::vector< SALOMEDSImpl_AbstractCallback* > _genObjRegVec;
+  if ( doc->GetDocumentID() >= (int)_genObjRegVec.size() )
+    _genObjRegVec.resize( doc->GetDocumentID() + 1, 0 );
+  return _genObjRegVec[ doc->GetDocumentID() ];
+}
+
+//================================================================================
+/*!
+ * \brief Stores theRegister
+ */
+//================================================================================
+
+void SALOMEDSImpl_Study::setGenObjRegister(SALOMEDSImpl_AbstractCallback* theRegister)
+{
+  getGenObjRegister( _doc ) = theRegister;
+}
+
+//================================================================================
+/*!
+ * \brief Indirectly invokes GenericObj_i::Register()
+ */
+//================================================================================
+
+void SALOMEDSImpl_Study::RegisterGenObj  (const std::string& theIOR, DF_Label label)
+{
+  if ( SALOMEDSImpl_AbstractCallback* goRegister = getGenObjRegister( label.GetDocument() ))
+    goRegister->RegisterGenObj( theIOR );
+}
+
+//================================================================================
+/*!
+ * \brief Indirectly invokes GenericObj_i::UnRegister()
+ */
+//================================================================================
+
+void SALOMEDSImpl_Study::UnRegisterGenObj(const std::string& theIOR, DF_Label label)
+{
+  if ( SALOMEDSImpl_AbstractCallback* goRegister = getGenObjRegister( label.GetDocument() ))
+    goRegister->UnRegisterGenObj( theIOR );
+}
index c53db253e8a5e177f1b6b11b29477382beed1a2d..6063a98292a4ee8999254ea310a87be6d552313f 100644 (file)
@@ -70,7 +70,8 @@ private:
   SALOMEDSImpl_Callback*   _cb;
   SALOMEDSImpl_StudyBuilder*   _builder;
   SALOMEDSImpl_UseCaseBuilder* _useCaseBuilder;
-  SALOMEDSImpl_AbstractCallback*   _notifier;
+  SALOMEDSImpl_AbstractCallback* _notifier;
+  SALOMEDSImpl_AbstractCallback* _genObjRegister;
 
   std::map<std::string, SALOMEDSImpl_SObject> _mapOfSO;
   std::map<std::string, SALOMEDSImpl_SComponent> _mapOfSCO;
@@ -321,6 +322,9 @@ public:
   virtual bool modifySO_Notification(const SALOMEDSImpl_SObject& theSObject, int reason);
   virtual void setNotifier(SALOMEDSImpl_AbstractCallback* notifier);
 
+  static void RegisterGenObj  (const std::string& theIOR, DF_Label label);
+  static void UnRegisterGenObj(const std::string& theIOR, DF_Label label);
+  void setGenObjRegister(SALOMEDSImpl_AbstractCallback* theRegister);
 
   friend class SALOMEDSImpl_StudyManager;    
   friend class SALOMEDSImpl_GenericAttribute;