*/
PyConsole_Editor::~PyConsole_Editor()
{
+ myInterp->destroy();
+ delete myInterp;
+ myInterp = 0;
}
/*!
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;
}
initRun();
}
+void PyInterp_Interp::destroy()
+{
+ PyLockWrapper lck;
+ closeContext();
+}
+
/*!
\brief Initialize Python interpreter.
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.
virtual ~PyInterp_Interp();
void initialize();
+ void destroy();
virtual int run(const char *command);
/** Initialize execution context. Must set the member _context, and return True on success. */
virtual bool initContext() = 0;
virtual bool initRun();
+ virtual void closeContext();
};
/**
}
return true;
}
+
+void SalomeApp_PyInterp::closeContext()
+{
+ simpleRun( "import salome", false );
+ simpleRun( "salome.salome_close()", false );
+}
virtual ~SalomeApp_PyInterp();
virtual void initPython();
+ virtual void closeContext();
protected:
virtual int beforeRun();