mirror of
https://github.com/ModOrganizer2/modorganizer-plugin_python.git
synced 2026-07-27 14:03:33 -07:00
dependencies that fulfills the plugin interface. The other contains the actual python functionality. This way the outer dll can always be loaded and report issues. - The build process embeds the second dll into the first, this way only one dll has to be shipped
25 lines
726 B
C++
25 lines
726 B
C++
#include <boost/python.hpp>
|
|
#include <QString>
|
|
#include <utility.h>
|
|
|
|
using namespace MOBase;
|
|
namespace bpy = boost::python;
|
|
|
|
void reportPythonError()
|
|
{
|
|
if (PyErr_Occurred()) {
|
|
// prints to s_ErrIO buffer
|
|
PyErr_Print();
|
|
// extract data from python buffer
|
|
bpy::object mainModule = bpy::import("__main__");
|
|
bpy::object mainNamespace = mainModule.attr("__dict__");
|
|
bpy::object errMsgObj = bpy::eval("s_ErrIO.getvalue()", mainNamespace);
|
|
QString errMsg = bpy::extract<QString>(errMsgObj.ptr());
|
|
bpy::eval("s_ErrIO.truncate(0)", mainNamespace);
|
|
|
|
throw MyException(errMsg);
|
|
} else {
|
|
throw MyException("An unexpected C++ exception was thrown in python code");
|
|
}
|
|
}
|