From d894cfa863a3fc9cd9a6dcb9f3c7b04e6ce41285 Mon Sep 17 00:00:00 2001 From: Joni Poikelin Date: Wed, 4 Nov 2015 11:35:09 +0200 Subject: Fix QImage::setDotsPerMeterX/Y for images with some orientations Rotation of images with orientation of 90 and 270 degrees dropped DPM values from rotated image. Task-number: QTBUG-49220 Change-Id: I9c23153c49dd63b5f6958fdde72f466873b0a407 Reviewed-by: Friedemann Kleint Reviewed-by: Liang Qi Reviewed-by: aavit --- src/gui/image/qimage.cpp | 4 ++++ tests/auto/gui/image/qimage/tst_qimage.cpp | 25 +++++++++++++++---------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index c4691b5f5e..b3d8563614 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -4285,6 +4285,8 @@ QImage QImage::smoothScaled(int w, int h) const { static QImage rotated90(const QImage &image) { QImage out(image.height(), image.width(), image.format()); + out.setDotsPerMeterX(image.dotsPerMeterY()); + out.setDotsPerMeterY(image.dotsPerMeterX()); if (image.colorCount() > 0) out.setColorTable(image.colorTable()); int w = image.width(); @@ -4353,6 +4355,8 @@ static QImage rotated180(const QImage &image) { static QImage rotated270(const QImage &image) { QImage out(image.height(), image.width(), image.format()); + out.setDotsPerMeterX(image.dotsPerMeterY()); + out.setDotsPerMeterY(image.dotsPerMeterX()); if (image.colorCount() > 0) out.setColorTable(image.colorTable()); int w = image.width(); diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp index 8286c800c2..939226e2b0 100644 --- a/tests/auto/gui/image/qimage/tst_qimage.cpp +++ b/tests/auto/gui/image/qimage/tst_qimage.cpp @@ -2822,15 +2822,17 @@ void tst_QImage::exifOrientation_data() { QTest::addColumn("fileName"); QTest::addColumn("orientation"); - QTest::newRow("Orientation 1, Intel format") << m_prefix + "jpeg_exif_orientation_value_1.jpg" << (int)QImageIOHandler::TransformationNone; - QTest::newRow("Orientation 2, Intel format") << m_prefix + "jpeg_exif_orientation_value_2.jpg" << (int)QImageIOHandler::TransformationMirror; - QTest::newRow("Orientation 3, Intel format") << m_prefix + "jpeg_exif_orientation_value_3.jpg" << (int)QImageIOHandler::TransformationRotate180; - QTest::newRow("Orientation 4, Intel format") << m_prefix + "jpeg_exif_orientation_value_4.jpg" << (int)QImageIOHandler::TransformationFlip; - QTest::newRow("Orientation 5, Intel format") << m_prefix + "jpeg_exif_orientation_value_5.jpg" << (int)QImageIOHandler::TransformationFlipAndRotate90; - QTest::newRow("Orientation 6, Intel format") << m_prefix + "jpeg_exif_orientation_value_6.jpg" << (int)QImageIOHandler::TransformationRotate90; - QTest::newRow("Orientation 6, Motorola format") << m_prefix + "jpeg_exif_orientation_value_6_motorola.jpg" << (int)QImageIOHandler::TransformationRotate90; - QTest::newRow("Orientation 7, Intel format") << m_prefix + "jpeg_exif_orientation_value_7.jpg" << (int)QImageIOHandler::TransformationMirrorAndRotate90; - QTest::newRow("Orientation 8, Intel format") << m_prefix + "jpeg_exif_orientation_value_8.jpg" << (int)QImageIOHandler::TransformationRotate270; + QTest::addColumn("dpmx"); + QTest::addColumn("dpmy"); + QTest::newRow("Orientation 1, Intel format") << m_prefix + "jpeg_exif_orientation_value_1.jpg" << (int)QImageIOHandler::TransformationNone << 39 << 39; + QTest::newRow("Orientation 2, Intel format") << m_prefix + "jpeg_exif_orientation_value_2.jpg" << (int)QImageIOHandler::TransformationMirror << 39 << 39; + QTest::newRow("Orientation 3, Intel format") << m_prefix + "jpeg_exif_orientation_value_3.jpg" << (int)QImageIOHandler::TransformationRotate180 << 39 << 39; + QTest::newRow("Orientation 4, Intel format") << m_prefix + "jpeg_exif_orientation_value_4.jpg" << (int)QImageIOHandler::TransformationFlip << 39 << 39; + QTest::newRow("Orientation 5, Intel format") << m_prefix + "jpeg_exif_orientation_value_5.jpg" << (int)QImageIOHandler::TransformationFlipAndRotate90 << 39 << 39; + QTest::newRow("Orientation 6, Intel format") << m_prefix + "jpeg_exif_orientation_value_6.jpg" << (int)QImageIOHandler::TransformationRotate90 << 39 << 39; + QTest::newRow("Orientation 6, Motorola format") << m_prefix + "jpeg_exif_orientation_value_6_motorola.jpg" << (int)QImageIOHandler::TransformationRotate90 << 39 << 39; + QTest::newRow("Orientation 7, Intel format") << m_prefix + "jpeg_exif_orientation_value_7.jpg" << (int)QImageIOHandler::TransformationMirrorAndRotate90 << 39 << 39; + QTest::newRow("Orientation 8, Intel format") << m_prefix + "jpeg_exif_orientation_value_8.jpg" << (int)QImageIOHandler::TransformationRotate270 << 39 << 39; } QT_BEGIN_NAMESPACE @@ -2842,14 +2844,17 @@ void tst_QImage::exifOrientation() { QFETCH(QString, fileName); QFETCH(int, orientation); + QFETCH(int, dpmx); + QFETCH(int, dpmy); QImageReader imageReader(fileName); imageReader.setAutoTransform(true); QCOMPARE(imageReader.transformation(), orientation); QImage img = imageReader.read(); + QCOMPARE(img.dotsPerMeterX(), dpmx); + QCOMPARE(img.dotsPerMeterY(), dpmy); QRgb px; QVERIFY(!img.isNull()); - px = img.pixel(0, 0); QVERIFY(qRed(px) > 250 && qGreen(px) < 5 && qBlue(px) < 5); -- cgit v1.2.3 From c78fec01f89e7383b3008b5ca30d2a2601ba0a97 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 2 Nov 2015 21:26:08 +0100 Subject: [docs] QStyle: remove remaining references to QStyleOption*V They are all obsolete since Qt 5.0. Change-Id: Ief9111057137c3bd091630430a23681095b73510 Reviewed-by: Jake Petroules --- src/widgets/styles/qstyle.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/widgets/styles/qstyle.cpp b/src/widgets/styles/qstyle.cpp index b368477a39..02c420e55c 100644 --- a/src/widgets/styles/qstyle.cpp +++ b/src/widgets/styles/qstyle.cpp @@ -896,7 +896,7 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, \value CE_ToolBoxTabLabel The toolbox's tab label. \value CE_HeaderEmptyArea The area of a header view where there are no header sections. - \value CE_ShapedFrame The frame with the shape specified in the QStyleOptionFrameV3; see QFrame. + \value CE_ShapedFrame The frame with the shape specified in the QStyleOptionFrame; see QFrame. \omitvalue CE_ColumnViewGrip @@ -1034,7 +1034,7 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, \omitvalue SE_ViewItemCheckIndicator \value SE_FrameContents Area for a frame's contents. - \value SE_ShapedFrameContents Area for a frame's contents using the shape in QStyleOptionFrameV3; see QFrame + \value SE_ShapedFrameContents Area for a frame's contents using the shape in QStyleOptionFrame; see QFrame \value SE_FrameLayoutItem Area that counts for the parent layout. \value SE_HeaderArrow Area for the sort indicator for a header. -- cgit v1.2.3 From c69f75426d004d7cdadf51ea06238fef98493ec7 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 2 Nov 2015 15:26:32 +0100 Subject: QStyleOption*V: mark as \obsolete Change-Id: I6e4857bcfa7792bec4d38f6c65bfec15a52b4d30 Reviewed-by: Friedemann Kleint --- src/widgets/styles/qstyleoption.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/widgets/styles/qstyleoption.cpp b/src/widgets/styles/qstyleoption.cpp index cab56e329e..d66dbec472 100644 --- a/src/widgets/styles/qstyleoption.cpp +++ b/src/widgets/styles/qstyleoption.cpp @@ -475,6 +475,7 @@ QStyleOptionFocusRect::QStyleOptionFocusRect(int version) /*! \typedef QStyleOptionFrameV2 \relates QStyleOptionFrame + \obsolete Synonym for QStyleOptionFrame. */ @@ -482,6 +483,7 @@ QStyleOptionFocusRect::QStyleOptionFocusRect(int version) /*! \typedef QStyleOptionFrameV3 \relates QStyleOptionFrame + \obsolete Synonym for QStyleOptionFrame. */ @@ -1253,6 +1255,7 @@ QStyleOptionToolBar::QStyleOptionToolBar(int version) /*! \typedef QStyleOptionTabV2 \relates QStyleOptionTab + \obsolete Synonym for QStyleOptionTab. */ @@ -1260,6 +1263,7 @@ QStyleOptionToolBar::QStyleOptionToolBar(int version) /*! \typedef QStyleOptionTabV3 \relates QStyleOptionTab + \obsolete Synonym for QStyleOptionTab. */ @@ -1497,6 +1501,7 @@ QStyleOptionTab::QStyleOptionTab(int version) /*! \typedef QStyleOptionProgressBarV2 \relates QStyleOptionProgressBar + \obsolete Synonym for QStyleOptionProgressBar. */ @@ -2270,6 +2275,7 @@ QStyleOptionSpinBox::QStyleOptionSpinBox(int version) /*! \typedef QStyleOptionDockWidgetV2 \relates QStyleOptionDockWidget + \obsolete Synonym for QStyleOptionDockWidget. */ @@ -2675,6 +2681,7 @@ QStyleOptionComboBox::QStyleOptionComboBox(int version) /*! \typedef QStyleOptionToolBoxV2 \relates QStyleOptionToolBox + \obsolete Synonym for QStyleOptionToolBox. */ @@ -3012,6 +3019,7 @@ QStyleOptionTitleBar::QStyleOptionTitleBar(int version) /*! \typedef QStyleOptionViewItemV2 \relates QStyleOptionViewItem + \obsolete Synonym for QStyleOptionViewItem. */ @@ -3019,6 +3027,7 @@ QStyleOptionTitleBar::QStyleOptionTitleBar(int version) /*! \typedef QStyleOptionViewItemV3 \relates QStyleOptionViewItem + \obsolete Synonym for QStyleOptionViewItem. */ @@ -3026,6 +3035,7 @@ QStyleOptionTitleBar::QStyleOptionTitleBar(int version) /*! \typedef QStyleOptionViewItemV4 \relates QStyleOptionViewItem + \obsolete Synonym for QStyleOptionViewItem. */ @@ -3298,6 +3308,7 @@ QStyleOptionViewItem::QStyleOptionViewItem(int version) /*! \typedef QStyleOptionTabWidgetFrameV2 \relates QStyleOptionTabWidgetFrame + \obsolete Synonym for QStyleOptionTabWidgetFrame. */ @@ -3447,6 +3458,7 @@ QStyleOptionTabWidgetFrame::QStyleOptionTabWidgetFrame(int version) /*! \typedef QStyleOptionTabBarBaseV2 \relates QStyleOptionTabBarBase + \obsolete Synonym for QStyleOptionTabBarBase. */ -- cgit v1.2.3 From 7aba75ffc52e5dce4b3ada12668611be2ad6787e Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Fri, 25 Sep 2015 13:23:46 +0200 Subject: Don't let closed http sockets pass as valid connections A QAbstractSocket can be close()'d at any time, independently of its current connection state. being closed means that we cannot use it to read or write data, but internally it might still have some data to send or receive, for example to an http server. We can even get a connected() signal after close()'ing the socket. We need to catch this condition and mark any pending data not yet written to the socket for resending. (cherry picked from commit 0df5d079290b4c3b13e58e9397fabdc1dfdba96b) Task-number: QTBUG-48326 Change-Id: I67d9ad36f7288c9c6bef51aa6253d7b187737601 Reviewed-by: Ulf Hermann Reviewed-by: Markus Goetz (Woboq GmbH) --- .../access/qhttpnetworkconnectionchannel.cpp | 7 ++- .../tst_qhttpnetworkconnection.cpp | 54 ++++++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index 0820a8d63e..453a0c71b6 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -272,7 +272,12 @@ bool QHttpNetworkConnectionChannel::ensureConnection() QAbstractSocket::SocketState socketState = socket->state(); // resend this request after we receive the disconnected signal - if (socketState == QAbstractSocket::ClosingState) { + // If !socket->isOpen() then we have already called close() on the socket, but there was still a + // pending connectToHost() for which we hadn't seen a connected() signal, yet. The connected() + // has now arrived (as indicated by socketState != ClosingState), but we cannot send anything on + // such a socket anymore. + if (socketState == QAbstractSocket::ClosingState || + (socketState != QAbstractSocket::UnconnectedState && !socket->isOpen())) { if (reply) resendCurrent = true; return false; diff --git a/tests/auto/network/access/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp b/tests/auto/network/access/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp index 5d072af6d5..0d188a8fec 100644 --- a/tests/auto/network/access/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp +++ b/tests/auto/network/access/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp @@ -36,6 +36,7 @@ #include "private/qhttpnetworkconnection_p.h" #include "private/qnoncontiguousbytedevice_p.h" #include +#include #include "../../../network-settings.h" @@ -106,6 +107,8 @@ private Q_SLOTS: void getAndThenDeleteObject(); void getAndThenDeleteObject_data(); + + void overlappingCloseAndWrite(); }; tst_QHttpNetworkConnection::tst_QHttpNetworkConnection() @@ -1112,6 +1115,57 @@ void tst_QHttpNetworkConnection::getAndThenDeleteObject() } } +class TestTcpServer : public QTcpServer +{ + Q_OBJECT +public: + TestTcpServer() : errorCodeReports(0) + { + connect(this, &QTcpServer::newConnection, this, &TestTcpServer::onNewConnection); + QVERIFY(listen(QHostAddress::LocalHost)); + } + + int errorCodeReports; + +public slots: + void onNewConnection() + { + QTcpSocket *socket = nextPendingConnection(); + if (!socket) + return; + // close socket instantly! + connect(socket, &QTcpSocket::readyRead, socket, &QTcpSocket::close); + } + + void onReply(QNetworkReply::NetworkError code) + { + QCOMPARE(code, QNetworkReply::RemoteHostClosedError); + ++errorCodeReports; + } +}; + +void tst_QHttpNetworkConnection::overlappingCloseAndWrite() +{ + // server accepts connections, but closes the socket instantly + TestTcpServer server; + QNetworkAccessManager accessManager; + + // ten requests are scheduled. All should result in an RemoteHostClosed... + QUrl url; + url.setScheme(QStringLiteral("http")); + url.setHost(server.serverAddress().toString()); + url.setPort(server.serverPort()); + for (int i = 0; i < 10; ++i) { + QNetworkRequest request(url); + QNetworkReply *reply = accessManager.get(request); + // Not using Qt5 connection syntax here because of overly baroque syntax to discern between + // different error() methods. + QObject::connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), + &server, SLOT(onReply(QNetworkReply::NetworkError))); + } + + QTRY_COMPARE(server.errorCodeReports, 10); +} QTEST_MAIN(tst_QHttpNetworkConnection) -- cgit v1.2.3 From 110a8c339fa078a4edd09a70239280e482b149f1 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 3 Nov 2015 08:04:15 -0500 Subject: Remove qatomic_mips.h: the 3-operand testAndSet is broken MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The "previous" value is always 1 when the compare-and-swap succeeded, instead of the previous value. Instead of fixing this, let's just remove this file a bit earlier than the rest. All of them will be removed in Qt 5.7 anyway, so let's leave MIPS atomics to the compiler. Task-number: QTBUG-49168 Change-Id: Idba8c29717f34c70a58fffff14133304595165f5 Reviewed-by: Dmitry Shachnev Reviewed-by: Oswald Buddenhagen Reviewed-by: Marc Mutz Reviewed-by: Thiago Macieira Reviewed-by: Lisandro Damián Nicanor Pérez Meyer --- src/corelib/arch/qatomic_mips.h | 351 -------------------------------------- src/corelib/thread/qbasicatomic.h | 2 - 2 files changed, 353 deletions(-) delete mode 100644 src/corelib/arch/qatomic_mips.h diff --git a/src/corelib/arch/qatomic_mips.h b/src/corelib/arch/qatomic_mips.h deleted file mode 100644 index 8c400e0076..0000000000 --- a/src/corelib/arch/qatomic_mips.h +++ /dev/null @@ -1,351 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Copyright (C) 2011 Thiago Macieira -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QATOMIC_MIPS_H -#define QATOMIC_MIPS_H - -#include - -QT_BEGIN_NAMESPACE - -#if 0 -// silence syncqt warnings -QT_END_NAMESPACE -#pragma qt_sync_skip_header_check -#pragma qt_sync_stop_processing -#endif - -#define Q_ATOMIC_INT_REFERENCE_COUNTING_IS_ALWAYS_NATIVE -#define Q_ATOMIC_INT_TEST_AND_SET_IS_ALWAYS_NATIVE -#define Q_ATOMIC_INT_FETCH_AND_STORE_IS_ALWAYS_NATIVE -#define Q_ATOMIC_INT_FETCH_AND_ADD_IS_ALWAYS_NATIVE - -#define Q_ATOMIC_INT32_IS_SUPPORTED -#define Q_ATOMIC_INT32_REFERENCE_COUNTING_IS_ALWAYS_NATIVE -#define Q_ATOMIC_INT32_TEST_AND_SET_IS_ALWAYS_NATIVE -#define Q_ATOMIC_INT32_FETCH_AND_STORE_IS_ALWAYS_NATIVE -#define Q_ATOMIC_INT32_FETCH_AND_ADD_IS_ALWAYS_NATIVE - -#define Q_ATOMIC_POINTER_TEST_AND_SET_IS_ALWAYS_NATIVE -#define Q_ATOMIC_POINTER_FETCH_AND_STORE_IS_ALWAYS_NATIVE -#define Q_ATOMIC_POINTER_FETCH_AND_ADD_IS_ALWAYS_NATIVE - -template struct QBasicAtomicOps: QGenericAtomicOps > -{ - template - static void acquireMemoryFence(const T &) Q_DECL_NOTHROW; - template - static void releaseMemoryFence(const T &) Q_DECL_NOTHROW; - template - static void orderedMemoryFence(const T &) Q_DECL_NOTHROW; - - static inline Q_DECL_CONSTEXPR bool isReferenceCountingNative() Q_DECL_NOTHROW { return true; } - template static bool ref(T &_q_value) Q_DECL_NOTHROW; - template static bool deref(T &_q_value) Q_DECL_NOTHROW; - - static inline Q_DECL_CONSTEXPR bool isTestAndSetNative() Q_DECL_NOTHROW { return true; } - static inline Q_DECL_CONSTEXPR bool isTestAndSetWaitFree() Q_DECL_NOTHROW { return false; } - template static bool - testAndSetRelaxed(T &_q_value, T expectedValue, T newValue, T *currentValue = 0) Q_DECL_NOTHROW; - - static inline Q_DECL_CONSTEXPR bool isFetchAndStoreNative() Q_DECL_NOTHROW { return true; } - template static T fetchAndStoreRelaxed(T &_q_value, T newValue) Q_DECL_NOTHROW; - - static inline Q_DECL_CONSTEXPR bool isFetchAndAddNative() Q_DECL_NOTHROW { return true; } - template static - T fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW; -}; - -template struct QAtomicOps : QBasicAtomicOps -{ - typedef T Type; -}; - -#if defined(Q_CC_GNU) - -#if defined(_MIPS_ARCH_MIPS1) || (!defined(Q_CC_CLANG) && defined(__mips) && __mips - 0 == 1) -# error "Sorry, the MIPS1 architecture is not supported" -# error "please set '-march=' to your architecture (e.g., -march=mips32)" -#endif - -template template inline -void QBasicAtomicOps::acquireMemoryFence(const T &) Q_DECL_NOTHROW -{ - asm volatile (".set push\n" - ".set mips32\n" - "sync 0x11\n" - ".set pop\n" ::: "memory"); -} - -template template inline -void QBasicAtomicOps::releaseMemoryFence(const T &) Q_DECL_NOTHROW -{ - asm volatile (".set push\n" - ".set mips32\n" - "sync 0x12\n" - ".set pop\n" ::: "memory"); -} - -template template inline -void QBasicAtomicOps::orderedMemoryFence(const T &) Q_DECL_NOTHROW -{ - asm volatile (".set push\n" - ".set mips32\n" - "sync 0\n" - ".set pop\n" ::: "memory"); -} - -template<> template inline -bool QBasicAtomicOps<4>::ref(T &_q_value) Q_DECL_NOTHROW -{ - T originalValue; - T newValue; - asm volatile("0:\n" - "ll %[originalValue], %[_q_value]\n" - "addiu %[newValue], %[originalValue], %[one]\n" - "sc %[newValue], %[_q_value]\n" - "beqz %[newValue], 0b\n" - "nop\n" - : [originalValue] "=&r" (originalValue), - [_q_value] "+m" (_q_value), - [newValue] "=&r" (newValue) - : [one] "i" (1) - : "cc", "memory"); - return originalValue != T(-1); -} - -template<> template inline -bool QBasicAtomicOps<4>::deref(T &_q_value) Q_DECL_NOTHROW -{ - T originalValue; - T newValue; - asm volatile("0:\n" - "ll %[originalValue], %[_q_value]\n" - "addiu %[newValue], %[originalValue], %[minusOne]\n" - "sc %[newValue], %[_q_value]\n" - "beqz %[newValue], 0b\n" - "nop\n" - : [originalValue] "=&r" (originalValue), - [_q_value] "+m" (_q_value), - [newValue] "=&r" (newValue) - : [minusOne] "i" (-1) - : "cc", "memory"); - return originalValue != 1; -} - -template<> template inline -bool QBasicAtomicOps<4>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue, T *currentValue) Q_DECL_NOTHROW -{ - T result; - T tempValue; - asm volatile("0:\n" - "ll %[tempValue], %[_q_value]\n" - "xor %[result], %[tempValue], %[expectedValue]\n" - "bnez %[result], 0f\n" - "nop\n" - "move %[tempValue], %[newValue]\n" - "sc %[tempValue], %[_q_value]\n" - "beqz %[tempValue], 0b\n" - "nop\n" - "0:\n" - : [result] "=&r" (result), - [tempValue] "=&r" (tempValue), - [_q_value] "+m" (_q_value) - : [expectedValue] "r" (expectedValue), - [newValue] "r" (newValue) - : "cc", "memory"); - if (currentValue) - *currentValue = tempValue; - return result == 0; -} - -template<> template inline -T QBasicAtomicOps<4>::fetchAndStoreRelaxed(T &_q_value, T newValue) Q_DECL_NOTHROW -{ - T originalValue; - T tempValue; - asm volatile("0:\n" - "ll %[originalValue], %[_q_value]\n" - "move %[tempValue], %[newValue]\n" - "sc %[tempValue], %[_q_value]\n" - "beqz %[tempValue], 0b\n" - "nop\n" - : [originalValue] "=&r" (originalValue), - [tempValue] "=&r" (tempValue), - [_q_value] "+m" (_q_value) - : [newValue] "r" (newValue) - : "cc", "memory"); - return originalValue; -} - -template<> template inline -T QBasicAtomicOps<4>::fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW -{ - T originalValue; - T newValue; - asm volatile("0:\n" - "ll %[originalValue], %[_q_value]\n" - "addu %[newValue], %[originalValue], %[valueToAdd]\n" - "sc %[newValue], %[_q_value]\n" - "beqz %[newValue], 0b\n" - "nop\n" - : [originalValue] "=&r" (originalValue), - [_q_value] "+m" (_q_value), - [newValue] "=&r" (newValue) - : [valueToAdd] "r" (valueToAdd * QAtomicAdditiveType::AddScale) - : "cc", "memory"); - return originalValue; -} - -#if defined(Q_PROCESSOR_MIPS_64) - -#define Q_ATOMIC_INT64_IS_SUPPORTED -#define Q_ATOMIC_INT64_REFERENCE_COUNTING_IS_ALWAYS_NATIVE -#define Q_ATOMIC_INT64_TEST_AND_SET_IS_ALWAYS_NATIVE -#define Q_ATOMIC_INT64_FETCH_AND_STORE_IS_ALWAYS_NATIVE -#define Q_ATOMIC_INT64_FETCH_AND_ADD_IS_ALWAYS_NATIVE - -template<> struct QAtomicOpsSupport<8> { enum { IsSupported = 1 }; }; - -template<> template inline -bool QBasicAtomicOps<8>::ref(T &_q_value) Q_DECL_NOTHROW -{ - T originalValue; - T newValue; - asm volatile("0:\n" - "lld %[originalValue], %[_q_value]\n" - "addiu %[newValue], %[originalValue], %[one]\n" - "scd %[newValue], %[_q_value]\n" - "beqz %[newValue], 0b\n" - "nop\n" - : [originalValue] "=&r" (originalValue), - [_q_value] "+m" (_q_value), - [newValue] "=&r" (newValue) - : [one] "i" (1) - : "cc", "memory"); - return originalValue != T(-1); -} - -template<> template inline -bool QBasicAtomicOps<8>::deref(T &_q_value) Q_DECL_NOTHROW -{ - T originalValue; - T newValue; - asm volatile("0:\n" - "lld %[originalValue], %[_q_value]\n" - "addiu %[newValue], %[originalValue], %[minusOne]\n" - "scd %[newValue], %[_q_value]\n" - "beqz %[newValue], 0b\n" - "nop\n" - : [originalValue] "=&r" (originalValue), - [_q_value] "+m" (_q_value), - [newValue] "=&r" (newValue) - : [minusOne] "i" (-1) - : "cc", "memory"); - return originalValue != 1; -} - -template<> template inline -bool QBasicAtomicOps<8>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue, T *currentValue) Q_DECL_NOTHROW -{ - T result; - T tempValue; - asm volatile("0:\n" - "lld %[tempValue], %[_q_value]\n" - "xor %[result], %[tempValue], %[expectedValue]\n" - "bnez %[result], 0f\n" - "nop\n" - "move %[tempValue], %[newValue]\n" - "scd %[tempValue], %[_q_value]\n" - "beqz %[tempValue], 0b\n" - "nop\n" - "0:\n" - : [result] "=&r" (result), - [tempValue] "=&r" (tempValue), - [_q_value] "+m" (_q_value) - : [expectedValue] "r" (expectedValue), - [newValue] "r" (newValue) - : "cc", "memory"); - if (currentValue) - *currentValue = tempValue; - return result == 0; -} - -template<> template inline -T QBasicAtomicOps<8>::fetchAndStoreRelaxed(T &_q_value, T newValue) Q_DECL_NOTHROW -{ - T originalValue; - T tempValue; - asm volatile("0:\n" - "lld %[originalValue], %[_q_value]\n" - "move %[tempValue], %[newValue]\n" - "scd %[tempValue], %[_q_value]\n" - "beqz %[tempValue], 0b\n" - "nop\n" - : [originalValue] "=&r" (originalValue), - [tempValue] "=&r" (tempValue), - [_q_value] "+m" (_q_value) - : [newValue] "r" (newValue) - : "cc", "memory"); - return originalValue; -} - -template<> template inline -T QBasicAtomicOps<8>::fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType::AdditiveT valueToAdd) Q_DECL_NOTHROW -{ - T originalValue; - T newValue; - asm volatile("0:\n" - "lld %[originalValue], %[_q_value]\n" - "addu %[newValue], %[originalValue], %[valueToAdd]\n" - "scd %[newValue], %[_q_value]\n" - "beqz %[newValue], 0b\n" - "nop\n" - : [originalValue] "=&r" (originalValue), - [_q_value] "+m" (_q_value), - [newValue] "=&r" (newValue) - : [valueToAdd] "r" (valueToAdd * QAtomicAdditiveType::AddScale) - : "cc", "memory"); - return originalValue; -} - -#endif // MIPS64 - -#else -# error "This compiler for MIPS is not supported" -#endif // Q_CC_GNU - -QT_END_NAMESPACE - -#endif // QATOMIC_MIPS_H diff --git a/src/corelib/thread/qbasicatomic.h b/src/corelib/thread/qbasicatomic.h index ecf39d699f..3c16cf5b9c 100644 --- a/src/corelib/thread/qbasicatomic.h +++ b/src/corelib/thread/qbasicatomic.h @@ -60,8 +60,6 @@ # include "QtCore/qatomic_armv5.h" #elif defined(Q_PROCESSOR_IA64) # include "QtCore/qatomic_ia64.h" -#elif defined(Q_PROCESSOR_MIPS) -# include "QtCore/qatomic_mips.h" #elif defined(Q_PROCESSOR_X86) # include -- cgit v1.2.3 From cd0a1251232baf17fdfa002d2299305d5613063c Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Thu, 14 May 2015 02:47:21 +0400 Subject: Minor optimization to QWidgetPrivate::naturalWidgetFont() When inheritedMask is 0, the font inherits just everything; in this case `inheritedFont.resolve(baseFont)` could be replaced with `baseFont`. Change-Id: Ic3ed8ef174493544ada32037e7bdded46eb4bd43 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/widgets/kernel/qwidget.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 49da4d1faf..2d7c03116b 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -4699,9 +4699,11 @@ QFont QWidgetPrivate::naturalWidgetFont(uint inheritedMask) const if (QWidget *p = q->parentWidget()) { if (!p->testAttribute(Qt::WA_StyleSheet)) { if (!naturalFont.isCopyOf(QApplication::font())) { - QFont inheritedFont = p->font(); - inheritedFont.resolve(inheritedMask); - naturalFont = inheritedFont.resolve(naturalFont); + if (inheritedMask != 0) { + QFont inheritedFont = p->font(); + inheritedFont.resolve(inheritedMask); + naturalFont = inheritedFont.resolve(naturalFont); + } // else nothing to do (naturalFont = naturalFont) } else { naturalFont = p->font(); } @@ -4709,9 +4711,11 @@ QFont QWidgetPrivate::naturalWidgetFont(uint inheritedMask) const } #ifndef QT_NO_GRAPHICSVIEW else if (extra && extra->proxyWidget) { - QFont inheritedFont = extra->proxyWidget->font(); - inheritedFont.resolve(inheritedMask); - naturalFont = inheritedFont.resolve(naturalFont); + if (inheritedMask != 0) { + QFont inheritedFont = extra->proxyWidget->font(); + inheritedFont.resolve(inheritedMask); + naturalFont = inheritedFont.resolve(naturalFont); + } // else nothing to do (naturalFont = naturalFont) } #endif //QT_NO_GRAPHICSVIEW } -- cgit v1.2.3 From 9daef8a54c32162a50b0f558dac829333165618f Mon Sep 17 00:00:00 2001 From: Adam Strzelecki Date: Thu, 5 Nov 2015 22:35:42 +0100 Subject: QComboBox: Disable wheel events on OS X & iOS This is follow-up for QTabBar fix ea47d152b35158ba07a55d009f57df0e4c2a048f. In native OS X applications using mouse wheel on combo boxes have absolutely no effect. We should bring the same behavior to Qt based OS X apps too, as users are complaining of unexpected behavior, eg. randomly switching Qt Creator sidebar mode when scrolling file list and moving mouse pointer little bit above. Moreover inertial mouse behavior on OS X makes combo box usually move several indexes, rather than single one on slight finger slide. This also applies to iOS apps so the change affects all Apple platforms. Task-number: QTBUG-10707 Change-Id: I6582265039198707ad8c2f54de96ee2a0b0e0b47 Reviewed-by: Adam Strzelecki Reviewed-by: Jake Petroules --- src/widgets/widgets/qcombobox.cpp | 4 ++++ tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index 4840b75c1b..c97159d4cb 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -3238,6 +3238,9 @@ void QComboBox::keyReleaseEvent(QKeyEvent *e) #ifndef QT_NO_WHEELEVENT void QComboBox::wheelEvent(QWheelEvent *e) { +#ifdef Q_OS_DARWIN + Q_UNUSED(e); +#else Q_D(QComboBox); if (!d->viewContainer()->isVisible()) { int newIndex = currentIndex(); @@ -3258,6 +3261,7 @@ void QComboBox::wheelEvent(QWheelEvent *e) } e->accept(); } +#endif } #endif diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp index 7824172812..21446de069 100644 --- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp @@ -2044,7 +2044,13 @@ void tst_QComboBox::mouseWheel_data() QTest::newRow("upper locked") << disabled << start << wheel << expected; wheel = -1; +#ifdef Q_OS_DARWIN + // on OS X & iOS mouse wheel shall have no effect on combo box + expected = start; +#else + // on other OSes we should jump to next enabled item (no. 5) expected = 5; +#endif QTest::newRow("jump over") << disabled << start << wheel << expected; disabled.clear(); -- cgit v1.2.3