From c62f71722639c39f210ddbec0c4d832521b3f187 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Wed, 17 Aug 2016 10:44:53 +0200 Subject: [PATCH] Fix signal code generation The old code is broken because it was passing signal.outputArgs as inputArgs variable of writeArgList, fix can not be passing signal.outputArgs as outputArgs of writeArgList since that ignores the first of the list, so i added a new function that does the right thing Change-Id: If54484e04880d5dcebfedb9d478ee0e9faf37baa Task-number: QTBUG-21577 Reviewed-by: Thiago Macieira --- src/3rdparty/atspi2/xml/Cache.xml | 4 +-- src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp | 38 +++++++++++++++++++++---- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/src/3rdparty/atspi2/xml/Cache.xml b/src/3rdparty/atspi2/xml/Cache.xml index 9d0c5801a9..01c52810ac 100644 --- a/src/3rdparty/atspi2/xml/Cache.xml +++ b/src/3rdparty/atspi2/xml/Cache.xml @@ -9,12 +9,12 @@ - + - + diff --git a/src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp b/src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp index 7361fa2230..1835e8a283 100644 --- a/src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp +++ b/src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp @@ -332,7 +332,10 @@ static QString classNameForInterface(const QString &interface, ClassType classTy return retval; } -static QByteArray qtTypeName(const QString &signature, const QDBusIntrospection::Annotations &annotations, int paramId = -1, const char *direction = "Out") +// ### Qt6 Remove the two isSignal ifs +// They are only here because before signal arguments where previously searched as "In" so to maintain compatibility +// we first search for "Out" and if not found we search for "In" +static QByteArray qtTypeName(const QString &signature, const QDBusIntrospection::Annotations &annotations, int paramId = -1, const char *direction = "Out", bool isSignal = false) { int type = QDBusMetaType::signatureToType(signature.toLatin1()); if (type == QVariant::Invalid) { @@ -349,9 +352,15 @@ static QByteArray qtTypeName(const QString &signature, const QDBusIntrospection: qttype = annotations.value(oldAnnotationName); if (qttype.isEmpty()) { - fprintf(stderr, "Got unknown type `%s'\n", qPrintable(signature)); - fprintf(stderr, "You should add \"/> to the XML description\n", - qPrintable(annotationName)); + if (!isSignal || qstrcmp(direction, "Out") == 0) { + fprintf(stderr, "Got unknown type `%s'\n", qPrintable(signature)); + fprintf(stderr, "You should add \"/> to the XML description\n", + qPrintable(annotationName)); + } + + if (isSignal) + return qtTypeName(signature, annotations, paramId, "In", isSignal); + exit(1); } @@ -451,6 +460,23 @@ static void writeArgList(QTextStream &ts, const QStringList &argNames, } } +static void writeSignalArgList(QTextStream &ts, const QStringList &argNames, + const QDBusIntrospection::Annotations &annotations, + const QDBusIntrospection::Arguments &outputArgs) +{ + bool first = true; + int argPos = 0; + for (int i = 0; i < outputArgs.count(); ++i) { + const QDBusIntrospection::Argument &arg = outputArgs.at(i); + QString type = constRefArg(qtTypeName(arg.type, annotations, i, "Out", true /* isSignal */)); + + if (!first) + ts << ", "; + ts << type << argNames.at(argPos++); + first = false; + } +} + static QString propertyGetter(const QDBusIntrospection::Property &property) { QString getter = property.annotations.value(QLatin1String("org.qtproject.QtDBus.PropertyGetter")); @@ -765,7 +791,7 @@ static void writeProxy(const QString &filename, const QDBusIntrospection::Interf hs << "void " << signal.name << "("; QStringList argNames = makeArgNames(signal.outputArgs); - writeArgList(hs, argNames, signal.annotations, signal.outputArgs); + writeSignalArgList(hs, argNames, signal.annotations, signal.outputArgs); hs << ");" << endl; // finished for header } @@ -1109,7 +1135,7 @@ static void writeAdaptor(const QString &filename, const QDBusIntrospection::Inte hs << "void " << signal.name << "("; QStringList argNames = makeArgNames(signal.outputArgs); - writeArgList(hs, argNames, signal.annotations, signal.outputArgs); + writeSignalArgList(hs, argNames, signal.annotations, signal.outputArgs); hs << ");" << endl; // finished for header }