aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2023-02-27 09:19:24 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2023-02-27 09:53:40 +0100
commit8fc33607461cdb697ba607ac3d74dd37c14479e6 (patch)
tree7934eaec4d31ecf1fafd975d99c8b86c553fadfd
parentff40e74847cae1e746fc857597209294ca2c2568 (diff)
shiboken6: Mangle field name "from"
Fixes: PYSIDE-2237 Pick-to: 6.4 Change-Id: I9993bbaf545e2868a5be900f793e5ae23f17235f Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
-rw-r--r--sources/pyside6/tests/QtGui/qtextdocument_functions.py13
-rw-r--r--sources/shiboken6/generator/shiboken/cppgenerator.cpp16
2 files changed, 20 insertions, 9 deletions
diff --git a/sources/pyside6/tests/QtGui/qtextdocument_functions.py b/sources/pyside6/tests/QtGui/qtextdocument_functions.py
index 3329b1aee..2ac72df56 100644
--- a/sources/pyside6/tests/QtGui/qtextdocument_functions.py
+++ b/sources/pyside6/tests/QtGui/qtextdocument_functions.py
@@ -10,7 +10,7 @@ sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
from init_paths import init_test_paths
init_test_paths(False)
-from PySide6.QtGui import Qt
+from PySide6.QtGui import QPageRanges, Qt
class QTextDocumentFunctions(unittest.TestCase):
@@ -22,5 +22,16 @@ class QTextDocumentFunctions(unittest.TestCase):
self.assertEqual(html, '<p>A &amp; B</p>')
+class QPageRangesTest(unittest.TestCase):
+ """PYSIDE-2237: Test that field QPageRanges.Range.from is properly mangled."""
+
+ def test(self):
+ pr = QPageRanges()
+ pr.addPage(1)
+ r0 = pr.toRangeList()[0]
+ self.assertEqual(r0.from_, 1)
+ self.assertEqual(r0.to, 1)
+
+
if __name__ == '__main__':
unittest.main()
diff --git a/sources/shiboken6/generator/shiboken/cppgenerator.cpp b/sources/shiboken6/generator/shiboken/cppgenerator.cpp
index 34fa0cff7..c26d06999 100644
--- a/sources/shiboken6/generator/shiboken/cppgenerator.cpp
+++ b/sources/shiboken6/generator/shiboken/cppgenerator.cpp
@@ -55,6 +55,13 @@
using namespace Qt::StringLiterals;
+static QString mangleName(QString name)
+{
+ if (name == u"None" || name == u"False" || name == u"True" || name == u"from")
+ name += u'_';
+ return name;
+}
+
struct sbkUnusedVariableCast
{
explicit sbkUnusedVariableCast(QString name) : m_name(name) {}
@@ -472,7 +479,7 @@ static QString BuildEnumFlagInfo(const AbstractMetaEnum &cppEnum)
static void writePyGetSetDefEntry(TextStream &s, const QString &name,
const QString &getFunc, const QString &setFunc)
{
- s << "{const_cast<char *>(\"" << name << "\"), " << getFunc << ", "
+ s << "{const_cast<char *>(\"" << mangleName(name) << "\"), " << getFunc << ", "
<< (setFunc.isEmpty() ? NULL_PTR : setFunc) << ", nullptr, nullptr},\n";
}
@@ -5673,13 +5680,6 @@ void CppGenerator::writeEnumsInitialization(TextStream &s, AbstractMetaEnumList
}
}
-static QString mangleName(QString name)
-{
- if (name == u"None" || name == u"False" || name == u"True")
- name += u'_';
- return name;
-}
-
void CppGenerator::writeEnumInitialization(TextStream &s, const AbstractMetaEnum &cppEnum,
ErrorReturn errorReturn) const
{