From 3a26e22f38c56af09c12e6808781a50e60ea01ac Mon Sep 17 00:00:00 2001 From: Ladislav Michl Date: Sat, 3 Feb 2024 17:54:20 +0100 Subject: [PATCH] Gui: PythonWrapper: move wrap instance argument into template --- src/Gui/PythonWrapper.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/Gui/PythonWrapper.cpp b/src/Gui/PythonWrapper.cpp index d5b9714296..96dc6a7e9b 100644 --- a/src/Gui/PythonWrapper.cpp +++ b/src/Gui/PythonWrapper.cpp @@ -425,11 +425,10 @@ static PyObject* importPySide(const std::string& moduleName) template Py::Object qt_wrapInstance(qttype object, const std::string& className, - const std::string& moduleName, - const std::string& wrap) + const std::string& moduleName) { Py::Module mainmod(importShiboken(), true); - Py::Callable func = mainmod.getDict().getItem(wrap); + Py::Callable func = mainmod.getDict().getItem("wrapInstance"); Py::Tuple arguments(2); arguments[0] = Py::asObject(PyLong_FromVoidPtr((void*)object)); @@ -576,7 +575,7 @@ Py::Object PythonWrapper::fromQImage(const QImage& img) throw Py::RuntimeError("Failed to wrap image"); #else // Access shiboken/PySide via Python - return qt_wrapInstance(&img, "QImage", "QtGui", "wrapInstance"); + return qt_wrapInstance(&img, "QImage", "QtGui"); #endif } @@ -597,7 +596,7 @@ Py::Object PythonWrapper::fromQIcon(const QIcon* icon) throw Py::RuntimeError("Failed to wrap icon"); #else // Access shiboken/PySide via Python - return qt_wrapInstance(icon, "QIcon", "QtGui", "wrapInstance"); + return qt_wrapInstance(icon, "QIcon", "QtGui"); #endif } @@ -648,7 +647,7 @@ Py::Object PythonWrapper::fromQPrinter(QPrinter* printer) throw Py::RuntimeError("Failed to wrap printer"); #else // Access shiboken/PySide via Python - return qt_wrapInstance(printer, "QPrinter", "QtCore", "wrapInstance"); + return qt_wrapInstance(printer, "QPrinter", "QtCore"); #endif } @@ -677,7 +676,7 @@ Py::Object PythonWrapper::fromQObject(QObject* object, const char* className) typeName = className; else typeName = object->metaObject()->className(); - return qt_wrapInstance(object, typeName, "QtCore", "wrapInstance"); + return qt_wrapInstance(object, typeName, "QtCore"); #endif } @@ -704,7 +703,7 @@ Py::Object PythonWrapper::fromQWidget(QWidget* widget, const char* className) typeName = className; else typeName = widget->metaObject()->className(); - return qt_wrapInstance(widget, typeName, "QtWidgets", "wrapInstance"); + return qt_wrapInstance(widget, typeName, "QtWidgets"); #endif } @@ -778,7 +777,7 @@ void PythonWrapper::createChildrenNameAttributes(PyObject* root, QObject* object className = "QObject"; } - Py::Object pyChild(qt_wrapInstance(child, className, "QtWidgets", "wrapInstance")); + Py::Object pyChild(qt_wrapInstance(child, className, "QtWidgets")); PyObject_SetAttrString(root, name.constData(), pyChild.ptr()); #endif }