diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2020-06-11 07:56:19 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2020-06-11 09:45:05 +0200 |
commit | f2e63d3588c8422d84d9ff5480427a83d68083bb (patch) | |
tree | ec6742554b9e854885e598ac3fd9a37f0daa9894 /sources | |
parent | 76d5ddebc281543294a330da3e56feea080581bb (diff) |
shiboken: Fix default-initialized function arguments
Specifying {} causes it to be qualified, check this.
Change-Id: Idd23c8a5af01cd7fbb63a2e5a01bb349c530fe54
Fixes: PYSIDE-1325
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources')
5 files changed, 13 insertions, 1 deletions
diff --git a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp index b7852c017..b6ab70d1f 100644 --- a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp +++ b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp @@ -589,7 +589,7 @@ QString ShibokenGenerator::guessScopeForDefaultValue(const AbstractMetaFunction { QString value = arg->defaultValueExpression(); - if (value.isEmpty() + if (value.isEmpty() || value == QLatin1String("{}") || arg->hasModifiedDefaultValueExpression() || isPointer(arg->type())) { return value; diff --git a/sources/shiboken2/tests/libsample/pen.cpp b/sources/shiboken2/tests/libsample/pen.cpp index d30071f49..b08721f79 100644 --- a/sources/shiboken2/tests/libsample/pen.cpp +++ b/sources/shiboken2/tests/libsample/pen.cpp @@ -65,3 +65,7 @@ int Pen::ctorType() { return m_ctor; } + +void Pen::drawLine(int x1, int y1, int x2, int y2, RenderHints renderHints) +{ +} diff --git a/sources/shiboken2/tests/libsample/pen.h b/sources/shiboken2/tests/libsample/pen.h index ca079198b..6b3bf9f1a 100644 --- a/sources/shiboken2/tests/libsample/pen.h +++ b/sources/shiboken2/tests/libsample/pen.h @@ -49,11 +49,16 @@ class LIBSAMPLE_API Pen public: enum { EmptyCtor, EnumCtor, ColorCtor, CopyCtor }; + enum RenderHints { None = 0, Antialiasing = 0x1, TextAntialiasing = 0x2 }; + Pen(); Pen(SampleNamespace::Option option); Pen(const Color& color); Pen(const Pen& pen); + // PYSIDE-1325, default initializer + void drawLine(int x1, int y1, int x2, int y2, RenderHints renderHints = {}); + int ctorType(); private: int m_ctor; diff --git a/sources/shiboken2/tests/samplebinding/pen_test.py b/sources/shiboken2/tests/samplebinding/pen_test.py index 408871bb3..89abf4d54 100644 --- a/sources/shiboken2/tests/samplebinding/pen_test.py +++ b/sources/shiboken2/tests/samplebinding/pen_test.py @@ -63,6 +63,8 @@ class TestPen(unittest.TestCase): def testPenWithIntConvertedToColor(self): pen = Pen(1) self.assertEqual(pen.ctorType(), Pen.ColorCtor) + pen.drawLine(0, 0, 5, 5) + if __name__ == '__main__': unittest.main() diff --git a/sources/shiboken2/tests/samplebinding/typesystem_sample.xml b/sources/shiboken2/tests/samplebinding/typesystem_sample.xml index 30ad5def7..3aaecf247 100644 --- a/sources/shiboken2/tests/samplebinding/typesystem_sample.xml +++ b/sources/shiboken2/tests/samplebinding/typesystem_sample.xml @@ -2310,6 +2310,7 @@ <value-type name="Color" /> <value-type name="Pen"> <enum-type identified-by-value="EnumCtor"/> + <enum-type name="RenderHints"/> </value-type> <value-type name="CtorConvRule"> |