mirror of
https://github.com/ModOrganizer2/modorganizer-plugin_python.git
synced 2026-07-27 14:03:33 -07:00
PyQt6 fixes
This commit is contained in:
@@ -42,7 +42,7 @@ CONFIG(debug, debug|release) {
|
||||
msvc:QMAKE_LFLAGS += /DEBUG
|
||||
}
|
||||
|
||||
INCLUDEPATH += "$${BOOSTPATH}" "$${PYTHONPATH}/include" "$${PYTHONPATH}/Lib/site-packages/PyQt5/include" ../uibase
|
||||
INCLUDEPATH += "$${BOOSTPATH}" "$${PYTHONPATH}/include" "$${PYTHONPATH}/Lib/site-packages/PyQt6/include" ../uibase
|
||||
LIBS += -L"$${PYTHONPATH}/libs" -L"$${BOOSTPATH}/stage/lib"
|
||||
LIBS += -lpython27
|
||||
LIBS += -luibase
|
||||
|
||||
@@ -67,8 +67,8 @@ BOOST_PYTHON_MODULE(mobase)
|
||||
{
|
||||
PyEval_InitThreads();
|
||||
|
||||
bpy::import("PyQt5.QtCore");
|
||||
bpy::import("PyQt5.QtWidgets");
|
||||
bpy::import("PyQt6.QtCore");
|
||||
bpy::import("PyQt6.QtWidgets");
|
||||
|
||||
utils::register_qstring_converter();
|
||||
utils::register_qvariant_converter();
|
||||
@@ -112,7 +112,7 @@ BOOST_PYTHON_MODULE(mobase)
|
||||
utils::register_sequence_container<QList<ExecutableInfo>>();
|
||||
utils::register_sequence_container<QList<ExecutableForcedLoadSetting>>();
|
||||
utils::register_sequence_container<QList<PluginSetting>>();
|
||||
//utils::register_sequence_container<QList<ModRepositoryFileInfo>>();
|
||||
utils::register_sequence_container<QList<ModRepositoryFileInfo*>>();
|
||||
utils::register_sequence_container<QStringList>();
|
||||
utils::register_sequence_container<QList<QString>>();
|
||||
utils::register_sequence_container<QList<QFileInfo>>();
|
||||
|
||||
@@ -5,5 +5,54 @@
|
||||
|
||||
const sipAPIDef* sipAPIAccess::sipAPI()
|
||||
{
|
||||
return (const sipAPIDef*)PyCapsule_Import("sip._C_API", 0);
|
||||
QString exception;
|
||||
static const sipAPIDef* sipApi = nullptr;
|
||||
if (sipApi == nullptr) {
|
||||
PyImport_ImportModule("PyQt6.sip");
|
||||
|
||||
auto errorObj = PyErr_Occurred();
|
||||
if (errorObj != NULL) {
|
||||
PyObject* type, * value, * traceback;
|
||||
PyErr_Fetch(&type, &value, &traceback);
|
||||
PyErr_NormalizeException(&type, &value, &traceback);
|
||||
if (traceback != NULL) {
|
||||
boost::python::handle<> h_type(type);
|
||||
boost::python::handle<> h_val(value);
|
||||
boost::python::handle<> h_tb(traceback);
|
||||
boost::python::object tb(boost::python::import("traceback"));
|
||||
boost::python::object fmt_exp(tb.attr("format_exception"));
|
||||
boost::python::object exp_list(fmt_exp(h_type, h_val, h_tb));
|
||||
boost::python::object exp_str(boost::python::str("\n").join(exp_list));
|
||||
boost::python::extract<std::string> returned(exp_str);
|
||||
exception = QString::fromStdString(returned());
|
||||
}
|
||||
PyErr_Restore(type, value, traceback);
|
||||
throw MOBase::Exception(QString("Failed to load PyQt6: %1").arg(exception));
|
||||
}
|
||||
|
||||
sipApi = (const sipAPIDef*)PyCapsule_Import("PyQt6.sip._C_API", 0);
|
||||
if (sipApi == NULL) {
|
||||
auto errorObj = PyErr_Occurred();
|
||||
if (errorObj != NULL) {
|
||||
PyObject* type, * value, * traceback;
|
||||
PyErr_Fetch(&type, &value, &traceback);
|
||||
PyErr_NormalizeException(&type, &value, &traceback);
|
||||
if (traceback != NULL) {
|
||||
boost::python::handle<> h_type(type);
|
||||
boost::python::handle<> h_val(value);
|
||||
boost::python::handle<> h_tb(traceback);
|
||||
boost::python::object tb(boost::python::import("traceback"));
|
||||
boost::python::object fmt_exp(tb.attr("format_exception"));
|
||||
boost::python::object exp_list(fmt_exp(h_type, h_val, h_tb));
|
||||
boost::python::object exp_str(boost::python::str("\n").join(exp_list));
|
||||
boost::python::extract<std::string> returned(exp_str);
|
||||
exception = QString::fromStdString(returned());
|
||||
}
|
||||
PyErr_Restore(type, value, traceback);
|
||||
}
|
||||
throw MOBase::Exception(QString("Failed to load SIP API: %1").arg(exception));
|
||||
}
|
||||
}
|
||||
|
||||
return sipApi;
|
||||
}
|
||||
Reference in New Issue
Block a user