-// 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
#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
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)
{
QVBoxLayout *verticalLayout(new QVBoxLayout(this));
_textEdit=new YDFXGUISeqSetterT(this); verticalLayout->addWidget(_textEdit);
_push=new YDFXGUISeqSetterP(this); verticalLayout->addWidget(_push);
- _textEdit->setText(QString("import math\n%1=[math.sqrt(float(elt)+0.) for elt in xrange(4)]").arg(name));
+ _textEdit->setText(QString("import math\n%1=[math.sqrt(float(elt)+0.) for elt in range(4)]").arg(name));
_textEdit->hide();
_push->hide();
}