From 89b754d30eaa5c9c57fb50bc563a3c60cc314c4e Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 16 Feb 2011 10:29:50 +0100 Subject: Use QElapsedTimer in QFutureInterface. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QElapsedTimer can also keep its on vlaid/invalid state, so we don't need to keep an additional boolean. Task-number: https://projects.maemo.org/bugzilla/show_bug.cgi?id=227660 Reviewed-by: Morten Sørvig --- src/corelib/concurrent/qfutureinterface.cpp | 9 +++++---- src/corelib/concurrent/qfutureinterface_p.h | 5 ++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/corelib/concurrent/qfutureinterface.cpp b/src/corelib/concurrent/qfutureinterface.cpp index 6256944..627d0c7 100644 --- a/src/corelib/concurrent/qfutureinterface.cpp +++ b/src/corelib/concurrent/qfutureinterface.cpp @@ -421,9 +421,11 @@ bool QFutureInterfaceBase::referenceCountIsOne() const QFutureInterfaceBasePrivate::QFutureInterfaceBasePrivate(QFutureInterfaceBase::State initialState) : refCount(1), m_progressValue(0), m_progressMinimum(0), m_progressMaximum(0), - state(initialState), progressTimeStarted(false), pendingResults(0), + state(initialState), pendingResults(0), manualProgress(false), m_expectedResultCount(0), runnable(0) -{ } +{ + progressTime.invalidate(); +} int QFutureInterfaceBasePrivate::internal_resultCount() const { @@ -455,12 +457,11 @@ bool QFutureInterfaceBasePrivate::internal_updateProgress(int progress, m_progressValue = progress; m_progressText = progressText; - if (progressTimeStarted == true && m_progressValue != m_progressMaximum) // make sure the first and last steps are emitted. + if (progressTime.isValid() && m_progressValue != m_progressMaximum) // make sure the first and last steps are emitted. if (progressTime.elapsed() < (1000 / MaxProgressEmitsPerSecond)) return false; progressTime.start(); - progressTimeStarted = true; return true; } diff --git a/src/corelib/concurrent/qfutureinterface_p.h b/src/corelib/concurrent/qfutureinterface_p.h index 7f93c75..538947e 100644 --- a/src/corelib/concurrent/qfutureinterface_p.h +++ b/src/corelib/concurrent/qfutureinterface_p.h @@ -53,7 +53,7 @@ // We mean it. // -#include +#include #include #include #include @@ -137,8 +137,7 @@ public: int m_progressMinimum; int m_progressMaximum; QFutureInterfaceBase::State state; - QTime progressTime; - bool progressTimeStarted; + QElapsedTimer progressTime; QWaitCondition pausedWaitCondition; int pendingResults; QtConcurrent::ResultStoreBase m_results; -- cgit v0.12 From df129c2449181869f0b95ae92d174b9eca52b2f7 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 16 Feb 2011 11:06:08 +0100 Subject: Add a mutex to protect the access to the QSet. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In theory, there should be no problems with doing this unlocked, as the test should only run one thread at a time in this particular code section. In practice, if the test is failing, multiple threads would be modifying the QSet. So the mutex is necessary to detect the test failing. Reviewed-By: Morten Sørvig --- .../auto/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/auto/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp b/tests/auto/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp index a6499ff..92e8608 100644 --- a/tests/auto/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp +++ b/tests/auto/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp @@ -201,6 +201,7 @@ void tst_QtConcurrentIterateKernel::noIterations() startThreadEngine(new IterateKernel(0, 0)).startBlocking(); } +QMutex threadsMutex; QSet threads; class ThrottleFor : public IterateKernel { @@ -219,8 +220,10 @@ public: QThread *thread = QThread::currentThread(); - if (begin > 140 && end < 160) + if (begin > 140 && end < 160) { + QMutexLocker locker(&threadsMutex); threads.insert(thread); + } if (100 >= begin && 100 < end) { throttling = true; -- cgit v0.12 From 02f2ac6d090547f5b13534d77fe7761d6f236fb2 Mon Sep 17 00:00:00 2001 From: Martin Petersson Date: Wed, 16 Feb 2011 12:46:36 +0100 Subject: SSL: fix memory leak when loading certificates on Mac OS X Reviewed-by: Markus Goetz --- src/network/ssl/qsslsocket_openssl.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp index 7d21bd3..84e14ff 100644 --- a/src/network/ssl/qsslsocket_openssl.cpp +++ b/src/network/ssl/qsslsocket_openssl.cpp @@ -780,6 +780,7 @@ QList QSslSocketPrivate::systemCaCertificates() systemCerts.append(QSslCertificate::fromData(rawCert, QSsl::Der)); } } + CFRelease(cfCerts); } else { // no detailed error handling here -- cgit v0.12 From dfde84cccb14b109bebd672108a0ce0d6131361f Mon Sep 17 00:00:00 2001 From: Ademar de Souza Reis Jr Date: Wed, 16 Feb 2011 17:05:55 -0300 Subject: Bump QtWebKit version to 2.0.2 QtWebKit 2.0.1 was part of Qt-4.7.1, QtWebKit as included in 4.7.2 should be 2.0.2. Merge-request: 1095 Task-number: QTBUG-17480 Reviewed-by: Jason McDonald --- src/3rdparty/webkit/WebKit/qt/Api/qwebkitglobal.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebkitglobal.h b/src/3rdparty/webkit/WebKit/qt/Api/qwebkitglobal.h index 63d9e55..2c0bf6d 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebkitglobal.h +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebkitglobal.h @@ -22,9 +22,9 @@ #include -#define QTWEBKIT_VERSION_STR "2.0.1" +#define QTWEBKIT_VERSION_STR "2.0.2" // QTWEBKIT_VERSION is (major << 16) + (minor << 8) + patch. Similar to Qt. -#define QTWEBKIT_VERSION 0x020001 +#define QTWEBKIT_VERSION 0x020002 // Use: #if (QTWEBKIT_VERSION >= QTWEBKIT_VERSION_CHECK(2, 0, 0)). Similar to Qt. #define QTWEBKIT_VERSION_CHECK(major, minor, patch) ((major<<16)|(minor<<8)|(patch)) -- cgit v0.12 From baed5fdbc1d14e3190b9834f00be9926f9600d62 Mon Sep 17 00:00:00 2001 From: Denis Oliver Kropp Date: Thu, 17 Feb 2011 15:28:47 +0100 Subject: fix-layer-getsurface-result-check-for-screen-size-determination GetSurface() was checked for NOT returning DFB_OK, but it should Merge-request: 2528 Reviewed-by: Marcel Schuette --- src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index 09cc465..ff15078 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -1285,7 +1285,7 @@ bool QDirectFBScreen::connect(const QString &displaySpec) result = d_ptr->primarySurface->GetSize(d_ptr->primarySurface, &w, &h); #elif (Q_DIRECTFB_VERSION >= 0x010000) IDirectFBSurface *layerSurface; - if (d_ptr->dfbLayer->GetSurface(d_ptr->dfbLayer, &layerSurface) != DFB_OK) { + if (d_ptr->dfbLayer->GetSurface(d_ptr->dfbLayer, &layerSurface) == DFB_OK) { result = layerSurface->GetSize(layerSurface, &w, &h); layerSurface->Release(layerSurface); } -- cgit v0.12 From 1b5ee40f491daf0f0b1d44b648ffb7b0ca8b8a63 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 10 Feb 2011 11:23:17 +0100 Subject: Make the QtDBus parser not complain about unknown things Keep only the warnings about application errors. If the unknown things come from the outside, it's not our job to make noise. Task-number: QTBUG-17476 --- src/dbus/qdbusdemarshaller.cpp | 14 +++---- src/dbus/qdbusxmlparser.cpp | 52 +++++++++++++----------- tests/auto/qdbusxmlparser/tst_qdbusxmlparser.cpp | 13 +++--- 3 files changed, 43 insertions(+), 36 deletions(-) diff --git a/src/dbus/qdbusdemarshaller.cpp b/src/dbus/qdbusdemarshaller.cpp index ab1455f..91dbf25 100644 --- a/src/dbus/qdbusdemarshaller.cpp +++ b/src/dbus/qdbusdemarshaller.cpp @@ -176,10 +176,10 @@ QDBusArgument::ElementType QDBusDemarshaller::currentType() case DBUS_TYPE_INVALID: return QDBusArgument::UnknownType; - default: - qWarning("QDBusDemarshaller: Found unknown D-Bus type %d '%c'", - q_dbus_message_iter_get_arg_type(&iterator), - q_dbus_message_iter_get_arg_type(&iterator)); +// default: +// qWarning("QDBusDemarshaller: Found unknown D-Bus type %d '%c'", +// q_dbus_message_iter_get_arg_type(&iterator), +// q_dbus_message_iter_get_arg_type(&iterator)); } return QDBusArgument::UnknownType; } @@ -232,9 +232,9 @@ QVariant QDBusDemarshaller::toVariantInternal() return qVariantFromValue(duplicate()); default: - qWarning("QDBusDemarshaller: Found unknown D-Bus type %d '%c'", - q_dbus_message_iter_get_arg_type(&iterator), - q_dbus_message_iter_get_arg_type(&iterator)); +// qWarning("QDBusDemarshaller: Found unknown D-Bus type %d '%c'", +// q_dbus_message_iter_get_arg_type(&iterator), +// q_dbus_message_iter_get_arg_type(&iterator)); return QVariant(); break; }; diff --git a/src/dbus/qdbusxmlparser.cpp b/src/dbus/qdbusxmlparser.cpp index 1b99ced..413ebbe 100644 --- a/src/dbus/qdbusxmlparser.cpp +++ b/src/dbus/qdbusxmlparser.cpp @@ -52,6 +52,13 @@ #ifndef QT_NO_DBUS +//#define QDBUS_PARSER_DEBUG +#ifdef QDBUS_PARSER_DEBUG +# define qDBusParserError qWarning +#else +# define qDBusParserError if (true) {} else qDebug +#endif + QT_BEGIN_NAMESPACE static QDBusIntrospection::Annotations @@ -69,8 +76,8 @@ parseAnnotations(const QDomElement& elem) value = ann.attribute(QLatin1String("value")); if (!QDBusUtil::isValidInterfaceName(name)) { - qWarning("Invalid D-BUS annotation '%s' found while parsing introspection", - qPrintable(name)); + qDBusParserError("Invalid D-BUS annotation '%s' found while parsing introspection", + qPrintable(name)); continue; } @@ -99,9 +106,8 @@ parseArgs(const QDomElement& elem, const QLatin1String& direction, bool acceptEm argData.name = arg.attribute(QLatin1String("name")); // can be empty argData.type = arg.attribute(QLatin1String("type")); if (!QDBusUtil::isValidSingleSignature(argData.type)) { - qWarning("Invalid D-BUS type signature '%s' found while parsing introspection", - qPrintable(argData.type)); - continue; + qDBusParserError("Invalid D-BUS type signature '%s' found while parsing introspection", + qPrintable(argData.type)); } retval << argData; @@ -141,8 +147,8 @@ QDBusXmlParser::interfaces() const if (iface.isNull()) continue; // for whatever reason if (!QDBusUtil::isValidInterfaceName(ifaceName)) { - qWarning("Invalid D-BUS interface name '%s' found while parsing introspection", - qPrintable(ifaceName)); + qDBusParserError("Invalid D-BUS interface name '%s' found while parsing introspection", + qPrintable(ifaceName)); continue; } @@ -166,8 +172,8 @@ QDBusXmlParser::interfaces() const if (method.isNull()) continue; if (!QDBusUtil::isValidMemberName(methodName)) { - qWarning("Invalid D-BUS member name '%s' found in interface '%s' while parsing introspection", - qPrintable(methodName), qPrintable(ifaceName)); + qDBusParserError("Invalid D-BUS member name '%s' found in interface '%s' while parsing introspection", + qPrintable(methodName), qPrintable(ifaceName)); continue; } @@ -192,8 +198,8 @@ QDBusXmlParser::interfaces() const if (signal.isNull()) continue; if (!QDBusUtil::isValidMemberName(signalName)) { - qWarning("Invalid D-BUS member name '%s' found in interface '%s' while parsing introspection", - qPrintable(signalName), qPrintable(ifaceName)); + qDBusParserError("Invalid D-BUS member name '%s' found in interface '%s' while parsing introspection", + qPrintable(signalName), qPrintable(ifaceName)); continue; } @@ -217,8 +223,8 @@ QDBusXmlParser::interfaces() const if (property.isNull()) continue; if (!QDBusUtil::isValidMemberName(propertyName)) { - qWarning("Invalid D-BUS member name '%s' found in interface '%s' while parsing introspection", - qPrintable(propertyName), qPrintable(ifaceName)); + qDBusParserError("Invalid D-BUS member name '%s' found in interface '%s' while parsing introspection", + qPrintable(propertyName), qPrintable(ifaceName)); continue; } @@ -231,9 +237,9 @@ QDBusXmlParser::interfaces() const if (!QDBusUtil::isValidSingleSignature(propertyData.type)) { // cannot be! - qWarning("Invalid D-BUS type signature '%s' found in property '%s.%s' while parsing introspection", - qPrintable(propertyData.type), qPrintable(ifaceName), - qPrintable(propertyName)); + qDBusParserError("Invalid D-BUS type signature '%s' found in property '%s.%s' while parsing introspection", + qPrintable(propertyData.type), qPrintable(ifaceName), + qPrintable(propertyName)); continue; } @@ -245,9 +251,9 @@ QDBusXmlParser::interfaces() const else if (access == QLatin1String("readwrite")) propertyData.access = QDBusIntrospection::Property::ReadWrite; else { - qWarning("Invalid D-BUS property access '%s' found in property '%s.%s' while parsing introspection", - qPrintable(access), qPrintable(ifaceName), - qPrintable(propertyName)); + qDBusParserError("Invalid D-BUS property access '%s' found in property '%s.%s' while parsing introspection", + qPrintable(access), qPrintable(ifaceName), + qPrintable(propertyName)); continue; // invalid one! } @@ -286,8 +292,8 @@ QDBusXmlParser::object() const if (obj.isNull()) continue; // for whatever reason if (!QDBusUtil::isValidObjectPath(m_path + QLatin1Char('/') + objName)) { - qWarning("Invalid D-BUS object path '%s/%s' found while parsing introspection", - qPrintable(m_path), qPrintable(objName)); + qDBusParserError("Invalid D-BUS object path '%s/%s' found while parsing introspection", + qPrintable(m_path), qPrintable(objName)); continue; } @@ -301,8 +307,8 @@ QDBusXmlParser::object() const if (iface.isNull()) continue; if (!QDBusUtil::isValidInterfaceName(ifaceName)) { - qWarning("Invalid D-BUS interface name '%s' found while parsing introspection", - qPrintable(ifaceName)); + qDBusParserError("Invalid D-BUS interface name '%s' found while parsing introspection", + qPrintable(ifaceName)); continue; } diff --git a/tests/auto/qdbusxmlparser/tst_qdbusxmlparser.cpp b/tests/auto/qdbusxmlparser/tst_qdbusxmlparser.cpp index 25595c5..f83795c 100644 --- a/tests/auto/qdbusxmlparser/tst_qdbusxmlparser.cpp +++ b/tests/auto/qdbusxmlparser/tst_qdbusxmlparser.cpp @@ -287,11 +287,14 @@ void tst_QDBusXmlParser::methods_data() "" << map; // one invalid arg + method.inputArgs << arg("~", "invalid"); + map.clear(); + map << method; QTest::newRow("two-in-one-invalid") << "" "" - "" // this line should be ignored "" + "" "" << map; // one out argument @@ -380,8 +383,6 @@ void tst_QDBusXmlParser::methods() QFETCH(QString, xmlDataFragment); - if (strcmp(QTest::currentDataTag(), "two-in-one-invalid") == 0) - QTest::ignoreMessage(QtWarningMsg, "Invalid D-BUS type signature '~' found while parsing introspection"); QDBusIntrospection::Interface iface = QDBusIntrospection::parseInterface(xmlHeader + xmlDataFragment + xmlFooter); @@ -390,9 +391,9 @@ void tst_QDBusXmlParser::methods() QFETCH(MethodMap, methodMap); MethodMap parsedMap = iface.methods; - QCOMPARE(methodMap.count(), parsedMap.count()); - QCOMPARE(methodMap, parsedMap); -} + QCOMPARE(parsedMap.count(), methodMap.count()); + QCOMPARE(parsedMap, methodMap); +} void tst_QDBusXmlParser::signals__data() { -- cgit v0.12 From 5b53b44a2be8478adeee4a9e4796345828ad0248 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 10 Feb 2011 13:05:53 +0100 Subject: Autotest: add a new test for parsing an introspection with unknown types Task-number: QTBUG-17476 --- tests/auto/qdbusinterface/tst_qdbusinterface.cpp | 35 ++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/tests/auto/qdbusinterface/tst_qdbusinterface.cpp b/tests/auto/qdbusinterface/tst_qdbusinterface.cpp index c1938b1..37e1c64 100644 --- a/tests/auto/qdbusinterface/tst_qdbusinterface.cpp +++ b/tests/auto/qdbusinterface/tst_qdbusinterface.cpp @@ -169,6 +169,25 @@ public slots: int MyObject::callCount = 0; QVariantList MyObject::callArgs; +class MyObjectUnknownType: public QObject +{ + Q_OBJECT + Q_CLASSINFO("D-Bus Interface", "com.trolltech.QtDBus.MyObject") + Q_CLASSINFO("D-Bus Introspection", "" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" + "") +}; + class Spy: public QObject { Q_OBJECT @@ -228,6 +247,7 @@ private slots: void notValidDerived(); void invalidAfterServiceOwnerChanged(); void introspect(); + void introspectUnknownTypes(); void callMethod(); void invokeMethod(); void invokeMethodWithReturn(); @@ -250,8 +270,7 @@ void tst_QDBusInterface::initTestCase() con.registerObject("/", &obj, QDBusConnection::ExportAllProperties | QDBusConnection::ExportAllSlots - | QDBusConnection::ExportAllInvokables - | QDBusConnection::ExportChildObjects); + | QDBusConnection::ExportAllInvokables); } void tst_QDBusInterface::notConnected() @@ -322,6 +341,18 @@ void tst_QDBusInterface::introspect() QVERIFY(mo->indexOfProperty("complexProp") != -1); } +void tst_QDBusInterface::introspectUnknownTypes() +{ + QDBusConnection con = QDBusConnection::sessionBus(); + MyObjectUnknownType obj; + con.registerObject("/unknownTypes", &obj, QDBusConnection::ExportAllContents); + QDBusInterface iface(QDBusConnection::sessionBus().baseService(), QLatin1String("/unknownTypes"), + "com.trolltech.QtDBus.MyObjectUnknownTypes"); + + const QMetaObject *mo = iface.metaObject(); + QVERIFY(mo->indexOfMethod("regularMethod()") != -1); +} + void tst_QDBusInterface::callMethod() { QDBusConnection con = QDBusConnection::sessionBus(); -- cgit v0.12 From cc2db7a49c9208a00a913f7c4a410009814a5580 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 10 Feb 2011 13:26:56 +0100 Subject: QtDBus meta object: keep methods, signals and props with unknown types Use VoidStar as the metatype, with an unknown type called "QDBusRawType". The actual D-Bus type is saved as an hex value as a template parameter. D-Bus type Qt type comment h QDBusRawType<0x68>* Unix file descriptors ~ QDBusRawType<0x7e>* invalid type ai QDBusRawType<0x6169>* array of int32 a{i(ssy)} QDBusRawType<0x617b6928737379297d>* Note that the number in the template doesn't have to be valid. The QDBusRawType class doesn't exist anyway. I thought of just leaving the raw D-Bus type there, but who knows what kind of things can appear there, like other '>' (which may cause problems for anything trying to parse the meta object later). Task-number: QTBUG-17476 --- src/dbus/qdbusmetaobject.cpp | 21 +++++++++++++-------- src/dbus/qdbusxmlparser.cpp | 1 - tests/auto/qdbusinterface/tst_qdbusinterface.cpp | 11 ++++++++++- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/dbus/qdbusmetaobject.cpp b/src/dbus/qdbusmetaobject.cpp index 6683505..df8bc1d 100644 --- a/src/dbus/qdbusmetaobject.cpp +++ b/src/dbus/qdbusmetaobject.cpp @@ -193,14 +193,19 @@ QDBusMetaObjectGenerator::findType(const QByteArray &signature, QByteArray typeName = annotations.value(annotationName).toLatin1(); // verify that it's a valid one - if (typeName.isEmpty()) - return result; // invalid - - type = QVariant::nameToType(typeName); - if (type == QVariant::UserType) - type = QMetaType::type(typeName); - if (type == QVariant::Invalid || signature != QDBusMetaType::typeToSignature(type)) - return result; // unknown type is invalid too + if (!typeName.isEmpty()) { + // type name found + type = QVariant::nameToType(typeName); + if (type == QVariant::UserType) + type = QMetaType::type(typeName); + } + + if (type == QVariant::Invalid || signature != QDBusMetaType::typeToSignature(type)) { + // type is still unknown or doesn't match back to the signature that it + // was expected to, so synthesize a fake type + type = QMetaType::VoidStar; + typeName = "QDBusRawType<0x" + signature.toHex() + ">*"; + } result.name = typeName; } else if (type == QVariant::Invalid) { diff --git a/src/dbus/qdbusxmlparser.cpp b/src/dbus/qdbusxmlparser.cpp index 413ebbe..3feedde 100644 --- a/src/dbus/qdbusxmlparser.cpp +++ b/src/dbus/qdbusxmlparser.cpp @@ -240,7 +240,6 @@ QDBusXmlParser::interfaces() const qDBusParserError("Invalid D-BUS type signature '%s' found in property '%s.%s' while parsing introspection", qPrintable(propertyData.type), qPrintable(ifaceName), qPrintable(propertyName)); - continue; } QString access = property.attribute(QLatin1String("access")); diff --git a/tests/auto/qdbusinterface/tst_qdbusinterface.cpp b/tests/auto/qdbusinterface/tst_qdbusinterface.cpp index 37e1c64..39f0677 100644 --- a/tests/auto/qdbusinterface/tst_qdbusinterface.cpp +++ b/tests/auto/qdbusinterface/tst_qdbusinterface.cpp @@ -350,7 +350,16 @@ void tst_QDBusInterface::introspectUnknownTypes() "com.trolltech.QtDBus.MyObjectUnknownTypes"); const QMetaObject *mo = iface.metaObject(); - QVERIFY(mo->indexOfMethod("regularMethod()") != -1); + QVERIFY(mo->indexOfMethod("regularMethod()") != -1); // this is the control + QVERIFY(mo->indexOfMethod("somethingHappened(QDBusRawType<0x7e>*)") != -1); + + QVERIFY(mo->indexOfMethod("ping(QDBusRawType<0x7e>*)") != -1); + int midx = mo->indexOfMethod("ping(QDBusRawType<0x7e>*)"); + QCOMPARE(mo->method(midx).typeName(), "QDBusRawType<0x7e>*"); + + QVERIFY(mo->indexOfProperty("prop1") != -1); + int pidx = mo->indexOfProperty("prop1"); + QCOMPARE(mo->property(pidx).typeName(), "QDBusRawType<0x7e>*"); } void tst_QDBusInterface::callMethod() -- cgit v0.12 From 1d8ebff955d357d3723487308e2906a12c6c043b Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 10 Feb 2011 14:38:35 +0100 Subject: QtDBus: Make sure we can receive unknown types We must make sure we advance the receiving iterator, or we end up in an infinite loop. Task-number: QTBUG-17476 --- src/dbus/qdbusdemarshaller.cpp | 7 +- tests/auto/qdbusmarshall/test/test.pro | 3 +- tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp | 107 ++++++++++++++++++++++++- 3 files changed, 114 insertions(+), 3 deletions(-) diff --git a/src/dbus/qdbusdemarshaller.cpp b/src/dbus/qdbusdemarshaller.cpp index 91dbf25..ac3b5fa 100644 --- a/src/dbus/qdbusdemarshaller.cpp +++ b/src/dbus/qdbusdemarshaller.cpp @@ -235,7 +235,12 @@ QVariant QDBusDemarshaller::toVariantInternal() // qWarning("QDBusDemarshaller: Found unknown D-Bus type %d '%c'", // q_dbus_message_iter_get_arg_type(&iterator), // q_dbus_message_iter_get_arg_type(&iterator)); - return QVariant(); + char *ptr = 0; + ptr += q_dbus_message_iter_get_arg_type(&iterator); + q_dbus_message_iter_next(&iterator); + + // I hope you never dereference this pointer! + return QVariant::fromValue(ptr); break; }; } diff --git a/tests/auto/qdbusmarshall/test/test.pro b/tests/auto/qdbusmarshall/test/test.pro index 8901999..71fc656 100644 --- a/tests/auto/qdbusmarshall/test/test.pro +++ b/tests/auto/qdbusmarshall/test/test.pro @@ -5,4 +5,5 @@ TARGET = ../tst_qdbusmarshall QT = core QT += dbus - +LIBS += $$QT_LIBS_DBUS +QMAKE_CXXFLAGS += $$QT_CFLAGS_DBUS diff --git a/tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp b/tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp index c05e49c..0d28dbd 100644 --- a/tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp +++ b/tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp @@ -38,7 +38,6 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#define DBUS_API_SUBJECT_TO_CHANGE #include #include #include @@ -47,6 +46,8 @@ #include "common.h" #include +#include + static const char serviceName[] = "com.trolltech.autotests.qpong"; static const char objectPath[] = "/com/trolltech/qpong"; static const char *interfaceName = serviceName; @@ -88,6 +89,9 @@ private slots: void sendCallErrors_data(); void sendCallErrors(); + void receiveUnknownType_data(); + void receiveUnknownType(); + private: QProcess proc; }; @@ -938,5 +942,106 @@ void tst_QDBusMarshall::sendCallErrors() QCOMPARE(reply.errorMessage(), errorMsg); } +void tst_QDBusMarshall::receiveUnknownType_data() +{ + QTest::newRow("in-call"); + QTest::newRow("type-variant"); + QTest::newRow("type-array"); + QTest::newRow("type-struct"); + QTest::newRow("type-naked"); +} + +void tst_QDBusMarshall::receiveUnknownType() +{ +#ifndef DBUS_TYPE_UNIX_FD + QSKIP("Your system's D-Bus library is too old for this test", SkipAll); +#else + QDBusConnection con = QDBusConnection::sessionBus(); + QVERIFY(con.isConnected()); + + // this needs to be implemented in raw + // open a new connection to the bus daemon + DBusError error; + dbus_error_init(&error); + DBusConnection *rawcon = dbus_bus_get_private(DBUS_BUS_SESSION, &error); + QVERIFY2(rawcon, error.name); + + // check if this bus supports passing file descriptors + if (!dbus_connection_can_send_type(rawcon, DBUS_TYPE_UNIX_FD)) + QSKIP("Your session bus does not allow sending Unix file descriptors", SkipAll); + + if (qstrcmp(QTest::currentDataTag(), "in-call") == 0) { + // create a call back to us containing a file descriptor + DBusMessage *msg = dbus_message_new_method_call(con.baseService().toLatin1(), "/irrelevant/path", NULL, "irrelevantMethod"); + + int fd = fileno(stdout); + dbus_message_append_args(msg, DBUS_TYPE_UNIX_FD, &fd, DBUS_TYPE_INVALID); + + // try to send to us + DBusPendingCall *pending; + dbus_connection_send_with_reply(rawcon, msg, &pending, 1000); + dbus_message_unref(msg); + + // check that it got sent + while (dbus_connection_dispatch(rawcon) == DBUS_DISPATCH_DATA_REMAINS) + ; + + // now spin our event loop. We don't catch this call, so let's get the reply + QEventLoop loop; + QTimer::singleShot(200, &loop, SLOT(quit())); + loop.exec(); + + // now try to receive the reply + dbus_pending_call_block(pending); + msg = dbus_pending_call_steal_reply(pending); + dbus_pending_call_unref(pending); + QVERIFY(msg); + QCOMPARE(dbus_message_get_type(msg), DBUS_MESSAGE_TYPE_ERROR); + QCOMPARE(dbus_message_get_error_name(msg), "org.freedesktop.DBus.Error.UnknownObject"); + qDebug() << dbus_message_get_signature(msg); + } else { + // create a signal that we'll emit + static const char signalName[] = "signalName"; + static const char interfaceName[] = "local.interface.name"; + DBusMessage *msg = dbus_message_new_signal("/", interfaceName, signalName); + con.connect(dbus_bus_get_unique_name(rawcon), QString(), interfaceName, signalName, &QTestEventLoop::instance(), SLOT(exitLoop())); + + DBusMessageIter iter; + dbus_message_iter_init_append(msg, &iter); + int fd = fileno(stdout); + + if (qstrcmp(QTest::currentDataTag(), "type-naked") == 0) { + // send naked + dbus_message_iter_append_basic(&iter, DBUS_TYPE_UNIX_FD, &fd); + } else { + DBusMessageIter subiter; + if (qstrcmp(QTest::currentDataTag(), "type-variant") == 0) + dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT, DBUS_TYPE_UNIX_FD_AS_STRING, &subiter); + else if (qstrcmp(QTest::currentDataTag(), "type-array") == 0) + dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, DBUS_TYPE_UNIX_FD_AS_STRING, &subiter); + else if (qstrcmp(QTest::currentDataTag(), "type-struct") == 0) + dbus_message_iter_open_container(&iter, DBUS_TYPE_STRUCT, 0, &subiter); + dbus_message_iter_append_basic(&subiter, DBUS_TYPE_UNIX_FD, &fd); + dbus_message_iter_close_container(&iter, &subiter); + } + + // send it + dbus_connection_send(rawcon, msg, 0); + dbus_message_unref(msg); + + // check that it got sent + while (dbus_connection_dispatch(rawcon) == DBUS_DISPATCH_DATA_REMAINS) + ; + + // now let's see what happens + QTestEventLoop::instance().enterLoop(1); + QVERIFY(!QTestEventLoop::instance().timeout()); + } + + dbus_connection_close(rawcon); + dbus_connection_unref(rawcon); +#endif +} + QTEST_MAIN(tst_QDBusMarshall) #include "tst_qdbusmarshall.moc" -- cgit v0.12 From ebdbd453a7612b3764b2e423ecb97aa9fb6cd28e Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 10 Feb 2011 15:01:40 +0100 Subject: Autotest: avoid memory leaks if test fails --- tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp | 65 ++++++++++++++++---------- 1 file changed, 41 insertions(+), 24 deletions(-) diff --git a/tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp b/tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp index 0d28dbd..6ad991b 100644 --- a/tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp +++ b/tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp @@ -951,6 +951,29 @@ void tst_QDBusMarshall::receiveUnknownType_data() QTest::newRow("type-naked"); } +struct DisconnectRawDBus { + static void cleanup(DBusConnection *connection) + { + if (!connection) + return; + dbus_connection_close(connection); + dbus_connection_unref(connection); + } +}; +template struct GenericUnref +{ + static void cleanup(T *type) + { + if (!type) return; + unref(type); + } +}; + +// use these scoped types to avoid memory leaks if QVERIFY or QCOMPARE fails +typedef QScopedPointer ScopedDBusConnection; +typedef QScopedPointer > ScopedDBusMessage; +typedef QScopedPointer > ScopedDBusPendingCall; + void tst_QDBusMarshall::receiveUnknownType() { #ifndef DBUS_TYPE_UNIX_FD @@ -963,27 +986,27 @@ void tst_QDBusMarshall::receiveUnknownType() // open a new connection to the bus daemon DBusError error; dbus_error_init(&error); - DBusConnection *rawcon = dbus_bus_get_private(DBUS_BUS_SESSION, &error); - QVERIFY2(rawcon, error.name); + ScopedDBusConnection rawcon(dbus_bus_get_private(DBUS_BUS_SESSION, &error)); + QVERIFY2(rawcon.data(), error.name); // check if this bus supports passing file descriptors - if (!dbus_connection_can_send_type(rawcon, DBUS_TYPE_UNIX_FD)) + if (!dbus_connection_can_send_type(rawcon.data(), DBUS_TYPE_UNIX_FD)) QSKIP("Your session bus does not allow sending Unix file descriptors", SkipAll); if (qstrcmp(QTest::currentDataTag(), "in-call") == 0) { // create a call back to us containing a file descriptor - DBusMessage *msg = dbus_message_new_method_call(con.baseService().toLatin1(), "/irrelevant/path", NULL, "irrelevantMethod"); + ScopedDBusMessage msg(dbus_message_new_method_call(con.baseService().toLatin1(), "/irrelevant/path", NULL, "irrelevantMethod")); int fd = fileno(stdout); - dbus_message_append_args(msg, DBUS_TYPE_UNIX_FD, &fd, DBUS_TYPE_INVALID); + dbus_message_append_args(msg.data(), DBUS_TYPE_UNIX_FD, &fd, DBUS_TYPE_INVALID); // try to send to us - DBusPendingCall *pending; - dbus_connection_send_with_reply(rawcon, msg, &pending, 1000); - dbus_message_unref(msg); + DBusPendingCall *pending_ptr; + dbus_connection_send_with_reply(rawcon.data(), msg.data(), &pending_ptr, 1000); + ScopedDBusPendingCall pending(pending_ptr); // check that it got sent - while (dbus_connection_dispatch(rawcon) == DBUS_DISPATCH_DATA_REMAINS) + while (dbus_connection_dispatch(rawcon.data()) == DBUS_DISPATCH_DATA_REMAINS) ; // now spin our event loop. We don't catch this call, so let's get the reply @@ -992,22 +1015,20 @@ void tst_QDBusMarshall::receiveUnknownType() loop.exec(); // now try to receive the reply - dbus_pending_call_block(pending); - msg = dbus_pending_call_steal_reply(pending); - dbus_pending_call_unref(pending); + dbus_pending_call_block(pending.data()); + msg.reset(dbus_pending_call_steal_reply(pending.data())); QVERIFY(msg); - QCOMPARE(dbus_message_get_type(msg), DBUS_MESSAGE_TYPE_ERROR); - QCOMPARE(dbus_message_get_error_name(msg), "org.freedesktop.DBus.Error.UnknownObject"); - qDebug() << dbus_message_get_signature(msg); + QCOMPARE(dbus_message_get_type(msg.data()), DBUS_MESSAGE_TYPE_ERROR); + QCOMPARE(dbus_message_get_error_name(msg.data()), "org.freedesktop.DBus.Error.UnknownObject"); } else { // create a signal that we'll emit static const char signalName[] = "signalName"; static const char interfaceName[] = "local.interface.name"; - DBusMessage *msg = dbus_message_new_signal("/", interfaceName, signalName); - con.connect(dbus_bus_get_unique_name(rawcon), QString(), interfaceName, signalName, &QTestEventLoop::instance(), SLOT(exitLoop())); + ScopedDBusMessage msg(dbus_message_new_signal("/", interfaceName, signalName)); + con.connect(dbus_bus_get_unique_name(rawcon.data()), QString(), interfaceName, signalName, &QTestEventLoop::instance(), SLOT(exitLoop())); DBusMessageIter iter; - dbus_message_iter_init_append(msg, &iter); + dbus_message_iter_init_append(msg.data(), &iter); int fd = fileno(stdout); if (qstrcmp(QTest::currentDataTag(), "type-naked") == 0) { @@ -1026,20 +1047,16 @@ void tst_QDBusMarshall::receiveUnknownType() } // send it - dbus_connection_send(rawcon, msg, 0); - dbus_message_unref(msg); + dbus_connection_send(rawcon.data(), msg.data(), 0); // check that it got sent - while (dbus_connection_dispatch(rawcon) == DBUS_DISPATCH_DATA_REMAINS) + while (dbus_connection_dispatch(rawcon.data()) == DBUS_DISPATCH_DATA_REMAINS) ; // now let's see what happens QTestEventLoop::instance().enterLoop(1); QVERIFY(!QTestEventLoop::instance().timeout()); } - - dbus_connection_close(rawcon); - dbus_connection_unref(rawcon); #endif } -- cgit v0.12 From 00f689370ce97d557f8af4596c780f381aa66cb7 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 17 Feb 2011 14:25:07 +0100 Subject: Fix warnings in QtDeclarative --- src/declarative/qml/qdeclarativeobjectscriptclass.cpp | 2 +- src/declarative/qml/qdeclarativeproperty.cpp | 2 +- src/declarative/qml/qdeclarativevaluetypescriptclass.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp index 2aa2059..dc3ecca 100644 --- a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp +++ b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp @@ -368,7 +368,7 @@ void QDeclarativeObjectScriptClass::setProperty(QObject *obj, newBinding = new QDeclarativeBinding(value, obj, evalContext); newBinding->setSourceLocation(ctxtInfo.fileName(), ctxtInfo.functionStartLineNumber()); newBinding->setTarget(QDeclarativePropertyPrivate::restore(*lastData, valueTypeData, obj, evalContext)); - if (newBinding->expression().contains("this")) + if (newBinding->expression().contains(QLatin1String("this"))) newBinding->setEvaluateFlags(newBinding->evaluateFlags() | QDeclarativeBinding::RequiresThisObject); } diff --git a/src/declarative/qml/qdeclarativeproperty.cpp b/src/declarative/qml/qdeclarativeproperty.cpp index 61e3002..0dd0edb 100644 --- a/src/declarative/qml/qdeclarativeproperty.cpp +++ b/src/declarative/qml/qdeclarativeproperty.cpp @@ -427,7 +427,7 @@ bool QDeclarativeProperty::operator==(const QDeclarativeProperty &other) const */ int QDeclarativeProperty::propertyType() const { - return d ? d->propertyType() : QVariant::Invalid; + return d ? d->propertyType() : int(QVariant::Invalid); } bool QDeclarativePropertyPrivate::isValueType() const diff --git a/src/declarative/qml/qdeclarativevaluetypescriptclass.cpp b/src/declarative/qml/qdeclarativevaluetypescriptclass.cpp index 200cc1c..4c312b5 100644 --- a/src/declarative/qml/qdeclarativevaluetypescriptclass.cpp +++ b/src/declarative/qml/qdeclarativevaluetypescriptclass.cpp @@ -184,7 +184,7 @@ void QDeclarativeValueTypeScriptClass::setProperty(Object *obj, const Identifier newBinding->setSourceLocation(ctxtInfo.fileName(), ctxtInfo.functionStartLineNumber()); QDeclarativeProperty prop = QDeclarativePropertyPrivate::restore(cacheData, valueTypeData, ref->object, ctxt); newBinding->setTarget(prop); - if (newBinding->expression().contains("this")) + if (newBinding->expression().contains(QLatin1String("this"))) newBinding->setEvaluateFlags(newBinding->evaluateFlags() | QDeclarativeBinding::RequiresThisObject); } -- cgit v0.12 From 426833486c3d801ec4dbce96407ec6e1e6c525f8 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 17 Feb 2011 17:03:13 +0100 Subject: Autotest: be nicer to the subprocess and SIGTERM it --- tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp b/tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp index 6ad991b..d0c9675 100644 --- a/tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp +++ b/tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp @@ -151,7 +151,8 @@ void tst_QDBusMarshall::initTestCase() void tst_QDBusMarshall::cleanupTestCase() { proc.close(); - proc.kill(); + proc.terminate(); + proc.waitForFinished(200); } void tst_QDBusMarshall::sendBasic_data() -- cgit v0.12 From 63bfd78b6a80f608f9b09254d815b6da04f8e2fc Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 16 Feb 2011 14:56:24 +0100 Subject: Autotest: don't use the deprecated signal from QDBusConnectionInterface --- tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp | 56 ++++++++------------------ 1 file changed, 17 insertions(+), 39 deletions(-) diff --git a/tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp b/tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp index d0c9675..0c53087 100644 --- a/tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp +++ b/tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp @@ -99,53 +99,29 @@ private: struct UnregisteredType { }; Q_DECLARE_METATYPE(UnregisteredType) -class WaitForQPong: public QObject -{ - Q_OBJECT -public: - WaitForQPong(); - bool ok(); -public Q_SLOTS: - void ownerChange(const QString &name) - { - if (name == serviceName) - loop.quit(); - } - -private: - QEventLoop loop; -}; - -WaitForQPong::WaitForQPong() -{ - QDBusConnection con = QDBusConnection::sessionBus(); - if (!ok()) { - connect(con.interface(), SIGNAL(serviceOwnerChanged(QString,QString,QString)), - SLOT(ownerChange(QString))); - QTimer::singleShot(2000, &loop, SLOT(quit())); - loop.exec(); - } -} - -bool WaitForQPong::ok() -{ - return QDBusConnection::sessionBus().isConnected() && - QDBusConnection::sessionBus().interface()->isServiceRegistered(serviceName); -} - void tst_QDBusMarshall::initTestCase() { commonInit(); + QDBusConnection con = QDBusConnection::sessionBus(); #ifdef Q_OS_WIN proc.start("qpong"); #else proc.start("./qpong/qpong"); #endif - QVERIFY(proc.waitForStarted()); - - WaitForQPong w; - QVERIFY(w.ok()); - //QTest::qWait(2000); + if (!QDBusConnection::sessionBus().interface()->isServiceRegistered(serviceName)) { + QVERIFY(proc.waitForStarted()); + + QVERIFY(con.isConnected()); + con.connect("org.freedesktop.DBus", QString(), "org.freedesktop.DBus", "NameOwnerChanged", + QStringList() << serviceName << QString(""), QString(), + &QTestEventLoop::instance(), SLOT(exitLoop())); + QTestEventLoop::instance().enterLoop(2); + QVERIFY(!QTestEventLoop::instance().timeout()); + QVERIFY(QDBusConnection::sessionBus().interface()->isServiceRegistered(serviceName)); + con.disconnect("org.freedesktop.DBus", QString(), "org.freedesktop.DBus", "NameOwnerChanged", + QStringList() << serviceName << QString(""), QString(), + &QTestEventLoop::instance(), SLOT(exitLoop())); + } } void tst_QDBusMarshall::cleanupTestCase() @@ -705,6 +681,8 @@ void tst_QDBusMarshall::sendBasic() msg << value; QDBusMessage reply = con.call(msg); + QVERIFY2(reply.type() == QDBusMessage::ReplyMessage, + qPrintable(reply.errorName() + ": " + reply.errorMessage())); //qDebug() << reply; QCOMPARE(reply.arguments().count(), msg.arguments().count()); -- cgit v0.12 From a6e1a7caeb7f03d1c102c250df8e602d5e40ab62 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Thu, 17 Feb 2011 18:37:15 +0100 Subject: Make Qt/DirectFB less verbose about failing to load pixmaps. Qt/DirectFB is way too verbose about not being able to use DirectFB for loading images. A lot of times DirectFB doesn't have support for e.g. pngs or gifs and currently one gets a message for every failed pixmap load, even if they will succeed when falling back to Qt. Merge-request: 2552 Reviewed-by: Marcel Schuette --- src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp index 50e0f5f..eaff74a 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp @@ -245,10 +245,9 @@ bool QDirectFBPixmapData::fromDataBufferDescription(const DFBDataBufferDescripti QDirectFBPointer dataBuffer(dataBufferPtr); IDirectFBImageProvider *providerPtr; - if ((result = dataBuffer->CreateImageProvider(dataBuffer.data(), &providerPtr)) != DFB_OK) { - DirectFBError("QDirectFBPixmapData::fromDataBufferDescription(): Can't create image provider", result); + if ((result = dataBuffer->CreateImageProvider(dataBuffer.data(), &providerPtr)) != DFB_OK) return false; - } + QDirectFBPointer provider(providerPtr); DFBImageDescription imageDescription; -- cgit v0.12 From 1a9ea90144c7131029fdf19950d1f313a64eb4a1 Mon Sep 17 00:00:00 2001 From: Denis Oliver Kropp Date: Thu, 17 Feb 2011 19:01:29 +0100 Subject: directfb: fix crash in client/server mode of qws The server was crashing due to client pointer being sent as "sibling". Instead surface flags are sent and sibling code is removed. Also the window ID is transfered and used on receiver side to get a local handle to the window. Click to focus window works, but it is not raised. Merge-request: 989 Reviewed-by: Marcel Schuette --- .../gfxdrivers/directfb/qdirectfbwindowsurface.cpp | 46 +++++++++++++++------- .../gfxdrivers/directfb/qdirectfbwindowsurface.h | 1 - 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp index d0056a7..3d8cf50 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp @@ -55,7 +55,6 @@ QT_BEGIN_NAMESPACE QDirectFBWindowSurface::QDirectFBWindowSurface(DFBSurfaceFlipFlags flip, QDirectFBScreen *scr) : QDirectFBPaintDevice(scr) - , sibling(0) #ifndef QT_NO_DIRECTFB_WM , dfbWindow(0) #endif @@ -75,7 +74,6 @@ QDirectFBWindowSurface::QDirectFBWindowSurface(DFBSurfaceFlipFlags flip, QDirect QDirectFBWindowSurface::QDirectFBWindowSurface(DFBSurfaceFlipFlags flip, QDirectFBScreen *scr, QWidget *widget) : QWSWindowSurface(widget), QDirectFBPaintDevice(scr) - , sibling(0) #ifndef QT_NO_DIRECTFB_WM , dfbWindow(0) #endif @@ -123,7 +121,7 @@ void QDirectFBWindowSurface::raise() IDirectFBWindow *QDirectFBWindowSurface::directFBWindow() const { - return (dfbWindow ? dfbWindow : (sibling ? sibling->dfbWindow : 0)); + return dfbWindow; } void QDirectFBWindowSurface::createWindow(const QRect &rect) @@ -287,17 +285,40 @@ void QDirectFBWindowSurface::setGeometry(const QRect &rect) QByteArray QDirectFBWindowSurface::permanentState() const { - QByteArray state(sizeof(this), 0); - *reinterpret_cast(state.data()) = this; + QByteArray state(sizeof(SurfaceFlags) + sizeof(DFBWindowID), 0); + char *ptr = state.data(); + SurfaceFlags flags = surfaceFlags(); + memcpy(ptr, &flags, sizeof(SurfaceFlags)); + ptr += sizeof(SurfaceFlags); + DFBWindowID did = (DFBWindowID)(-1); + if (dfbWindow) + dfbWindow->GetID(dfbWindow, &did); + memcpy(ptr, &did, sizeof(DFBWindowID)); return state; } void QDirectFBWindowSurface::setPermanentState(const QByteArray &state) { - if (state.size() == sizeof(this)) { - sibling = *reinterpret_cast(state.constData()); - Q_ASSERT(sibling); - setSurfaceFlags(sibling->surfaceFlags()); + const char *ptr = state.constData(); + IDirectFBDisplayLayer *layer = screen->dfbDisplayLayer(); + SurfaceFlags flags; + memcpy(&flags, ptr, sizeof(SurfaceFlags)); + + setSurfaceFlags(flags); + ptr += sizeof(SurfaceFlags); + DFBWindowID id; + memcpy(&id, ptr, sizeof(DFBWindowID)); + if (dfbSurface) + dfbSurface->Release(dfbSurface); + if (id != (DFBWindowID)-1) { + IDirectFBWindow *dw; + layer->GetWindow(layer, id, &dw); + if (dw->GetSurface(dw, &dfbSurface) != DFB_OK) + dfbSurface = 0; + dw->Release(dw); + } + else { + dfbSurface = 0; } } @@ -406,8 +427,6 @@ void QDirectFBWindowSurface::endPaint(const QRegion &) IDirectFBSurface *QDirectFBWindowSurface::directFBSurface() const { - if (!dfbSurface && sibling && sibling->dfbSurface) - return sibling->dfbSurface; return dfbSurface; } @@ -415,11 +434,8 @@ IDirectFBSurface *QDirectFBWindowSurface::directFBSurface() const IDirectFBSurface *QDirectFBWindowSurface::surfaceForWidget(const QWidget *widget, QRect *rect) const { Q_ASSERT(widget); - if (!dfbSurface) { - if (sibling && (!sibling->sibling || sibling->dfbSurface)) - return sibling->surfaceForWidget(widget, rect); + if (!dfbSurface) return 0; - } QWidget *win = window(); Q_ASSERT(win); if (rect) { diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h index f683fc8..75d462b 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h @@ -100,7 +100,6 @@ private: void updateIsOpaque(); void setOpaque(bool opaque); void releaseSurface(); - QDirectFBWindowSurface *sibling; #ifdef QT_DIRECTFB_WM void createWindow(const QRect &rect); -- cgit v0.12 From d6c1e5d78bdfbeb373970b65d8260f7e9f9ce1bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mauri=20Vehni=C3=A4inen?= Date: Fri, 18 Feb 2011 10:10:08 +0100 Subject: Prevents crashing when ICO file has bad color table value When color table value is read from ICO header memory allocation is made based on this value. This case is relevant only when reading 8bit images. Therefore values over 256 will abort reading the image. Task-number: QT-4535 Merge-request: 1090 Reviewed-by: Harald Fernengel --- src/plugins/imageformats/ico/qicohandler.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/imageformats/ico/qicohandler.cpp b/src/plugins/imageformats/ico/qicohandler.cpp index 5aa26d3..701207d 100644 --- a/src/plugins/imageformats/ico/qicohandler.cpp +++ b/src/plugins/imageformats/ico/qicohandler.cpp @@ -559,6 +559,8 @@ QImage ICOReader::iconAt(int index) icoAttrib.ncolors = 0; else // # colors used icoAttrib.ncolors = header.biClrUsed ? header.biClrUsed : 1 << icoAttrib.nbits; + if (icoAttrib.ncolors > 256) //color table can't be more than 256 + return img; icoAttrib.w = iconEntry.bWidth; if (icoAttrib.w == 0) icoAttrib.w = header.biWidth; -- cgit v0.12 From c658394f1b34c98b141eff22a69a3f4c7bbd4c51 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Fri, 18 Feb 2011 22:03:55 +1000 Subject: Attempt to fix symbian 3.1 and 3.2 compile break. e46c44f9538dbe5b44ce61d3a42403cfa471ae8b restructured qml.pri. In the original version the else part at the bottom of the file was processed for Symbian 3.1 and 3.2, but the commit stopped that from happening. This commit makes the minimal change to make the statements in the else part apply to 3.1 and 3.2 again. Really the file should be restructured to have separate logic for setting each vairable, but I'll leave that task for the developers. Reviewed-by: Eckhart Koppen --- tools/qml/qml.pri | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tools/qml/qml.pri b/tools/qml/qml.pri index 08cd506..650de94 100644 --- a/tools/qml/qml.pri +++ b/tools/qml/qml.pri @@ -19,17 +19,21 @@ SOURCES += $$PWD/qmlruntime.cpp \ RESOURCES = $$PWD/browser/browser.qrc \ $$PWD/startup/startup.qrc -symbian: { - contains(QT_CONFIG, s60): { +symbian { + contains(QT_CONFIG, s60) { LIBS += -lavkon -lcone } !contains(S60_VERSION, 3.1):!contains(S60_VERSION, 3.2) { LIBS += -lsensrvclient -lsensrvutil } - !contains(S60_VERSION, 3.1):!contains(S60_VERSION, 3.2): { + !contains(S60_VERSION, 3.1):!contains(S60_VERSION, 3.2) { SOURCES += $$PWD/deviceorientation_symbian.cpp FORMS = $$PWD/recopts.ui \ $$PWD/proxysettings.ui + } else { + SOURCES += $$PWD/deviceorientation.cpp + FORMS = $$PWD/recopts.ui \ + $$PWD/proxysettings.ui } } else:maemo5 { QT += dbus -- cgit v0.12 From 7b6b9201bdc6435aaa50370c8cf511e47f6e630d Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 16 Feb 2011 14:05:54 +0100 Subject: Autotest: check that the type received is the expected one Task-number: QTBUG-17476 --- tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp | 51 ++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 8 deletions(-) diff --git a/tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp b/tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp index 0c53087..9bae6af 100644 --- a/tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp +++ b/tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp @@ -96,6 +96,19 @@ private: QProcess proc; }; +class QDBusMessageSpy: public QObject +{ + Q_OBJECT +public slots: + Q_SCRIPTABLE int theSlot(const QDBusMessage &msg) + { + list << msg; + return 42; + } +public: + QList list; +}; + struct UnregisteredType { }; Q_DECLARE_METATYPE(UnregisteredType) @@ -923,11 +936,12 @@ void tst_QDBusMarshall::sendCallErrors() void tst_QDBusMarshall::receiveUnknownType_data() { - QTest::newRow("in-call"); - QTest::newRow("type-variant"); - QTest::newRow("type-array"); - QTest::newRow("type-struct"); - QTest::newRow("type-naked"); + QTest::addColumn("receivedTypeId"); + QTest::newRow("in-call") << qMetaTypeId(); + QTest::newRow("type-variant") << qMetaTypeId(); + QTest::newRow("type-array") << qMetaTypeId(); + QTest::newRow("type-struct") << qMetaTypeId(); + QTest::newRow("type-naked") << qMetaTypeId(); } struct DisconnectRawDBus { @@ -974,7 +988,9 @@ void tst_QDBusMarshall::receiveUnknownType() if (qstrcmp(QTest::currentDataTag(), "in-call") == 0) { // create a call back to us containing a file descriptor - ScopedDBusMessage msg(dbus_message_new_method_call(con.baseService().toLatin1(), "/irrelevant/path", NULL, "irrelevantMethod")); + QDBusMessageSpy spy; + con.registerObject("/spyObject", &spy, QDBusConnection::ExportAllSlots); + ScopedDBusMessage msg(dbus_message_new_method_call(con.baseService().toLatin1(), "/spyObject", NULL, "theSlot")); int fd = fileno(stdout); dbus_message_append_args(msg.data(), DBUS_TYPE_UNIX_FD, &fd, DBUS_TYPE_INVALID); @@ -995,10 +1011,21 @@ void tst_QDBusMarshall::receiveUnknownType() // now try to receive the reply dbus_pending_call_block(pending.data()); + + // check that the spy received what it was supposed to receive + QCOMPARE(spy.list.size(), 1); + QCOMPARE(spy.list.at(0).arguments().size(), 1); + QFETCH(int, receivedTypeId); + QCOMPARE(spy.list.at(0).arguments().at(0).userType(), receivedTypeId); + msg.reset(dbus_pending_call_steal_reply(pending.data())); QVERIFY(msg); - QCOMPARE(dbus_message_get_type(msg.data()), DBUS_MESSAGE_TYPE_ERROR); - QCOMPARE(dbus_message_get_error_name(msg.data()), "org.freedesktop.DBus.Error.UnknownObject"); + QCOMPARE(dbus_message_get_type(msg.data()), DBUS_MESSAGE_TYPE_METHOD_RETURN); + QCOMPARE(dbus_message_get_signature(msg.data()), DBUS_TYPE_INT32_AS_STRING); + + int retval; + QVERIFY(dbus_message_get_args(msg.data(), &error, DBUS_TYPE_INT32, &retval, DBUS_TYPE_INVALID)); + QCOMPARE(retval, 42); } else { // create a signal that we'll emit static const char signalName[] = "signalName"; @@ -1006,6 +1033,9 @@ void tst_QDBusMarshall::receiveUnknownType() ScopedDBusMessage msg(dbus_message_new_signal("/", interfaceName, signalName)); con.connect(dbus_bus_get_unique_name(rawcon.data()), QString(), interfaceName, signalName, &QTestEventLoop::instance(), SLOT(exitLoop())); + QDBusMessageSpy spy; + con.connect(dbus_bus_get_unique_name(rawcon.data()), QString(), interfaceName, signalName, &spy, SLOT(theSlot(QDBusMessage))); + DBusMessageIter iter; dbus_message_iter_init_append(msg.data(), &iter); int fd = fileno(stdout); @@ -1035,6 +1065,11 @@ void tst_QDBusMarshall::receiveUnknownType() // now let's see what happens QTestEventLoop::instance().enterLoop(1); QVERIFY(!QTestEventLoop::instance().timeout()); + QCOMPARE(spy.list.size(), 1); + QCOMPARE(spy.list.at(0).arguments().count(), 1); + QFETCH(int, receivedTypeId); + //qDebug() << spy.list.at(0).arguments().at(0).typeName(); + QCOMPARE(spy.list.at(0).arguments().at(0).userType(), receivedTypeId); } #endif } -- cgit v0.12 From d6e509936358141b1fef93852edd10b3b324ec5b Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 19 Feb 2011 13:53:41 +0100 Subject: Doc: setSslConfiguration also sets the CA certificates --- src/network/access/qnetworkrequest.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/network/access/qnetworkrequest.cpp b/src/network/access/qnetworkrequest.cpp index 89f7d44..7eec24e 100644 --- a/src/network/access/qnetworkrequest.cpp +++ b/src/network/access/qnetworkrequest.cpp @@ -529,8 +529,9 @@ QSslConfiguration QNetworkRequest::sslConfiguration() const /*! Sets this network request's SSL configuration to be \a config. The settings that apply are the private key, the local certificate, - the SSL protocol (SSLv2, SSLv3, TLSv1 where applicable) and the - ciphers that the SSL backend is allowed to use. + the SSL protocol (SSLv2, SSLv3, TLSv1 where applicable), the CA + certificates and the ciphers that the SSL backend is allowed to + use. By default, no SSL configuration is set, which allows the backends to choose freely what configuration is best for them. -- cgit v0.12 From ef06cbef2e3240d49848f398b2d19adbbea1e781 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 19 Feb 2011 11:46:22 +0100 Subject: Fix warning about id maybe used when uninitialised The code would indicate it's never used uninitialised, but gcc doesn't know it. --- src/declarative/util/qdeclarativepropertychanges.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/util/qdeclarativepropertychanges.cpp b/src/declarative/util/qdeclarativepropertychanges.cpp index ccd122e..9bcb263 100644 --- a/src/declarative/util/qdeclarativepropertychanges.cpp +++ b/src/declarative/util/qdeclarativepropertychanges.cpp @@ -281,7 +281,7 @@ QDeclarativePropertyChangesParser::compile(const QList(data.at(ii).second); QVariant var; bool isScript = v.isScript(); - QDeclarativeBinding::Identifier id; + QDeclarativeBinding::Identifier id = 0; switch(v.type()) { case QDeclarativeParser::Variant::Boolean: var = QVariant(v.asBoolean()); -- cgit v0.12 From 13e9642616ab480d09bda2603cc89dcaea7a1ad6 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sun, 20 Feb 2011 15:37:06 +0100 Subject: Autotest: make at least one update before checking if more are needed The timer gets started only by making updates. If you try to check if an update is needed without making the first update, the timer won't be started and the function will return false. --- tests/auto/qfuturewatcher/tst_qfuturewatcher.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/auto/qfuturewatcher/tst_qfuturewatcher.cpp b/tests/auto/qfuturewatcher/tst_qfuturewatcher.cpp index 2ca1a47..9875fb5 100644 --- a/tests/auto/qfuturewatcher/tst_qfuturewatcher.cpp +++ b/tests/auto/qfuturewatcher/tst_qfuturewatcher.cpp @@ -484,8 +484,6 @@ class ProgressTextTask : public RunFunctionTask public: void runFunctor() { - while (this->isProgressUpdateNeeded() == false) - QTest::qSleep(1); this->setProgressValueAndText(1, QLatin1String("Foo 1")); while (this->isProgressUpdateNeeded() == false) @@ -495,6 +493,10 @@ public: while (this->isProgressUpdateNeeded() == false) QTest::qSleep(1); this->setProgressValueAndText(3, QLatin1String("Foo 3")); + + while (this->isProgressUpdateNeeded() == false) + QTest::qSleep(1); + this->setProgressValueAndText(4, QLatin1String("Foo 4")); } }; @@ -522,14 +524,16 @@ void tst_QFutureWatcher::progressText() QTestEventLoop::instance().enterLoop(5); QVERIFY(!QTestEventLoop::instance().timeout()); - QCOMPARE(f.progressText(), QLatin1String("Foo 3")); - QCOMPARE(f.progressValue(), 3); + QCOMPARE(f.progressText(), QLatin1String("Foo 4")); + QCOMPARE(f.progressValue(), 4); QVERIFY(progressValues.contains(1)); QVERIFY(progressValues.contains(2)); QVERIFY(progressValues.contains(3)); + QVERIFY(progressValues.contains(4)); QVERIFY(progressTexts.contains(QLatin1String("Foo 1"))); QVERIFY(progressTexts.contains(QLatin1String("Foo 2"))); QVERIFY(progressTexts.contains(QLatin1String("Foo 3"))); + QVERIFY(progressTexts.contains(QLatin1String("Foo 4"))); } } -- cgit v0.12