diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2016-12-14 10:48:11 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2016-12-14 10:27:04 +0000 |
commit | e554f704d48de142146baa2201e07623d231f199 (patch) | |
tree | 47f9fa5d7def310af1c9bfc0d8817f12eb6c7810 | |
parent | ac5851d935a33fcc6d83fa0c325ea29ad081d747 (diff) |
Fix inclusion of Qt headers in the generated code
Generate an #include directive for QDebug only when PySide
extensions are enabled and define QT_NO_VERSION_TAGGING
to prevent generation of the qt_version_tag symbol.
This makes it possible to generate code independent of Qt which
would otherwise produce a link error (such as the shiboken tests).
Change-Id: Ic5ee52f60980744a44af7cf666dc1a784414a5fd
Reviewed-by: Christian Tismer <tismer@stackless.com>
-rw-r--r-- | generator/shiboken2/cppgenerator.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/generator/shiboken2/cppgenerator.cpp b/generator/shiboken2/cppgenerator.cpp index cfc4f2d..8e434e0 100644 --- a/generator/shiboken2/cppgenerator.cpp +++ b/generator/shiboken2/cppgenerator.cpp @@ -177,6 +177,13 @@ bool CppGenerator::hasBoolCast(const AbstractMetaClass* metaClass) const typedef QMap<QString, AbstractMetaFunctionList> FunctionGroupMap; typedef FunctionGroupMap::const_iterator FunctionGroupMapIt; +// Prevent ELF symbol qt_version_tag from being generated into the source +static const char includeQDebug[] = +"#ifndef QT_NO_VERSION_TAGGING\n" +"# define QT_NO_VERSION_TAGGING\n" +"#endif\n" +"#include <QDebug>\n"; + /*! Function used to write the class generated binding code on the buffer \param s the output buffer @@ -198,8 +205,8 @@ void CppGenerator::generateClass(QTextStream &s, const AbstractMetaClass *metaCl // headers s << "// default includes" << endl; s << "#include <shiboken.h>" << endl; - s << "#include <QDebug>" << endl; if (usePySideExtensions()) { + s << includeQDebug; s << "#include <pysidesignal.h>" << endl; s << "#include <pysideproperty.h>" << endl; s << "#include <pyside.h>" << endl; @@ -4753,7 +4760,7 @@ bool CppGenerator::finishGeneration() s << "#include <shiboken.h>" << endl; s << "#include <algorithm>" << endl; if (usePySideExtensions()) { - s << "#include <QDebug>" << endl; + s << includeQDebug; s << "#include <pyside.h>" << endl; } |