From 4cedc55327d79aeee18c602fa0822283b27a74e9 Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Mon, 21 Jul 2014 12:40:00 +0200 Subject: Windows: Add Qt Creator PATH update tip for missing SQL client dlls This patch aims to provide an additional tip for users having trouble with e.g. the MySQL plugin. After a successful build most users are struggling with loading failure due the fact that the client libraries folder is not contained in the PATH environment variable. This tip helps them overcome that in a controlled manner with Qt Creator. Change-Id: I2dc5c9c6d8d8976686d74c369b6e1683c479f35c Reviewed-by: Jerome Pasion --- src/sql/doc/src/sql-driver.qdoc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/sql/doc/src/sql-driver.qdoc b/src/sql/doc/src/sql-driver.qdoc index 9858e30ff9..71d2fb4f85 100644 --- a/src/sql/doc/src/sql-driver.qdoc +++ b/src/sql/doc/src/sql-driver.qdoc @@ -700,7 +700,10 @@ system. On Unix, run the command \c{ldd} and pass the name of the plugin as parameter, for example \c{ldd libqsqlmysql.so}. You will get a warning if any of the client libraries couldn't be found. - On Windows, you can use Visual Studio's dependency walker. + On Windows, you can use Visual Studio's dependency walker. With + Qt Creator, you can update the \c PATH environment variable in the + \gui Run section of the \gui Project panel to include the path to + the folder containing the client libraries. \li Compile Qt with \c{QT_DEBUG_COMPONENT} defined to get very verbose debug output when loading plugins. \endlist -- cgit v1.2.3 From b0d0a2680afffe02713ee4110c7996ee423c1d1e Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 22 Jul 2014 13:45:58 +0200 Subject: QPixmap::fromImage() should detach when changing QImage format MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When QPixmap::fromImage() detects an ARGB32 image with only opaque pixels it will do a conversion where it only changes the advertised format of the image. This conversion was lacking a check to see if it the QImage was shared before doing so, which this patch adds. Task-number: QTBUG-40282 Change-Id: I3acf221b76735637cef04c2104a33f87e5f09d54 Reviewed-by: Andreas Löw Reviewed-by: Friedemann Kleint --- src/gui/image/qpixmap_raster.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/image/qpixmap_raster.cpp b/src/gui/image/qpixmap_raster.cpp index d879a5cb61..639650dd89 100644 --- a/src/gui/image/qpixmap_raster.cpp +++ b/src/gui/image/qpixmap_raster.cpp @@ -343,6 +343,7 @@ void QRasterPlatformPixmap::createPixmapForImage(QImage &sourceImage, Qt::ImageC if (format == QImage::Format_RGB32 && (sourceImage.format() == QImage::Format_ARGB32 || sourceImage.format() == QImage::Format_ARGB32_Premultiplied)) { + inPlace = inPlace && sourceImage.isDetached(); image = sourceImage; if (!inPlace) image.detach(); -- cgit v1.2.3 From fac1d4d17e849e069424e62cb0ef5fd4509c5066 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 22 Jul 2014 14:14:22 +0200 Subject: Windows: Fix assignment of margins in QPageSetupDialog. Task-number: QTBUG-40061 Change-Id: Id5c952a7d6280f2ab7180bff01911d6cffe57034 Reviewed-by: Kai Koehne --- src/printsupport/dialogs/qpagesetupdialog_win.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/printsupport/dialogs/qpagesetupdialog_win.cpp b/src/printsupport/dialogs/qpagesetupdialog_win.cpp index 5da87cce18..fd3a676369 100644 --- a/src/printsupport/dialogs/qpagesetupdialog_win.cpp +++ b/src/printsupport/dialogs/qpagesetupdialog_win.cpp @@ -137,9 +137,8 @@ int QPageSetupDialog::exec() QDialog::setVisible(false); if (result) { engine->setGlobalDevMode(psd.hDevNames, psd.hDevMode); - d->printer->setPageMargins(QMarginsF(psd.rtMargin.left / multiplier, psd.rtMargin.right / multiplier, - psd.rtMargin.top / multiplier, psd.rtMargin.bottom / multiplier), - layout.units()); + const QMarginsF margins(psd.rtMargin.left, psd.rtMargin.top, psd.rtMargin.right, psd.rtMargin.bottom); + d->printer->setPageMargins(margins / multiplier, layout.units()); // copy from our temp DEVMODE struct if (!engine->globalDevMode() && hDevMode) { -- cgit v1.2.3 From 66dbee12785d5474ec5ee787675eea6b271e6d2c Mon Sep 17 00:00:00 2001 From: Nico Vertriest Date: Tue, 22 Jul 2014 13:17:18 +0200 Subject: Doc: corrected autolink errors in qnamespace.qdoc Task-number: QTBUG-40362 Change-Id: Ic2a0740a12c98a60cb1d178c4d42c4ae1c39869c Reviewed-by: Jerome Pasion --- src/corelib/global/qnamespace.qdoc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index 4227dd358e..a47f2e2945 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -488,7 +488,7 @@ the underlines. \value TextDontPrint Treat this text as "hidden" and don't print it. \value TextIncludeTrailingSpaces When this option is set, - QTextLine::naturalTextWidth() and naturalTextRect() will + QTextLine::naturalTextWidth() and QTextLine::naturalTextRect() will return a value that includes the width of trailing spaces in the text; otherwise this width is excluded. \value TextJustificationForced Ensures that text lines are justified. @@ -1880,7 +1880,7 @@ menu, and in contrast to \c NoContextMenu, the handling is \e not deferred to the widget's parent. This means that all right mouse button events are guaranteed to be delivered to the widget itself - through mousePressEvent(), and mouseReleaseEvent(). + through QWidget::mousePressEvent(), and QWidget::mouseReleaseEvent(). \value DefaultContextMenu the widget's QWidget::contextMenuEvent() handler is called. \value ActionsContextMenu the widget displays its QWidget::actions() as context menu. \value CustomContextMenu the widget emits the QWidget::customContextMenuRequested() signal. @@ -2236,9 +2236,9 @@ \enum Qt::TextFormat This enum is used in widgets that can display both plain text and - rich text, e.g. QLabel. It is used for deciding whether a text + rich text, for example QLabel. It is used for deciding whether a text string should be interpreted as one or the other. This is normally - done by passing one of the enum values to a setTextFormat() + done by passing one of the enum values to a QTextEdit::setTextFormat() function. \value PlainText The text string is interpreted as a plain text @@ -2438,7 +2438,7 @@ \value ImSurroundingText The plain text around the input area, for example the current paragraph. \value ImCurrentSelection The currently selected text. \value ImMaximumTextLength The maximum number of characters that the widget can hold. If there is no limit, - QVariant() is returned. + QVariant::QVariant() is returned. \value ImAnchorPosition The position of the selection anchor. This may be less or greater than \c ImCursorPosition, depending on which side of selection the cursor is. If there is no selection, it returns the same as \c ImCursorPosition. -- cgit v1.2.3 From c94bf2cfbae06878857f2018367a1c2dff399d80 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 22 Jul 2014 22:24:41 -0700 Subject: Use the stateless UTF-8 encoder in QStringRef::toUtf8 QString::toUtf8 already does it. I guess I forgot to update this part in d51130cc3a00df8147e2eb0799e06865c901c6e0. Change-Id: I83feafcb0383758f7e64d5142f57a7ae6a2ff351 Reviewed-by: Olivier Goffart --- src/corelib/tools/qstring.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index a018b81c38..83f1bac2ef 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -9516,7 +9516,7 @@ QByteArray QStringRef::toUtf8() const if (isNull()) return QByteArray(); - return QUtf8::convertFromUnicode(constData(), length(), 0); + return QUtf8::convertFromUnicode(constData(), length()); } /*! -- cgit v1.2.3 From 3a9763d3492ef9c26a63c86e8a024fab3ce5807a Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Thu, 24 Jul 2014 10:22:48 +0200 Subject: qmake: Document the "aux" template type. Better late than never. Change-Id: If3bbeb4dfe3a8d49ceb02d9c2d0f2eff71595105 Reviewed-by: Leena Miettinen Reviewed-by: Oswald Buddenhagen --- qmake/doc/src/qmake-manual.qdoc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/qmake/doc/src/qmake-manual.qdoc b/qmake/doc/src/qmake-manual.qdoc index 2f43c8ad1f..58441064ad 100644 --- a/qmake/doc/src/qmake-manual.qdoc +++ b/qmake/doc/src/qmake-manual.qdoc @@ -321,6 +321,12 @@ \header \li Template \li qmake Output \row \li app (default) \li Makefile to build an application. \row \li lib \li Makefile to build a library. + \row \li aux \li Makefile to build nothing. Use this if no compiler needs to + be invoked to create the target, for instance because your + project is written in an interpreted language. + \note This template type is only available for Makefile-based + generators. In particular, it will not work with the vcxproj and + Xcode generators. \row \li subdirs \li Makefile containing rules for the subdirectories specified using the \l{SUBDIRS} variable. Each subdirectory must contain its own project file. @@ -2324,6 +2330,12 @@ \row \li subdirs \li Creates a Makefile for building targets in subdirectories. The subdirectories are specified using the \l{#SUBDIRS}{SUBDIRS} variable. + \row \li aux \li Creates a Makefile for not building anything. Use this if no compiler + needs to be invoked to create the target, for instance because your + project is written in an interpreted language. + \note This template type is only available for Makefile-based + generators. In particular, it will not work with the vcxproj and + Xcode generators. \row \li vcapp \li Windows only. Creates an application project for Visual Studio. See \l{Creating Visual Studio Project Files} for more information. -- cgit v1.2.3 From b99fa32d70e6511ae8bc1c6e806dbbb042dc8090 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Wed, 23 Jul 2014 16:35:01 +0200 Subject: QNAM: Fix CPU load for limited upload QIODevice This fixes high CPU load for upload devices that don't generate a constant stream of data. Their readData() function was called all the time without returning actual data. This was noticed when implementing an upload device that emits data in a limited way for bandwidth limiting. [ChangeLog][QtNetwork][QNetworkAccessManager] Fixed high CPU load when handling POST/upload QIODevice that generates data on readyRead(). Change-Id: Iefbcb1a21d8aedef1eb11761232dd16a049018dc Reviewed-by: Richard J. Moore --- src/network/access/qnetworkreplyhttpimpl.cpp | 19 +++++ src/network/access/qnetworkreplyhttpimpl_p.h | 4 + .../access/qnetworkreply/tst_qnetworkreply.cpp | 92 ++++++++++++++++++++++ 3 files changed, 115 insertions(+) diff --git a/src/network/access/qnetworkreplyhttpimpl.cpp b/src/network/access/qnetworkreplyhttpimpl.cpp index 56105a544b..4efb2f6a2a 100644 --- a/src/network/access/qnetworkreplyhttpimpl.cpp +++ b/src/network/access/qnetworkreplyhttpimpl.cpp @@ -863,6 +863,11 @@ void QNetworkReplyHttpImplPrivate::postRequest() forwardUploadDevice->setParent(delegate); // needed to make sure it is moved on moveToThread() delegate->httpRequest.setUploadByteDevice(forwardUploadDevice); + // If the device in the user thread claims it has more data, keep the flow to HTTP thread going + QObject::connect(uploadByteDevice.data(), SIGNAL(readyRead()), + q, SLOT(uploadByteDeviceReadyReadSlot()), + Qt::QueuedConnection); + // From main thread to user thread: QObject::connect(q, SIGNAL(haveUploadData(QByteArray,bool,qint64)), forwardUploadDevice, SLOT(haveDataSlot(QByteArray,bool,qint64)), Qt::QueuedConnection); @@ -1284,6 +1289,13 @@ void QNetworkReplyHttpImplPrivate::wantUploadDataSlot(qint64 maxSize) // call readPointer qint64 currentUploadDataLength = 0; char *data = const_cast(uploadByteDevice->readPointer(maxSize, currentUploadDataLength)); + + if (currentUploadDataLength == 0) { + // No bytes from upload byte device. There will be bytes later, it will emit readyRead() + // and our uploadByteDeviceReadyReadSlot() is called. + return; + } + // Let's make a copy of this data QByteArray dataArray(data, currentUploadDataLength); @@ -1291,6 +1303,13 @@ void QNetworkReplyHttpImplPrivate::wantUploadDataSlot(qint64 maxSize) emit q->haveUploadData(dataArray, uploadByteDevice->atEnd(), uploadByteDevice->size()); } +void QNetworkReplyHttpImplPrivate::uploadByteDeviceReadyReadSlot() +{ + // Start the flow between this thread and the HTTP thread again by triggering a upload. + wantUploadDataSlot(1024); +} + + /* A simple web page that can be used to test us: http://www.procata.com/cachetest/ */ diff --git a/src/network/access/qnetworkreplyhttpimpl_p.h b/src/network/access/qnetworkreplyhttpimpl_p.h index d21659ce82..06a5383ae4 100644 --- a/src/network/access/qnetworkreplyhttpimpl_p.h +++ b/src/network/access/qnetworkreplyhttpimpl_p.h @@ -129,6 +129,7 @@ public: Q_PRIVATE_SLOT(d_func(), void resetUploadDataSlot(bool *r)) Q_PRIVATE_SLOT(d_func(), void wantUploadDataSlot(qint64)) Q_PRIVATE_SLOT(d_func(), void sentUploadDataSlot(qint64)) + Q_PRIVATE_SLOT(d_func(), void uploadByteDeviceReadyReadSlot()) Q_PRIVATE_SLOT(d_func(), void emitReplyUploadProgress(qint64, qint64)) Q_PRIVATE_SLOT(d_func(), void _q_cacheSaveDeviceAboutToClose()) @@ -300,6 +301,9 @@ public: void wantUploadDataSlot(qint64); void sentUploadDataSlot(qint64); + // From user's QNonContiguousByteDevice + void uploadByteDeviceReadyReadSlot(); + Q_DECLARE_PUBLIC(QNetworkReplyHttpImpl) }; diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp index 0509eb9a77..480eeecb63 100644 --- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -461,6 +461,8 @@ private Q_SLOTS: void backgroundRequestConnectInBackground(); #endif + void putWithRateLimiting(); + // NOTE: This test must be last! void parentingRepliesToTheApp(); private: @@ -7776,6 +7778,96 @@ void tst_QNetworkReply::backgroundRequestConnectInBackground() } #endif +class RateLimitedUploadDevice : public QIODevice +{ + Q_OBJECT +public: + QByteArray data; + QBuffer buffer; + qint64 read; + qint64 bandwidthQuota; + QTimer timer; + + RateLimitedUploadDevice(QByteArray d) : QIODevice(),data(d),read(0),bandwidthQuota(0) { + buffer.setData(data); + buffer.open(QIODevice::ReadOnly); + timer.setInterval(200); + QObject::connect(&timer, SIGNAL(timeout()), this, SLOT(timeoutSlot())); + timer.start(); + } + + virtual qint64 writeData(const char* , qint64 ) { + Q_ASSERT(false); + return 0; + } + + virtual qint64 readData(char* data, qint64 maxlen) { + //qDebug() << Q_FUNC_INFO << maxlen << bandwidthQuota; + maxlen = qMin(maxlen, buffer.bytesAvailable()); + maxlen = qMin(maxlen, bandwidthQuota); + if (maxlen <= 0) { // no quota or at end + return 0; + } + bandwidthQuota -= maxlen; // reduce quota + + qint64 ret = buffer.read(data, maxlen); + if (ret == -1) { + return -1; + } + read += ret; + //qDebug() << Q_FUNC_INFO << maxlen << bandwidthQuota << read << ret << buffer.bytesAvailable(); + return ret; + } + virtual bool atEnd() const { + return buffer.atEnd(); + } + virtual qint64 size() const{ + return data.length(); + } + qint64 bytesAvailable() const + { + return buffer.bytesAvailable() + QIODevice::bytesAvailable(); + } + virtual bool isSequential() const{ // random access, we can seek + return false; + } + virtual bool seek ( qint64 pos ) { + return buffer.seek(pos); + } +protected slots: + void timeoutSlot() { + //qDebug() << Q_FUNC_INFO; + bandwidthQuota = 8*1024; // fill quota + emit readyRead(); + } +}; + +void tst_QNetworkReply::putWithRateLimiting() +{ + QFile reference(testDataDir + "/rfc3252.txt"); + reference.open(QIODevice::ReadOnly); + QByteArray data = reference.readAll(); + QVERIFY(data.length() > 0); + + QUrl url = QUrl::fromUserInput("http://" + QtNetworkSettings::serverName()+ "/qtest/cgi-bin/echo.cgi?"); + + QNetworkRequest request(url); + QNetworkReplyPtr reply; + + RateLimitedUploadDevice rateLimitedUploadDevice(data); + rateLimitedUploadDevice.open(QIODevice::ReadOnly); + + RUN_REQUEST(runCustomRequest(request, reply,QByteArray("POST"), &rateLimitedUploadDevice)); + QCOMPARE(reply->error(), QNetworkReply::NoError); + QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200); + + QByteArray uploadedData = reply->readAll(); + QCOMPARE(uploadedData.length(), data.length()); + QCOMPARE(uploadedData, data); +} + + + // NOTE: This test must be last testcase in tst_qnetworkreply! void tst_QNetworkReply::parentingRepliesToTheApp() { -- cgit v1.2.3 From 8b0cc9db9b5b09b00e573d1dc0dbfcca177c8a9d Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 25 Jul 2014 14:19:20 +0200 Subject: tst_QHash: verify that {}-style initialization drops duplicates No actual reason for this test, except my curiority. Then again, it's good to have this check, too. Also checks that the last entry in the init_list "wins", which is not how std:: containers work. Change-Id: Ia284d093cd0029432372630e81657fb687b9516f Reviewed-by: Olivier Goffart --- tests/auto/corelib/tools/qhash/tst_qhash.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/auto/corelib/tools/qhash/tst_qhash.cpp b/tests/auto/corelib/tools/qhash/tst_qhash.cpp index 9c96aaf78d..9c9e8ad635 100644 --- a/tests/auto/corelib/tools/qhash/tst_qhash.cpp +++ b/tests/auto/corelib/tools/qhash/tst_qhash.cpp @@ -1327,11 +1327,16 @@ void tst_QHash::twoArguments_qHash() void tst_QHash::initializerList() { #ifdef Q_COMPILER_INITIALIZER_LISTS - QHash hash{{1, "hello"}, {2, "initializer_list"}}; + QHash hash = {{1, "bar"}, {1, "hello"}, {2, "initializer_list"}}; QCOMPARE(hash.count(), 2); QVERIFY(hash[1] == "hello"); QVERIFY(hash[2] == "initializer_list"); + // note the difference to std::unordered_map: + // std::unordered_map stdh = {{1, "bar"}, {1, "hello"}, {2, "initializer_list"}}; + // QCOMPARE(stdh.size(), 2UL); + // QCOMPARE(stdh[1], QString("bar")); + QMultiHash multiHash{{"il", 1}, {"il", 2}, {"il", 3}}; QCOMPARE(multiHash.count(), 3); QList values = multiHash.values("il"); -- cgit v1.2.3 From 443bc6ab188c5107f8ac0a068dc3bf12b4809355 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 25 Jul 2014 14:23:20 +0200 Subject: tst_QHash: replace QVERIFY(x == y) with QCOMPARE(x,y) QCOMPARE produces more useful output on failure. Change-Id: I584a5d33026ac2587758d72524f735937029e111 Reviewed-by: Olivier Goffart --- tests/auto/corelib/tools/qhash/tst_qhash.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auto/corelib/tools/qhash/tst_qhash.cpp b/tests/auto/corelib/tools/qhash/tst_qhash.cpp index 9c9e8ad635..77baed87c2 100644 --- a/tests/auto/corelib/tools/qhash/tst_qhash.cpp +++ b/tests/auto/corelib/tools/qhash/tst_qhash.cpp @@ -1329,8 +1329,8 @@ void tst_QHash::initializerList() #ifdef Q_COMPILER_INITIALIZER_LISTS QHash hash = {{1, "bar"}, {1, "hello"}, {2, "initializer_list"}}; QCOMPARE(hash.count(), 2); - QVERIFY(hash[1] == "hello"); - QVERIFY(hash[2] == "initializer_list"); + QCOMPARE(hash[1], QString("hello")); + QCOMPARE(hash[2], QString("initializer_list")); // note the difference to std::unordered_map: // std::unordered_map stdh = {{1, "bar"}, {1, "hello"}, {2, "initializer_list"}}; -- cgit v1.2.3 From 34237d62f6023061564ae5ee3955bad0e9881fd3 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 25 Jul 2014 14:32:37 +0200 Subject: tst_QMap: verify that {}-style initialization drops duplicates No actual reason for this test, except my curiority. Then again, it's good to have this check, too. Also checks that the last entry in the init_list "wins", which is not how std:: containers work. Change-Id: I4f7d1228f2b90a904b6c3f99e54afcd9970b723e Reviewed-by: Olivier Goffart --- tests/auto/corelib/tools/qmap/tst_qmap.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/auto/corelib/tools/qmap/tst_qmap.cpp b/tests/auto/corelib/tools/qmap/tst_qmap.cpp index 00e669c1d8..c160902268 100644 --- a/tests/auto/corelib/tools/qmap/tst_qmap.cpp +++ b/tests/auto/corelib/tools/qmap/tst_qmap.cpp @@ -1179,11 +1179,16 @@ void tst_QMap::checkMostLeftNode() void tst_QMap::initializerList() { #ifdef Q_COMPILER_INITIALIZER_LISTS - QMap map{{1, "hello"}, {2, "initializer_list"}}; + QMap map = {{1, "bar"}, {1, "hello"}, {2, "initializer_list"}}; QCOMPARE(map.count(), 2); QVERIFY(map[1] == "hello"); QVERIFY(map[2] == "initializer_list"); + // note the difference to std::map: + // std::map stdm = {{1, "bar"}, {1, "hello"}, {2, "initializer_list"}}; + // QCOMPARE(stdm.size(), 2UL); + // QCOMPARE(stdm[1], QString("bar")); + QMultiMap multiMap{{"il", 1}, {"il", 2}, {"il", 3}}; QCOMPARE(multiMap.count(), 3); QList values = multiMap.values("il"); -- cgit v1.2.3 From 67a316be7cf9b9e7c2c7cc1845bee2dcf63f38ba Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 25 Jul 2014 14:33:01 +0200 Subject: tst_QMap: replace QVERIFY(x == y) with QCOMPARE(x,y) QCOMPARE produces more useful output on failure. Change-Id: Idaa9bf61a22a43b0feb084a71985a69c8787d633 Reviewed-by: Olivier Goffart --- tests/auto/corelib/tools/qmap/tst_qmap.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auto/corelib/tools/qmap/tst_qmap.cpp b/tests/auto/corelib/tools/qmap/tst_qmap.cpp index c160902268..3daab73cc2 100644 --- a/tests/auto/corelib/tools/qmap/tst_qmap.cpp +++ b/tests/auto/corelib/tools/qmap/tst_qmap.cpp @@ -1181,8 +1181,8 @@ void tst_QMap::initializerList() #ifdef Q_COMPILER_INITIALIZER_LISTS QMap map = {{1, "bar"}, {1, "hello"}, {2, "initializer_list"}}; QCOMPARE(map.count(), 2); - QVERIFY(map[1] == "hello"); - QVERIFY(map[2] == "initializer_list"); + QCOMPARE(map[1], QString("hello")); + QCOMPARE(map[2], QString("initializer_list")); // note the difference to std::map: // std::map stdm = {{1, "bar"}, {1, "hello"}, {2, "initializer_list"}}; -- cgit v1.2.3 From aaaba5da2400402c1c739ebd45e3d392eb8dfb86 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 25 Jul 2014 14:46:41 +0200 Subject: tst_QSet: verify that {}-style initialization drops duplicates No actual reason for this test, except my curiority. Then again, it's good to have this check, too. Change-Id: I815fce7e4dbe76e21cac29beb1dbfc1083191d24 Reviewed-by: Olivier Goffart --- tests/auto/corelib/tools/qset/tst_qset.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/corelib/tools/qset/tst_qset.cpp b/tests/auto/corelib/tools/qset/tst_qset.cpp index eaa1c018ba..5ef1b44b6f 100644 --- a/tests/auto/corelib/tools/qset/tst_qset.cpp +++ b/tests/auto/corelib/tools/qset/tst_qset.cpp @@ -922,7 +922,7 @@ void tst_QSet::makeSureTheComfortFunctionsCompile() void tst_QSet::initializerList() { #ifdef Q_COMPILER_INITIALIZER_LISTS - QSet set{1, 2, 3, 4, 5}; + QSet set = {1, 1, 2, 3, 4, 5}; QCOMPARE(set.count(), 5); QVERIFY(set.contains(1)); QVERIFY(set.contains(2)); -- cgit v1.2.3 From 553325abfd988b062195caae280bbf75b8474ca4 Mon Sep 17 00:00:00 2001 From: Artem Shevchenko Date: Sun, 27 Jul 2014 13:25:06 +0300 Subject: Fix buffer overrun error with some proxy servers In some cases, depending on the proxy server response, the current implementation of QHttpSocketEngine may write to memory beyond the allocated buffer size. That will trigger undefined behavior on UNIX systems and a buffer overrun exception if compiled with visual studio. Change-Id: I5769d10c56b6a7483d6d94672aa4321287b82651 Reviewed-by: Marc Mutz Reviewed-by: Olivier Goffart --- src/network/socket/qhttpsocketengine.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/network/socket/qhttpsocketengine.cpp b/src/network/socket/qhttpsocketengine.cpp index 2e920ad69f..0a25815752 100644 --- a/src/network/socket/qhttpsocketengine.cpp +++ b/src/network/socket/qhttpsocketengine.cpp @@ -568,9 +568,6 @@ void QHttpSocketEngine::slotSocketReadNotification() char dummybuffer[4096]; while (d->pendingResponseData) { int read = d->socket->read(dummybuffer, qMin(sizeof(dummybuffer), (size_t)d->pendingResponseData)); - if (read >= 0) - dummybuffer[read] = 0; - if (read == 0) return; if (read == -1) { -- cgit v1.2.3 From ec703836b314c419a1c463dc105234f733031535 Mon Sep 17 00:00:00 2001 From: Bernd Weimer Date: Wed, 9 Jul 2014 11:58:44 +0200 Subject: Improve dbus cross compilation Building QtDBus on Linux host for QNX target had two issues: * Configure check failed, because dbus-1 library was not linked in, if target platform doesn't support pkg-config. * Host tools were not built, because pkg-config was not used to locate dbus headers on the host. Task-number: QTBUG-37324 Change-Id: I71d8309599fd40ef2dd8c9e3b44b93a7482019f1 Reviewed-by: Rolf Eike Beer Reviewed-by: Thiago Macieira Reviewed-by: Oswald Buddenhagen --- configure | 10 +++++++++- src/tools/bootstrap-dbus/bootstrap-dbus.pro | 2 +- src/tools/qdbuscpp2xml/qdbuscpp2xml.pro | 2 +- src/tools/qdbusxml2cpp/qdbusxml2cpp.pro | 2 +- tools/configure/configureapp.cpp | 14 +++++++++++--- tools/configure/configureapp.h | 1 + 6 files changed, 24 insertions(+), 7 deletions(-) diff --git a/configure b/configure index d5c2b0801f..cb8d78fd3c 100755 --- a/configure +++ b/configure @@ -4584,11 +4584,19 @@ if [ "$CFG_DBUS" != "no" ]; then if [ -n "$PKG_CONFIG" ] && $PKG_CONFIG --atleast-version="$MIN_DBUS_1_VERSION" dbus-1 2>/dev/null; then QT_CFLAGS_DBUS=`$PKG_CONFIG --cflags dbus-1 2>/dev/null` QT_LIBS_DBUS=`$PKG_CONFIG --libs dbus-1 2>/dev/null` + else + QT_LIBS_DBUS="-ldbus-1" fi if compileTest unix/dbus "D-Bus" $QT_CFLAGS_DBUS $QT_LIBS_DBUS; then [ "$CFG_DBUS" = "auto" ] && CFG_DBUS=yes - QMakeVar set QT_CFLAGS_DBUS "$QT_CFLAGS_DBUS" QMakeVar set QT_LIBS_DBUS "$QT_LIBS_DBUS" + QMakeVar set QT_CFLAGS_DBUS "$QT_CFLAGS_DBUS" + # Try find correct host configuration for dbus tools when cross-compiling + if [ "$QT_CROSS_COMPILE" = "yes" ] && env -i PATH="$PATH" \ + pkg-config --atleast-version="$MIN_DBUS_1_VERSION" dbus-1 2>/dev/null; then + QT_CFLAGS_DBUS=`env -i PATH="$PATH" pkg-config --cflags dbus-1 2>/dev/null` + fi + QMakeVar set QT_HOST_CFLAGS_DBUS "$QT_CFLAGS_DBUS" else if [ "$CFG_DBUS" = "auto" ]; then CFG_DBUS=no diff --git a/src/tools/bootstrap-dbus/bootstrap-dbus.pro b/src/tools/bootstrap-dbus/bootstrap-dbus.pro index 62f9f96a9b..fb06b4d8a2 100644 --- a/src/tools/bootstrap-dbus/bootstrap-dbus.pro +++ b/src/tools/bootstrap-dbus/bootstrap-dbus.pro @@ -15,7 +15,7 @@ MODULE_PRIVATE_INCLUDES = \ load(qt_module) -QMAKE_CXXFLAGS += $$QT_CFLAGS_DBUS +QMAKE_CXXFLAGS += $$QT_HOST_CFLAGS_DBUS SOURCES = \ ../../dbus/qdbusintrospection.cpp \ diff --git a/src/tools/qdbuscpp2xml/qdbuscpp2xml.pro b/src/tools/qdbuscpp2xml/qdbuscpp2xml.pro index 655158e457..d65b5ce6ef 100644 --- a/src/tools/qdbuscpp2xml/qdbuscpp2xml.pro +++ b/src/tools/qdbuscpp2xml/qdbuscpp2xml.pro @@ -3,7 +3,7 @@ QT = core-private force_bootstrap: QT += bootstrap_dbus-private else: QT += dbus-private DEFINES += QT_NO_CAST_FROM_ASCII -QMAKE_CXXFLAGS += $$QT_CFLAGS_DBUS +QMAKE_CXXFLAGS += $$QT_HOST_CFLAGS_DBUS include(../moc/moc.pri) diff --git a/src/tools/qdbusxml2cpp/qdbusxml2cpp.pro b/src/tools/qdbusxml2cpp/qdbusxml2cpp.pro index dcc36c7913..6efcf323b8 100644 --- a/src/tools/qdbusxml2cpp/qdbusxml2cpp.pro +++ b/src/tools/qdbusxml2cpp/qdbusxml2cpp.pro @@ -3,7 +3,7 @@ QT = core-private force_bootstrap: QT += bootstrap_dbus-private else: QT += dbus-private DEFINES += QT_NO_CAST_FROM_ASCII -QMAKE_CXXFLAGS += $$QT_CFLAGS_DBUS +QMAKE_CXXFLAGS += $$QT_HOST_CFLAGS_DBUS SOURCES = qdbusxml2cpp.cpp diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index b7565093f1..63d9f2804e 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -1008,6 +1008,8 @@ void Configure::parseCmdLine() sybaseLibs = configCmdLine.at(i); } else if (configCmdLine.at(i).startsWith("DBUS_PATH=")) { dbusPath = QDir::fromNativeSeparators(configCmdLine.at(i).section("=", 1)); + } else if (configCmdLine.at(i).startsWith("DBUS_HOST_PATH=")) { + dbusHostPath = QDir::fromNativeSeparators(configCmdLine.at(i).section("=", 1)); } else if (configCmdLine.at(i).startsWith("MYSQL_PATH=")) { mysqlPath = QDir::fromNativeSeparators(configCmdLine.at(i).section("=", 1)); } else if (configCmdLine.at(i).startsWith("ZLIB_LIBS=")) { @@ -2938,9 +2940,15 @@ void Configure::generateOutputVars() qmakeVars += QString("OPENSSL_LIBS += -L%1/lib").arg(opensslPath); } } - if (dictionary[ "DBUS" ] != "no" && !dbusPath.isEmpty()) { - qmakeVars += QString("QT_CFLAGS_DBUS = -I%1/include").arg(dbusPath); - qmakeVars += QString("QT_LIBS_DBUS = -L%1/lib").arg(dbusPath); + if (dictionary[ "DBUS" ] != "no") { + if (!dbusPath.isEmpty()) { + qmakeVars += QString("QT_CFLAGS_DBUS = -I%1/include").arg(dbusPath); + qmakeVars += QString("QT_LIBS_DBUS = -L%1/lib").arg(dbusPath); + if (dbusHostPath.isEmpty()) + qmakeVars += QString("QT_HOST_CFLAGS_DBUS = -I%1/include").arg(dbusPath); + } + if (!dbusHostPath.isEmpty()) + qmakeVars += QString("QT_HOST_CFLAGS_DBUS = -I%1/include").arg(dbusHostPath); } if (dictionary[ "SQL_MYSQL" ] != "no" && !mysqlPath.isEmpty()) { qmakeVars += QString("QT_CFLAGS_MYSQL = -I%1/include").arg(mysqlPath); diff --git a/tools/configure/configureapp.h b/tools/configure/configureapp.h index 98e4912eaa..5f118ddd39 100644 --- a/tools/configure/configureapp.h +++ b/tools/configure/configureapp.h @@ -140,6 +140,7 @@ private: QString opensslLibsRelease; QString opensslPath; QString dbusPath; + QString dbusHostPath; QString mysqlPath; QString psqlLibs; QString zlibLibs; -- cgit v1.2.3 From 7e74f8f398deb8ed84f6c4613de6dab2066dc9de Mon Sep 17 00:00:00 2001 From: Joni Poikelin Date: Thu, 24 Jul 2014 10:06:10 +0300 Subject: Fix compilation if EC is disabled in OpenSSL Some Linux distributions disable EC by default which causes compile errors on those platforms. Task-number: QTBUG-40394 Change-Id: If5816d473bd1d64b1d4977860db662704a83310f Reviewed-by: Richard J. Moore --- src/network/ssl/qsslcontext.cpp | 2 ++ src/network/ssl/qsslsocket_openssl_symbols.cpp | 4 ++++ src/network/ssl/qsslsocket_openssl_symbols_p.h | 2 ++ 3 files changed, 8 insertions(+) diff --git a/src/network/ssl/qsslcontext.cpp b/src/network/ssl/qsslcontext.cpp index f5e5352d5e..addf7a2ff5 100644 --- a/src/network/ssl/qsslcontext.cpp +++ b/src/network/ssl/qsslcontext.cpp @@ -315,11 +315,13 @@ init_context: q_SSL_CTX_set_tmp_dh(sslContext->ctx, dh); q_DH_free(dh); +#ifndef OPENSSL_NO_EC // Set temp ECDH params EC_KEY *ecdh = 0; ecdh = q_EC_KEY_new_by_curve_name(NID_X9_62_prime256v1); q_SSL_CTX_set_tmp_ecdh(sslContext->ctx, ecdh); q_EC_KEY_free(ecdh); +#endif // OPENSSL_NO_EC return sslContext; } diff --git a/src/network/ssl/qsslsocket_openssl_symbols.cpp b/src/network/ssl/qsslsocket_openssl_symbols.cpp index d4a4117b8b..4e6200f880 100644 --- a/src/network/ssl/qsslsocket_openssl_symbols.cpp +++ b/src/network/ssl/qsslsocket_openssl_symbols.cpp @@ -365,8 +365,10 @@ DEFINEFUNC3(void, SSL_get0_next_proto_negotiated, const SSL *s, s, DEFINEFUNC(DH *, DH_new, DUMMYARG, DUMMYARG, return 0, return) DEFINEFUNC(void, DH_free, DH *dh, dh, return, DUMMYARG) DEFINEFUNC3(BIGNUM *, BN_bin2bn, const unsigned char *s, s, int len, len, BIGNUM *ret, ret, return 0, return) +#ifndef OPENSSL_NO_EC DEFINEFUNC(EC_KEY *, EC_KEY_new_by_curve_name, int nid, nid, return 0, return) DEFINEFUNC(void, EC_KEY_free, EC_KEY *ecdh, ecdh, return, DUMMYARG) +#endif // OPENSSL_NO_EC #define RESOLVEFUNC(func) \ if (!(_q_##func = _q_PTR_##func(libs.first->resolve(#func))) \ @@ -845,8 +847,10 @@ bool q_resolveOpenSslSymbols() RESOLVEFUNC(DH_new) RESOLVEFUNC(DH_free) RESOLVEFUNC(BN_bin2bn) +#ifndef OPENSSL_NO_EC RESOLVEFUNC(EC_KEY_new_by_curve_name) RESOLVEFUNC(EC_KEY_free) +#endif // OPENSSL_NO_EC symbolsResolved = true; delete libs.first; diff --git a/src/network/ssl/qsslsocket_openssl_symbols_p.h b/src/network/ssl/qsslsocket_openssl_symbols_p.h index 0f3d2673c2..68f5709b93 100644 --- a/src/network/ssl/qsslsocket_openssl_symbols_p.h +++ b/src/network/ssl/qsslsocket_openssl_symbols_p.h @@ -434,10 +434,12 @@ void q_DH_free(DH *dh); BIGNUM *q_BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret); #define q_SSL_CTX_set_tmp_dh(ctx, dh) q_SSL_CTX_ctrl((ctx), SSL_CTRL_SET_TMP_DH, 0, (char *)dh) +#ifndef OPENSSL_NO_EC // EC Diffie-Hellman support EC_KEY *q_EC_KEY_new_by_curve_name(int nid); void q_EC_KEY_free(EC_KEY *ecdh); #define q_SSL_CTX_set_tmp_ecdh(ctx, ecdh) q_SSL_CTX_ctrl((ctx), SSL_CTRL_SET_TMP_ECDH, 0, (char *)ecdh) +#endif // OPENSSL_NO_EC #define q_BIO_get_mem_data(b, pp) (int)q_BIO_ctrl(b,BIO_CTRL_INFO,0,(char *)pp) #define q_BIO_pending(b) (int)q_BIO_ctrl(b,BIO_CTRL_PENDING,0,NULL) -- cgit v1.2.3