diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2017-11-27 17:01:22 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2017-11-27 17:01:22 +0100 |
commit | 1c9e0d95263480a5ae5d645cabb41f835d1dbb70 (patch) | |
tree | 25f46dc18d8f8430d46ad365452ce0d8a7c9d9d0 /sources/shiboken2 | |
parent | ad14f64972d182fca3e180c08750ca020a91b84e (diff) | |
parent | 2490c34325bb1b39922582090a4cb69c01726999 (diff) |
Merge remote-tracking branch 'origin/5.6' into 5.9
Change-Id: I79637555fbfbd596dee4313baf80149d03bb5206
Diffstat (limited to 'sources/shiboken2')
-rw-r--r-- | sources/shiboken2/generator/shiboken2/cppgenerator.cpp | 4 | ||||
-rw-r--r-- | sources/shiboken2/libshiboken/signature.cpp | 32 | ||||
-rw-r--r-- | sources/shiboken2/tests/libsample/sample.cpp | 12 | ||||
-rw-r--r-- | sources/shiboken2/tests/libsample/sample.h | 3 |
4 files changed, 47 insertions, 4 deletions
diff --git a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp index 74861e3d4..cb650dde3 100644 --- a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp +++ b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp @@ -530,7 +530,7 @@ void CppGenerator::generateClass(QTextStream &s, GeneratorContext &classContext) writeMappingMethods(s, metaClass, classContext); } - if (metaClass->hasComparisonOperatorOverload()) { + if (!metaClass->isNamespace() && metaClass->hasComparisonOperatorOverload()) { s << "// Rich comparison" << endl; writeRichCompareFunction(s, classContext); } @@ -3751,7 +3751,7 @@ void CppGenerator::writeClassDefinition(QTextStream &s, } QString tp_richcompare = QString(QLatin1Char('0')); - if (metaClass->hasComparisonOperatorOverload()) + if (!metaClass->isNamespace() && metaClass->hasComparisonOperatorOverload()) tp_richcompare = cpythonBaseName(metaClass) + QLatin1String("_richcompare"); QString tp_getset = QString(QLatin1Char('0')); diff --git a/sources/shiboken2/libshiboken/signature.cpp b/sources/shiboken2/libshiboken/signature.cpp index e6d64c16e..a2cd12a87 100644 --- a/sources/shiboken2/libshiboken/signature.cpp +++ b/sources/shiboken2/libshiboken/signature.cpp @@ -442,6 +442,32 @@ static PyGetSetDef new_PyType_getsets[] = { // This special Type_Ready does certain initializations earlier with // our new version. // + +#ifndef _WIN32 +//////////////////////////////////////////////////////////////////////////// +// a stack trace for linux-like platforms +#include <stdio.h> +#include <execinfo.h> +#include <signal.h> +#include <stdlib.h> +#include <unistd.h> + +void handler(int sig) { + void *array[30]; + size_t size; + + // get void*'s for all entries on the stack + size = backtrace(array, 30); + + // print out all the frames to stderr + fprintf(stderr, "Error: signal %d:\n", sig); + backtrace_symbols_fd(array, size, STDERR_FILENO); + exit(1); +} + +//////////////////////////////////////////////////////////////////////////// +#endif // _WIN32 + static int PySideType_Ready(PyTypeObject *type) { @@ -461,6 +487,12 @@ PySideType_Ready(PyTypeObject *type) || add_more_getsets(&PyStaticMethod_Type, new_PyStaticMethod_getsets) < 0 || add_more_getsets(&PyType_Type, new_PyType_getsets) < 0) return -1; +#ifndef _WIN32 + // we enable the stack trace in CI, only. + const char *testEnv = getenv("QTEST_ENVIRONMENT"); + if (testEnv && strstr(testEnv, "ci")) + signal(SIGSEGV, handler); // install our handler +#endif // _WIN32 init_done = 1; } return PyType_Ready(type); diff --git a/sources/shiboken2/tests/libsample/sample.cpp b/sources/shiboken2/tests/libsample/sample.cpp index fa1e1fda3..850674bd9 100644 --- a/sources/shiboken2/tests/libsample/sample.cpp +++ b/sources/shiboken2/tests/libsample/sample.cpp @@ -28,12 +28,20 @@ #include "sample.h" -sample::sample::sample(int value) : m_value(value) +namespace sample +{ + +sample::sample(int value) : m_value(value) { } -int sample::sample::value() const +int sample::value() const { return m_value; } +bool operator==(const sample&s1, const sample&s2) +{ + return s1.value() == s2.value(); +} +} // namespace sample diff --git a/sources/shiboken2/tests/libsample/sample.h b/sources/shiboken2/tests/libsample/sample.h index 46e3d0d1a..68b54e067 100644 --- a/sources/shiboken2/tests/libsample/sample.h +++ b/sources/shiboken2/tests/libsample/sample.h @@ -43,6 +43,9 @@ namespace sample private: int m_value; }; + + // shiboken must not generate richcompare for namespace sample + LIBSAMPLE_API bool operator==(const sample&s1, const sample&s2); } #endif |