[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/work/dbus-qt4-qt3backport/tools/dbusxml2qt3
From:       Kevin Krammer <kevin.krammer () gmx ! at>
Date:       2007-02-01 21:52:30
Message-ID: 1170366750.184751.22096.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 629202 by krake:

Generate check for invalid error when interface implementations return false.


 M  +1 -1      classgen.cpp  
 M  +32 -2     methodgen.cpp  
 M  +1 -1      methodgen.h  


--- branches/work/dbus-qt4-qt3backport/tools/dbusxml2qt3/classgen.cpp #629201:629202
@@ -449,7 +449,7 @@
     QValueList<Method>::const_iterator endIt = classData.methods.end();
     for (; it != endIt; ++it)
     {
-        MethodGenerator::writeMethodCall(classData.name, *it, stream);
+        MethodGenerator::writeMethodCall(classData, *it, stream);
     }
 }
 
--- branches/work/dbus-qt4-qt3backport/tools/dbusxml2qt3/methodgen.cpp #629201:629202
@@ -403,10 +403,10 @@
     stream << endl;
 }
 
-void MethodGenerator::writeMethodCall(const QString& className,
+void MethodGenerator::writeMethodCall(const Class& classData,
         const Method& method, QTextStream& stream)
 {
-    stream << "QDBusMessage " << className << "::call" << method.name
+    stream << "QDBusMessage " << classData.name << "::call" << method.name
            << "(const QDBusMessage& message)" << endl;;
 
     stream << "{" << endl;
@@ -461,7 +461,37 @@
     stream << "    }" << endl;
     stream << "    else" << endl;
     stream << "    {" << endl;
+
+    stream << "        if (!error.isValid())" << endl;
+    stream << "        {" << endl;
+    stream << "            qWarning(\"Call to implementation of ";
+
+    QStringList::const_iterator nsIt    = classData.namespaces.begin();
+    QStringList::const_iterator nsEndIt = classData.namespaces.end();
+    for (; nsIt != nsEndIt; ++nsIt)
+    {
+        stream << *nsIt << "::";
+    }
+
+    stream  << classData.name << "::" << method.name;
+    stream << " returned 'false' but error object is not valid!\");" << endl;
+    stream << endl;
+    stream << "            error = QDBusError(\"org.freedesktop.DBus.Error.Failed\""
+              ", \"";
+
+    nsIt    = classData.namespaces.begin();
+    for (; nsIt != nsEndIt; ++nsIt)
+    {
+        stream << *nsIt << ".";
+    }
+
+    stream << classData.name << "." << method.name << " execution failed\");"
+           << endl;
+    stream << "        }" << endl;
+    stream << endl;
+
     stream << "        reply = QDBusMessage::methodError(message, error);" << endl;
+
     stream << "    }" << endl;
     stream << endl;
     stream << "    return reply;" << endl;
--- branches/work/dbus-qt4-qt3backport/tools/dbusxml2qt3/methodgen.h #629201:629202
@@ -88,7 +88,7 @@
     static void writeMethodCallDeclaration(const Method& method,
                                            QTextStream& stream);
 
-    static void writeMethodCall(const QString& className, const Method& method,
+    static void writeMethodCall(const Class& classData, const Method& method,
                                 QTextStream& stream);
 
     static void writeSignalEmitter(const Class& classData, const Method& method,
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic