Salome HOME
Merge branch 'master' of ssh://git.salome-platform.org/modules/gui
[modules/gui.git] / src / Session / SALOME_Session_Server.cxx
index 42770dbfca724eb6ff84b328ac8365236e603a45..c8b52cf4f4c4b7204bd83da04392f17d8ec3561e 100755 (executable)
@@ -68,6 +68,8 @@
 #include CORBA_SERVER_HEADER(SALOME_Session)
 #include CORBA_SERVER_HEADER(SALOMEDS)
 
+#include <time.h>
+
 #include <QDir>
 #include <QFile>
 #include <QApplication>
@@ -204,36 +206,10 @@ protected:
       // for backward compatibility we also check files prepended with "." with lower priority
       QRegExp exp( QString( "\\.?%1rc\\.([a-zA-Z0-9.]+)" ).arg( myExtAppName ) );
 #endif
-      QRegExp vers_exp( "^([0-9]+)([A-Z]|RC)?([0-9]*)", Qt::CaseInsensitive );
-      
       QString fname = QFileInfo( _fname ).fileName();
-      if( exp.exactMatch( fname ) ) {
-          QStringList vers = exp.cap( 1 ).split( ".", QString::SkipEmptyParts );
-          int major=0, minor=0;
-          int release = 0, dev1 = 0, dev2 = 0;
-          if ( vers.count() > 0 ) major = vers[0].toInt();
-          if ( vers.count() > 1 ) minor = vers[1].toInt();
-          if ( vers.count() > 2 ) {
-              if ( vers_exp.indexIn( vers[2] ) != -1 ) {
-                  release = vers_exp.cap( 1 ).toInt();
-                  QString tag = vers_exp.cap( 2 ).toLower();
-                  if ( !tag.isEmpty() ) {
-                      if ( tag == "rc" ) // release candidate
-                        dev1 = 49;       // 'rc'=49
-                      else               // a, b, c, ...
-                        dev1 = (int)( tag[ 0 ].toLatin1() ) - (int)( QChar('a').toLatin1() ) + 1; // 'a'=1, 'b'=2, ..., 'z'=26
-                  }
-                  if ( !vers_exp.cap( 3 ).isEmpty() )
-                    dev2 = vers_exp.cap( 3 ).toInt();
-              }
-          }
-
-          int dev = dev1*100+dev2;
-          id = major;
-          id*=100; id+=minor;
-          id*=100; id+=release;
-          id*=10000;
-          if ( dev > 0 ) id-=dev;
+      if ( exp.exactMatch( fname ) ) {
+       long fid = Qtx::versionToId( exp.cap( 1 ) );
+       if ( fid > 0 ) id = fid;
       }
     }
     return id;
@@ -285,19 +261,6 @@ public:
 
   virtual bool notify( QObject* receiver, QEvent* e )
   {
-#if OCC_VERSION_LARGE < 0x06010100
-    // Disable GUI user actions while python command is executed
-    if (SUIT_Session::IsPythonExecuted()) {
-      // Disable mouse and keyboard events
-      QEvent::Type aType = e->type();
-      if (aType == QEvent::MouseButtonPress || aType == QEvent::MouseButtonRelease ||
-          aType == QEvent::MouseButtonDblClick || aType == QEvent::MouseMove ||
-          aType == QEvent::Wheel || aType == QEvent::ContextMenu ||
-          aType == QEvent::KeyPress || aType == QEvent::KeyRelease ||
-          aType == QEvent::Accel || aType == QEvent::AccelOverride)
-        return false;
-    }
-#endif
 
 #ifdef ENABLE_TESTRECORDER
     return myHandler ? myHandler->handle( receiver, e ) :
@@ -680,15 +643,34 @@ int main( int argc, char **argv )
     abort(); //abort program to avoid deadlock in destructors or atexit when shutdown has been interrupted
   }
 
-  PyGILState_Ensure();
-  //Destroy orb from python (for chasing memory leaks)
+    //Destroy orb from python (for chasing memory leaks)
   //PyRun_SimpleString("from omniORB import CORBA");
   //PyRun_SimpleString("orb=CORBA.ORB_init([''], CORBA.ORB_ID)");
   //PyRun_SimpleString("orb.destroy()");
-  Py_Finalize();
+
+  // Destroy the ORB:
+  sleep(2);
+  //std::cout << "@@@@@ Explicitely destroying the ORB (hoping to kill omniORB threads ...)\n";
+  ORB_INIT * init = SINGLETON_<ORB_INIT>::Instance();
+  if (init)
+    init->explicit_destroy();
+  //std::cout << "@@@@@ ORB destroyed\n";
+
+  // After ORB destruction
+  if(Py_IsInitialized())
+    {
+      PyGILState_Ensure();
+      //std::cout << "@@@@@ About to PyFinalize\n";
+      Py_Finalize();
+      //std::cout << "@@@@@ DONE PyFinalize\n";
+    }
 
   if ( shutdownAll )
-    killOmniNames();
+    {
+      //std::cout << "@@@@@ About to kill omni\n";
+      killOmniNames();
+      //std::cout << "@@@@@ DONE kill omni\n";
+    }
 
   MESSAGE( "Salome_Session_Server:endofserver" );
   return result;