Salome HOME
Copyright update 2022
[modules/yacs.git] / src / ydfx_gui / YDFXGUISeqInit.cxx
index a04ace9e61effd92152690396b65ab1329b33618..c3d55cc8dbac595e6be78871ad76d2ce14d0b739 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2016  CEA/DEN, EDF R&D
+// Copyright (C) 2016-2022  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -33,7 +33,7 @@
 #include <QApplication>
 
 
-#include "AutoGIL.hxx"
+#include "PythonCppUtils.hxx"
 
 #include "YDFXGUIWrap.hxx"
 #include "YDFXGUIPyThreadSaver.hxx"
 
 const char YDFXGUIStatus::OK_STR[]="OK !";
 
-class AutoPyRef
-{
-public:
-  AutoPyRef(PyObject *pyobj=0):_pyobj(pyobj) { }
-  ~AutoPyRef() { release(); }
-  AutoPyRef(const AutoPyRef& other):_pyobj(other._pyobj) { if(_pyobj) Py_XINCREF(_pyobj); }
-  AutoPyRef& operator=(const AutoPyRef& other) { if(_pyobj==other._pyobj) return *this; release(); _pyobj=other._pyobj; Py_XINCREF(_pyobj); return *this; }
-  operator PyObject *() { return _pyobj; }
-  void set(PyObject *pyobj) { if(pyobj==_pyobj) return ; release(); _pyobj=pyobj; }
-  PyObject *get() { return _pyobj; }
-  bool isNull() const { return _pyobj==0; }
-  PyObject *retn() { if(_pyobj) Py_XINCREF(_pyobj); return _pyobj; }
-private:
-  void release() { if(_pyobj) Py_XDECREF(_pyobj); _pyobj=0; }
-private:
-  PyObject *_pyobj;
-};
-
 ////////////////////////////
 
 void YDFXGUIDoubleVectHolder::applyOnInput(YACSEvalInputPort *inp) const
@@ -199,7 +181,7 @@ bool YDFXGUISeqSetterT::executeScript(int& sz)
   std::string txt(toPlainText().toStdString());
   YDFXGUIPyThreadSaver::SaveContext(QApplication::instance()->thread());
   {
-    YACS::ENGINE::AutoGIL gal;
+    AutoGIL gal;
     AutoPyRef code(Py_CompileString(txt.c_str(),TMP_FILENAME, Py_file_input));
     if(code.get() == NULL)
       {