aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2
diff options
context:
space:
mode:
Diffstat (limited to 'sources/shiboken2')
-rw-r--r--sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp2
-rw-r--r--sources/shiboken2/generator/shiboken2/cppgenerator.cpp1
-rw-r--r--sources/shiboken2/generator/shiboken2/shibokengenerator.cpp8
-rw-r--r--sources/shiboken2/libshiboken/qapp_macro.cpp9
-rw-r--r--sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/parser.py3
-rw-r--r--sources/shiboken2/tests/libsample/modifications.cpp16
-rw-r--r--sources/shiboken2/tests/libsample/modifications.h10
-rw-r--r--sources/shiboken2/tests/samplebinding/modifications_test.py10
-rw-r--r--sources/shiboken2/tests/samplebinding/typesystem_sample.xml6
9 files changed, 58 insertions, 7 deletions
diff --git a/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp b/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp
index 9cad400f3..dd29c02f0 100644
--- a/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp
+++ b/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp
@@ -1023,6 +1023,8 @@ QtXmlToSphinx::LinkContext *QtXmlToSphinx::handleLinkStart(const QString &type,
result->type = LinkContext::External;
else
result->type = LinkContext::Reference;
+ } else if (type == QLatin1String("external")) {
+ result->type = LinkContext::External;
} else {
result->type = LinkContext::Reference;
}
diff --git a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
index 5e9d9378e..547aecc61 100644
--- a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
+++ b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
@@ -6018,6 +6018,7 @@ QString CppGenerator::writeReprFunction(QTextStream &s, GeneratorContext &contex
Indentation indent(INDENT);
s << INDENT << "str.replace(0, idx, Py_TYPE(self)->tp_name);" << endl;
}
+ s << INDENT << "str = str.trimmed();" << endl;
s << INDENT << "PyObject *mod = PyDict_GetItem(Py_TYPE(self)->tp_dict, Shiboken::PyMagicName::module());" << endl;
// PYSIDE-595: The introduction of heap types has the side effect that the module name
// is always prepended to the type name. Therefore the strchr check:
diff --git a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp
index 6d94af248..a94d3c8a7 100644
--- a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp
+++ b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp
@@ -573,11 +573,11 @@ QString ShibokenGenerator::guessScopeForDefaultValue(const AbstractMetaFunction
{
QString value = arg->defaultValueExpression();
- if (value.isEmpty())
- return QString();
-
- if (isPointer(arg->type()))
+ if (value.isEmpty()
+ || arg->hasModifiedDefaultValueExpression()
+ || isPointer(arg->type())) {
return value;
+ }
static const QRegularExpression enumValueRegEx(QStringLiteral("^([A-Za-z_]\\w*)?$"));
Q_ASSERT(enumValueRegEx.isValid());
diff --git a/sources/shiboken2/libshiboken/qapp_macro.cpp b/sources/shiboken2/libshiboken/qapp_macro.cpp
index 12af9613c..306f53b74 100644
--- a/sources/shiboken2/libshiboken/qapp_macro.cpp
+++ b/sources/shiboken2/libshiboken/qapp_macro.cpp
@@ -120,6 +120,7 @@ reset_qApp_var(void)
PyObject *
MakeSingletonQAppWrapper(PyTypeObject *type)
{
+ static bool app_created = false;
if (type == nullptr)
type = Py_NONE_TYPE;
if (!(type == Py_NONE_TYPE || Py_TYPE(qApp_content) == Py_NONE_TYPE)) {
@@ -145,6 +146,9 @@ MakeSingletonQAppWrapper(PyTypeObject *type)
Py_REFCNT(qApp_var) = 1; // fuse is armed...
}
if (type == Py_NONE_TYPE) {
+ // PYSIDE-1093: Ignore None when no instance has ever been created.
+ if (!app_created)
+ Py_RETURN_NONE;
// Debug mode showed that we need to do more than just remove the
// reference. To keep everything in the right order, it is easiest
// to do a full shutdown, using QtCore.__moduleShutdown().
@@ -158,9 +162,10 @@ MakeSingletonQAppWrapper(PyTypeObject *type)
Py_REFCNT(qApp_content) = Py_REFCNT(Py_None);
if (__moduleShutdown != nullptr)
Py_XDECREF(PyObject_CallFunction(__moduleShutdown, const_cast<char *>("()")));
+ } else {
+ PyObject_INIT(qApp_content, type);
+ app_created = true;
}
- else
- (void)PyObject_INIT(qApp_content, type);
Py_INCREF(qApp_content);
return qApp_content;
}
diff --git a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/parser.py b/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/parser.py
index df2b9fa92..8d970956b 100644
--- a/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/parser.py
+++ b/sources/shiboken2/shibokenmodule/files.dir/shibokensupport/signature/parser.py
@@ -106,7 +106,8 @@ def _parse_line(line):
$
"""
ret = SimpleNamespace(**re.match(line_re, line, re.VERBOSE).groupdict())
- argstr = ret.arglist
+ # PYSIDE-1095: Handle arbitrary default expressions
+ argstr = ret.arglist.replace("->", ".deref.")
arglist = _parse_arglist(argstr)
args = []
for arg in arglist:
diff --git a/sources/shiboken2/tests/libsample/modifications.cpp b/sources/shiboken2/tests/libsample/modifications.cpp
index 98b22f09b..56ba81875 100644
--- a/sources/shiboken2/tests/libsample/modifications.cpp
+++ b/sources/shiboken2/tests/libsample/modifications.cpp
@@ -149,3 +149,19 @@ Modifications::nonConversionRuleForArgumentWithDefaultValue(ObjectType** object)
*object = m_object;
return true;
}
+
+void Modifications::setEnumValue(TestEnum e)
+{
+ m_enumValue = e;
+}
+
+Modifications::TestEnum Modifications::enumValue() const
+{
+ return m_enumValue;
+}
+
+Modifications::TestEnum Modifications::defaultEnumValue() const
+{
+ return TestEnumValue2;
+}
+
diff --git a/sources/shiboken2/tests/libsample/modifications.h b/sources/shiboken2/tests/libsample/modifications.h
index fa32bdec3..674a05f27 100644
--- a/sources/shiboken2/tests/libsample/modifications.h
+++ b/sources/shiboken2/tests/libsample/modifications.h
@@ -51,6 +51,11 @@ public:
Overloaded_ibPP
};
+ enum TestEnum {
+ TestEnumValue1,
+ TestEnumValue2
+ };
+
// those overloaded methods should be heavily modified
// to push the overload decisor to its limits
inline OverloadedModFunc overloaded(int a0, bool b0, int c0, double d0) { return Overloaded_ibid; }
@@ -123,8 +128,13 @@ public:
// Inject code with a %CONVERTTOPYTHON that receives an user's primitive type.
static inline OddBool passOddBool(OddBool ob) { return ob; }
+ void setEnumValue(TestEnum e = TestEnumValue1);
+ TestEnum enumValue() const;
+ TestEnum defaultEnumValue() const;
+
private:
ObjectType* m_object;
+ TestEnum m_enumValue = TestEnumValue1;
};
class LIBSAMPLE_API AbstractModifications : public Modifications
diff --git a/sources/shiboken2/tests/samplebinding/modifications_test.py b/sources/shiboken2/tests/samplebinding/modifications_test.py
index 1dcd50359..e9a1eaf7f 100644
--- a/sources/shiboken2/tests/samplebinding/modifications_test.py
+++ b/sources/shiboken2/tests/samplebinding/modifications_test.py
@@ -220,5 +220,15 @@ class ModificationsTest(unittest.TestCase):
self.assertTrue(isinstance(res, float))
self.assertEqual(res, em.increment)
+ def testDefaultValueModifications(self):
+ # PSYIDE-1095: setEnumValue() has the default value modified to
+ # calling defaultEnumValue() which returns Modifications.TestEnumValue2.
+ # This used to generated broken code since defaultEnumValue() was
+ # qualified by the enum scope.
+ modifications = Modifications()
+ modifications.setEnumValue()
+ self.assertEqual(modifications.enumValue(), Modifications.TestEnumValue2)
+
+
if __name__ == '__main__':
unittest.main()
diff --git a/sources/shiboken2/tests/samplebinding/typesystem_sample.xml b/sources/shiboken2/tests/samplebinding/typesystem_sample.xml
index 2cf2ecab3..30ad5def7 100644
--- a/sources/shiboken2/tests/samplebinding/typesystem_sample.xml
+++ b/sources/shiboken2/tests/samplebinding/typesystem_sample.xml
@@ -955,6 +955,7 @@
<object-type name="Modifications">
<enum-type name="OverloadedModFunc"/>
+ <enum-type name="TestEnum"/>
<modify-function signature="overloaded(int, bool, int, double)">
<modify-argument index="2">
@@ -1286,6 +1287,11 @@
%PYARG_0 = %CONVERTTOPYTHON[OddBool](%0);
</inject-code>
</modify-function>
+ <modify-function signature="setEnumValue(Modifications::TestEnum)">
+ <modify-argument index="1">
+ <replace-default-expression with="cppSelf->defaultEnumValue()"/>
+ </modify-argument>
+ </modify-function>
</object-type>
<object-type name="AbstractModifications">