Salome HOME
python_test_driver.py declination of salome_test_driver.py for SSL mode (timeout...
[modules/kernel.git] / src / GenericObj / SALOME_GenericObj_i.cc
index bdb830cc75c8332c1fb433ac1455ecc7daec249b..508de67f3c6ced702c50663f2c5e4616964fa7c3 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2021  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -6,7 +6,7 @@
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
 #include "SALOME_GenericObj_i.hh"
 #include "utilities.h"
 
+#include <iostream>
+#include <typeinfo>
+
+// note: in KERNEL _DEBUG_ is not defined by default
 #ifdef _DEBUG_
 static int MYDEBUG = 0;
 #else
 static int MYDEBUG = 0;
 #endif
 
+//#define IS_OBJ_IN_QUESTION(where) is_obj_in_question(this, myRefCounter, where)
+#define IS_OBJ_IN_QUESTION(where)
+
 namespace SALOME
 {
+  void is_obj_in_question( const GenericObj_i* o, int myRefCounter,const char* where)
+  {
+    if ( std::string( typeid(*o).name() ).find("SALOMEDS") != std::string::npos )
+      return;
+    // if ( std::string( typeid(*o).name() ).find("SMESH_") != std::string::npos ||
+    //      std::string( typeid(*o).name() ).find("StdMesher") != std::string::npos )
+    {
+      std::cout<< typeid(*o).name() << " " << o << " " << where << "  myRefCounter ==> " << myRefCounter;
+      if ( myRefCounter == 0 ) std::cout << " DELETE !";
+      std::cout << std::endl;
+    }
+  }
 
   /*!
     \class SALOME::GenericObj_i
@@ -73,6 +92,8 @@ namespace SALOME
     else {
       myPOA = PortableServer::POA::_duplicate(thePOA);
     }
+    if(MYDEBUG)
+      MESSAGE("GenericObj_i::GenericObj_i thePOA: " << thePOA << " myPOA: " << myPOA);
   }
 
   /*!
@@ -85,6 +106,7 @@ namespace SALOME
   */
   PortableServer::POA_ptr GenericObj_i::_default_POA()
   {
+    MESSAGE("GenericObj_i::_default_POA: " << myPOA);
     return PortableServer::POA::_duplicate(myPOA);
   }
 
@@ -96,6 +118,7 @@ namespace SALOME
     if(MYDEBUG)
       MESSAGE("GenericObj_i::Register "<<this<<"; myRefCounter = "<<myRefCounter);
     ++myRefCounter;
+    IS_OBJ_IN_QUESTION( "Register" );
   }
 
   /*!
@@ -108,7 +131,9 @@ namespace SALOME
   {
     if(MYDEBUG)
       MESSAGE("GenericObj_i::UnRegister "<<this<<"; myRefCounter = "<<myRefCounter);
-    if(--myRefCounter <= 0){
+    --myRefCounter;
+    IS_OBJ_IN_QUESTION( "UnRegister" );
+    if(myRefCounter <= 0){
       PortableServer::ObjectId_var anObjectId = myPOA->servant_to_id(this);
       myPOA->deactivate_object(anObjectId.in());
       _remove_ref();
@@ -125,4 +150,4 @@ namespace SALOME
     UnRegister();
   }
 
-}; // end of namespace SALOME
+} // end of namespace SALOME