Skip to content

Commit 251544a

Browse files
committed
BUG: Fix PyUnicode/PyString usage for Qt6 compatibility
Add preprocessor conditional to use PyUnicode_FromString for Qt6 and PyString_FromString for earlier versions, ensuring compatibility with both Qt5 and Qt6.
1 parent 2d950c7 commit 251544a

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

generator/shellimplgenerator.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,11 @@ void ShellImplGenerator::write(QTextStream &s, const AbstractMetaClass *meta_cla
138138
s << "if (_wrapper) {" << endl;
139139
s << " PYTHONQT_GIL_SCOPE" << endl;
140140
s << " if (Py_REFCNT((PyObject*)_wrapper) > 0) {" << endl;
141+
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
142+
s << " static PyObject* name = PyUnicode_FromString(\"" << fun->name() << "\");" << endl;
143+
#else
141144
s << " static PyObject* name = PyString_FromString(\"" << fun->name() << "\");" << endl;
145+
#endif
142146
s << " PyObject* obj = PyBaseObject_Type.tp_getattro((PyObject*)_wrapper, name);" << endl;
143147
s << " if (obj) {" << endl;
144148
s << " static const char* argumentList[] ={\"";

0 commit comments

Comments
 (0)