X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2Fydfx_gui%2FYDFXGUISeqInit.cxx;h=0f3d69f3167038d69f51cb8c1979a5be986b4031;hb=255150e4eec79294bbd06c7c464f309b4a264960;hp=04e683aa445fe142944a10ed182f5c0204533c3a;hpb=f326fbedf87cbffb501f1c677c10222468e4e3f4;p=modules%2Fyacs.git diff --git a/src/ydfx_gui/YDFXGUISeqInit.cxx b/src/ydfx_gui/YDFXGUISeqInit.cxx index 04e683aa4..0f3d69f31 100644 --- a/src/ydfx_gui/YDFXGUISeqInit.cxx +++ b/src/ydfx_gui/YDFXGUISeqInit.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2016-2020 CEA/DEN, EDF R&D +// Copyright (C) 2016-2023 CEA, EDF // // 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 -#include "AutoGIL.hxx" +#include "PythonCppUtils.hxx" #include "YDFXGUIWrap.hxx" #include "YDFXGUIPyThreadSaver.hxx" @@ -46,24 +46,6 @@ 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) {