From 9c5950320814d6e0cfe7d6ebe9850ae49c18ae06 Mon Sep 17 00:00:00 2001 From: Christian Tismer Date: Tue, 17 Sep 2019 14:14:04 +0200 Subject: Ignore deprecation warning about QSysInfo class Amends 1bb4368a420ef12e3714bd4edfff34b8b3c983a8 . QSysInfo is deprecated and replaced by the QOperatingSystemVersion class which already exists. Before Qt 6.0 is out, we can not remove these classes. Fortunately, the warning can be suppressed by setting QT_WARNING_DISABLE_DEPRECATED. The options was already in the generated code, but the placement was too late. The qsysinfo include happens in the line // module include #include "pyside2_qtcore_python.h" which comes right after the first "usePySideExtensions" section. Furthermore, the used template in headergenerator.cpp needed the setting when the deprecated enum ocurred. The section after "// Macros for type check" got the setting, too, so that all calls to HeaderGenerator::writeSbkTypeFunction were excluded from warnings. Change-Id: Ife96f5ade26437b23cb756ee1b94af23d4a81faa Reviewed-by: Friedemann Kleint --- sources/shiboken2/generator/shiboken2/cppgenerator.cpp | 8 ++++---- sources/shiboken2/generator/shiboken2/headergenerator.cpp | 7 +++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp index dd6c5ee96..a2b67b91b 100644 --- a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp +++ b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp @@ -317,7 +317,10 @@ void CppGenerator::generateClass(QTextStream &s, GeneratorContext &classContext) s << "#include " << endl; s << "#include " << endl; s << "#include " << endl; - } + s << endl; + s << "QT_WARNING_DISABLE_DEPRECATED" << endl; + s << endl; + } s << "#include " << endl; if (usePySideExtensions() && metaClass->isQObject()) { @@ -368,9 +371,6 @@ void CppGenerator::generateClass(QTextStream &s, GeneratorContext &classContext) if (metaClass->typeEntry()->typeFlags() & ComplexTypeEntry::Deprecated) s << "#Deprecated" << endl; - if (usePySideExtensions()) - s << "\nQT_WARNING_DISABLE_DEPRECATED\n"; - // Use class base namespace { const AbstractMetaClass *context = metaClass->enclosingClass(); diff --git a/sources/shiboken2/generator/shiboken2/headergenerator.cpp b/sources/shiboken2/generator/shiboken2/headergenerator.cpp index 8a2c56232..e47c37523 100644 --- a/sources/shiboken2/generator/shiboken2/headergenerator.cpp +++ b/sources/shiboken2/generator/shiboken2/headergenerator.cpp @@ -454,6 +454,11 @@ bool HeaderGenerator::finishGeneration() // TODO-CONVERTER ------------------------------------------------------------------------------ macrosStream << "// Macros for type check" << endl; + + if (usePySideExtensions()) { + typeFunctions << "QT_WARNING_PUSH" << endl; + typeFunctions << "QT_WARNING_DISABLE_DEPRECATED" << endl; + } for (const AbstractMetaEnum *cppEnum : qAsConst(globalEnums)) { if (cppEnum->isAnonymous() || cppEnum->isPrivate()) continue; @@ -489,6 +494,8 @@ bool HeaderGenerator::finishGeneration() includes << classType->include(); writeSbkTypeFunction(typeFunctions, metaType); } + if (usePySideExtensions()) + typeFunctions << "QT_WARNING_POP" << endl; QString moduleHeaderFileName(outputDirectory() + QDir::separator() + subDirectoryForPackage(packageName()) -- cgit v1.2.3