]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Merge remote-tracking branch 'origin/vsr/fix_single_study_pb' into pre/fix_single_study
authorPaul RASCLE <paul.rascle@edf.fr>
Thu, 10 Apr 2014 08:31:47 +0000 (10:31 +0200)
committerPaul RASCLE <paul.rascle@edf.fr>
Thu, 10 Apr 2014 08:31:47 +0000 (10:31 +0200)
1  2 
src/PyConsole/PyConsole_Editor.cxx
src/PyConsole/PyConsole_Interp.cxx
src/PyInterp/PyInterp_Interp.cxx
src/PyInterp/PyInterp_Interp.h
src/SalomeApp/SalomeApp_PyInterp.cxx
src/SalomeApp/SalomeApp_PyInterp.h

index 851da035c26e57d83a1c8bedf1024c9158b194ba,4caf5e48b329d94a7f1cca8038b1b3a962520674..adb5a6d7ae9b72da5b2098272464734ee04d20ed
@@@ -1,4 -1,4 +1,4 @@@
 -// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
 +// Copyright (C) 2007-2014  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 +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
@@@ -190,6 -190,9 +190,9 @@@ PyConsole_Editor::PyConsole_Editor( PyC
  */
  PyConsole_Editor::~PyConsole_Editor()
  {
+   myInterp->destroy();
+   delete myInterp;
+   myInterp = 0;
  }
  
  /*!
index d230e9b12e1e4af677da1399e84e0d4f65f3e363,10e6fa0e623c7dfb1483e5f68a5f155516ccb648..c4b208180bb5c4a8d1c23cfe21bd4606afda42f9
@@@ -1,4 -1,4 +1,4 @@@
 -// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
 +// Copyright (C) 2007-2014  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 +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
@@@ -77,6 -77,7 +77,7 @@@ bool PyConsole_Interp::initContext(
      PyErr_Print();
      return false;
    }  
-   _context = PyModule_GetDict(m);          // get interpreter dictionnary context
+   PyObject* global_dict = PyModule_GetDict(m);          // get interpreter dictionnary context
+   _context = PyDict_Copy(global_dict);
    return true;
  }
index 4af91284eb60a80ddd52e9c28abe105a66f33496,f70141b6bce92356d5a62159221ee31a2e154abb..ba1a386fdb1c4a3de2dad8778017e613059715df
@@@ -1,4 -1,4 +1,4 @@@
 -// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
 +// Copyright (C) 2007-2014  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 +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
@@@ -254,6 -254,12 +254,12 @@@ void PyInterp_Interp::initialize(
    initRun();
  }
  
+ void PyInterp_Interp::destroy()
+ {
+   PyLockWrapper lck;
+   closeContext();
+ }
  /*!
    \brief Initialize Python interpreter.
  
@@@ -302,6 -308,10 +308,10 @@@ bool PyInterp_Interp::initRun(
    return true;
  }
  
+ void PyInterp_Interp::closeContext()
+ {
+ }
  /*!
    \brief Compile Python command and evaluate it in the
           python dictionary context if possible. This is not thread-safe.
index 72125dbd68b5fb0cec814de795d1b4fef04bb889,048bc448c84099bdcd6a5cc768dda1dc6532c452..766f02a5e72ded74c206ecd05e13ac568f71d19d
@@@ -1,4 -1,4 +1,4 @@@
 -// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
 +// Copyright (C) 2007-2014  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 +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
@@@ -73,6 -73,7 +73,7 @@@ public
    virtual ~PyInterp_Interp();
    
    void initialize();
+   void destroy();
  
    virtual int run(const char *command); 
  
@@@ -106,6 -107,7 +107,7 @@@ protected
    /** Initialize execution context. Must set the member _context, and return True on success. */
    virtual bool initContext() = 0;
    virtual bool initRun();
+   virtual void closeContext();
  };
  
  /**
index 42c8a0a0a46eaca282013631140a162a526d8bb9,a8d89daa927797bbe5a8671f9a6ef470f77ff73e..3adde1b6be2c319e0192abedb15dd88242be7f0d
@@@ -1,4 -1,4 +1,4 @@@
 -// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
 +// Copyright (C) 2007-2014  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 +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
@@@ -77,3 -77,9 +77,9 @@@ int SalomeApp_PyInterp::beforeRun(
    }
    return true;
  }
+ void SalomeApp_PyInterp::closeContext()
+ {
+     simpleRun( "import salome", false );
+     simpleRun( "salome.salome_close()", false );
+ }
index d2cfa0f0a53abe6d89073072e3471543919c10ee,ef556fcec4b2759ff0bf60cab6af3684acebfb04..95855f3a4107fcfb041c5693cfb8349ce921e298
@@@ -1,4 -1,4 +1,4 @@@
 -// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
 +// Copyright (C) 2007-2014  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 +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
@@@ -36,6 -36,7 +36,7 @@@ public
    virtual ~SalomeApp_PyInterp();
  
    virtual void initPython();
+   virtual void closeContext();
  
  protected:
    virtual int  beforeRun();