diff options
author | Liang Qi <liang.qi@qt.io> | 2016-08-10 17:43:12 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2016-08-10 17:43:13 +0200 |
commit | 8ba384a5645aebbefe34b814828024d511171497 (patch) | |
tree | 6f6cfe1b849b6e0e02de15ee74ad0f3d5fc740b6 | |
parent | e694ced803589b3504b6bdb2fc8bf97bc891c794 (diff) | |
parent | 25b72a63fffe800f2005b21d254b0b191d263b10 (diff) |
Merge remote-tracking branch 'origin/5.6' into 5.7
Change-Id: I1a63523de158757964b6fb5ea026cf69a6c5ddcf
31 files changed, 311 insertions, 64 deletions
diff --git a/doc/global/template/style/offline.css b/doc/global/template/style/offline.css index 1c5a2dfa61..612c1087d5 100644 --- a/doc/global/template/style/offline.css +++ b/doc/global/template/style/offline.css @@ -47,9 +47,6 @@ tt { text-align: left } -.main { - display: none; -} /* ----------- links diff --git a/examples/widgets/draganddrop/draggabletext/dragwidget.cpp b/examples/widgets/draganddrop/draggabletext/dragwidget.cpp index b184fcf060..fb169b953b 100644 --- a/examples/widgets/draganddrop/draggabletext/dragwidget.cpp +++ b/examples/widgets/draganddrop/draggabletext/dragwidget.cpp @@ -160,7 +160,9 @@ void DragWidget::mousePressEvent(QMouseEvent *event) mimeData->setData(hotSpotMimeDataKey(), QByteArray::number(hotSpot.x()) + ' ' + QByteArray::number(hotSpot.y())); - QPixmap pixmap(child->size()); + qreal dpr = window()->windowHandle()->devicePixelRatio(); + QPixmap pixmap(child->size() * dpr); + pixmap.setDevicePixelRatio(dpr); child->render(&pixmap); QDrag *drag = new QDrag(this); diff --git a/examples/widgets/widgets/icons/images/designer.png b/examples/widgets/widgets/icons/images/designer.png Binary files differindex 0988fcee3f..9f8578b49e 100644 --- a/examples/widgets/widgets/icons/images/designer.png +++ b/examples/widgets/widgets/icons/images/designer.png diff --git a/examples/widgets/widgets/icons/images/qt_extended_16x16.png b/examples/widgets/widgets/icons/images/qt_extended_16x16.png Binary files differindex bee4e7d6cd..30bcb45ed2 100644 --- a/examples/widgets/widgets/icons/images/qt_extended_16x16.png +++ b/examples/widgets/widgets/icons/images/qt_extended_16x16.png diff --git a/examples/widgets/widgets/icons/images/qt_extended_32x32.png b/examples/widgets/widgets/icons/images/qt_extended_32x32.png Binary files differindex 6e7d000c04..d609c1e1e5 100644 --- a/examples/widgets/widgets/icons/images/qt_extended_32x32.png +++ b/examples/widgets/widgets/icons/images/qt_extended_32x32.png diff --git a/examples/widgets/widgets/icons/images/qt_extended_48x48.png b/examples/widgets/widgets/icons/images/qt_extended_48x48.png Binary files differindex 7a93d88900..0e524fed5f 100644 --- a/examples/widgets/widgets/icons/images/qt_extended_48x48.png +++ b/examples/widgets/widgets/icons/images/qt_extended_48x48.png diff --git a/mkspecs/common/msvc-base.conf b/mkspecs/common/msvc-base.conf index 5bd144faa0..37f38560e8 100644 --- a/mkspecs/common/msvc-base.conf +++ b/mkspecs/common/msvc-base.conf @@ -52,5 +52,5 @@ greaterThan(MSC_VER, 1899) { QMAKE_CFLAGS_WARN_ON += -w44456 -w44457 -w44458 QMAKE_CFLAGS_AVX2 = -arch:AVX2 QMAKE_CXXFLAGS += -Zc:strictStrings -Zc:throwingNew - QMAKE_CXXFLAGS_WARN_ON += -w44456 -w44457 -w44458 -wd4577 + QMAKE_CXXFLAGS_WARN_ON += -w44456 -w44457 -w44458 -wd4577 -wd4467 } diff --git a/src/corelib/io/qlockfile_unix.cpp b/src/corelib/io/qlockfile_unix.cpp index 0895f9a3fc..2c564aca44 100644 --- a/src/corelib/io/qlockfile_unix.cpp +++ b/src/corelib/io/qlockfile_unix.cpp @@ -188,7 +188,7 @@ QLockFile::LockError QLockFilePrivate::tryLock_sys() % localHostName() % '\n'; const QByteArray lockFileName = QFile::encodeName(fileName); - const int fd = qt_safe_open(lockFileName.constData(), O_WRONLY | O_CREAT | O_EXCL, 0644); + const int fd = qt_safe_open(lockFileName.constData(), O_WRONLY | O_CREAT | O_EXCL, 0666); if (fd < 0) { switch (errno) { case EEXIST: @@ -229,7 +229,7 @@ QLockFile::LockError QLockFilePrivate::tryLock_sys() bool QLockFilePrivate::removeStaleLock() { const QByteArray lockFileName = QFile::encodeName(fileName); - const int fd = qt_safe_open(lockFileName.constData(), O_WRONLY, 0644); + const int fd = qt_safe_open(lockFileName.constData(), O_WRONLY, 0666); if (fd < 0) // gone already? return false; bool success = setNativeLocks(fileName, fd) && (::unlink(lockFileName) == 0); diff --git a/src/corelib/tools/qmap.cpp b/src/corelib/tools/qmap.cpp index 90edeca0a8..406eb31923 100644 --- a/src/corelib/tools/qmap.cpp +++ b/src/corelib/tools/qmap.cpp @@ -539,9 +539,6 @@ void QMapDataBase::freeData(QMapDataBase *d) Constructs a copy of \a other. - This function is only available if Qt is configured with STL - compatibility enabled. - \sa toStdMap() */ @@ -558,9 +555,6 @@ void QMapDataBase::freeData(QMapDataBase *d) /*! \fn std::map<Key, T> QMap::toStdMap() const Returns an STL map equivalent to this QMap. - - This function is only available if Qt is configured with STL - compatibility enabled. */ /*! \fn QMap::~QMap() diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index 00b8e05f30..1b7edb1278 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -448,6 +448,11 @@ void QWindowSystemInterface::unregisterTouchDevice(const QTouchDevice *device) QTouchDevicePrivate::unregisterDevice(device); } +bool QWindowSystemInterface::isTouchDeviceRegistered(const QTouchDevice *device) +{ + return QTouchDevicePrivate::isRegistered(device); +} + void QWindowSystemInterface::handleTouchEvent(QWindow *w, QTouchDevice *device, const QList<TouchPoint> &points, Qt::KeyboardModifiers mods) { diff --git a/src/gui/kernel/qwindowsysteminterface.h b/src/gui/kernel/qwindowsysteminterface.h index 00437e8341..6bf87439b9 100644 --- a/src/gui/kernel/qwindowsysteminterface.h +++ b/src/gui/kernel/qwindowsysteminterface.h @@ -130,6 +130,7 @@ public: static void registerTouchDevice(const QTouchDevice *device); static void unregisterTouchDevice(const QTouchDevice *device); + static bool isTouchDeviceRegistered(const QTouchDevice *device); static void handleTouchEvent(QWindow *w, QTouchDevice *device, const QList<struct TouchPoint> &points, Qt::KeyboardModifiers mods = Qt::NoModifier); static void handleTouchEvent(QWindow *w, ulong timestamp, QTouchDevice *device, diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp index 20dd8d7f82..0d24fd94f5 100644 --- a/src/gui/painting/qcolor.cpp +++ b/src/gui/painting/qcolor.cpp @@ -527,9 +527,10 @@ QString QColor::name(NameFormat format) const { switch (format) { case HexRgb: - return QString::asprintf("#%02x%02x%02x", red(), green(), blue()); + return QLatin1Char('#') + QString::number(rgba() | 0x1000000, 16).rightRef(6); case HexArgb: - return QString::asprintf("#%02x%02x%02x%02x", alpha(), red(), green(), blue()); + // it's called rgba() but it does return AARRGGBB + return QLatin1Char('#') + QString::number(rgba() | 0x100000000, 16).rightRef(8); } return QString(); } diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index cdfcdec80c..ca569e5961 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -2801,6 +2801,7 @@ void QFontDatabase::load(const QFontPrivate *d, int script) req.fallBackFamilies.clear(); } + Q_ASSERT(fe); if (fe->symbol || (d->request.styleStrategy & QFont::NoFontMerging)) { for (int i = 0; i < QChar::ScriptCount; ++i) { if (!d->engineData->engines[i]) { diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp index fcb8a60c8f..2d50cc1f8d 100644 --- a/src/network/socket/qnativesocketengine_unix.cpp +++ b/src/network/socket/qnativesocketengine_unix.cpp @@ -294,7 +294,7 @@ int QNativeSocketEnginePrivate::option(QNativeSocketEngine::SocketOption opt) co // handle non-getsockopt cases first if (opt == QNativeSocketEngine::BindExclusively || opt == QNativeSocketEngine::NonBlockingSocketOption || opt == QNativeSocketEngine::BroadcastSocketOption) - return true; + return -1; int n, level; int v = -1; diff --git a/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp b/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp index 6b98ed30a9..435f411f96 100644 --- a/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp +++ b/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp @@ -400,9 +400,13 @@ void QEvdevTouchScreenHandler::unregisterTouchDevice() if (!m_device) return; - QWindowSystemInterface::unregisterTouchDevice(m_device); + // At app exit the cleanup may have already been done, avoid + // double delete by checking the list first. + if (QWindowSystemInterface::isTouchDeviceRegistered(m_device)) { + QWindowSystemInterface::unregisterTouchDevice(m_device); + delete m_device; + } - delete m_device; m_device = Q_NULLPTR; } diff --git a/src/plugins/platforms/cocoa/qcocoadrag.mm b/src/plugins/platforms/cocoa/qcocoadrag.mm index 872b97566f..bb8d12e3ce 100644 --- a/src/plugins/platforms/cocoa/qcocoadrag.mm +++ b/src/plugins/platforms/cocoa/qcocoadrag.mm @@ -40,6 +40,9 @@ #include "qcocoadrag.h" #include "qmacclipboard.h" #include "qcocoahelpers.h" +#ifndef QT_NO_WIDGETS +#include <QtWidgets/qwidget.h> +#endif QT_BEGIN_NAMESPACE @@ -187,7 +190,18 @@ QPixmap QCocoaDrag::dragPixmap(QDrag *drag, QPoint &hotSpot) const const int width = fm.width(s); const int height = fm.height(); if (width > 0 && height > 0) { - pm = QPixmap(width, height); + qreal dpr = 1.0; + if (const QWindow *sourceWindow = qobject_cast<QWindow *>(drag->source())) { + dpr = sourceWindow->devicePixelRatio(); + } +#ifndef QT_NO_WIDGETS + else if (const QWidget *sourceWidget = qobject_cast<QWidget *>(drag->source())) { + if (const QWindow *sourceWindow = sourceWidget->window()->windowHandle()) + dpr = sourceWindow->devicePixelRatio(); + } +#endif + pm = QPixmap(width * dpr, height * dpr); + pm.setDevicePixelRatio(dpr); QPainter p(&pm); p.fillRect(0, 0, pm.width(), pm.height(), Qt::color0); p.setPen(Qt::color1); diff --git a/src/plugins/platforms/winrt/qwinrtwindow.cpp b/src/plugins/platforms/winrt/qwinrtwindow.cpp index a910967f87..606ca22bcd 100644 --- a/src/plugins/platforms/winrt/qwinrtwindow.cpp +++ b/src/plugins/platforms/winrt/qwinrtwindow.cpp @@ -322,10 +322,59 @@ void QWinRTWindow::setWindowState(Qt::WindowState state) if (d->state == state) return; +#if _MSC_VER >= 1900 + if (state == Qt::WindowFullScreen) { + HRESULT hr; + boolean success; + hr = QEventDispatcherWinRT::runOnXamlThread([&hr, &success]() { + ComPtr<IApplicationViewStatics2> applicationViewStatics; + hr = RoGetActivationFactory(HString::MakeReference(RuntimeClass_Windows_UI_ViewManagement_ApplicationView).Get(), + IID_PPV_ARGS(&applicationViewStatics)); + RETURN_HR_IF_FAILED("Could not access application view statics."); + ComPtr<IApplicationView> view; + hr = applicationViewStatics->GetForCurrentView(&view); + RETURN_HR_IF_FAILED("Could not access application view."); + ComPtr<IApplicationView3> view3; + hr = view.As(&view3); + Q_ASSERT_SUCCEEDED(hr); + hr = view3->TryEnterFullScreenMode(&success); + return hr; + }); + if (FAILED(hr) || !success) { + qCDebug(lcQpaWindows) << "Failed to enter full screen mode."; + return; + } + d->state = state; + return; + } + + if (d->state == Qt::WindowFullScreen) { + HRESULT hr; + hr = QEventDispatcherWinRT::runOnXamlThread([&hr]() { + ComPtr<IApplicationViewStatics2> applicationViewStatics; + hr = RoGetActivationFactory(HString::MakeReference(RuntimeClass_Windows_UI_ViewManagement_ApplicationView).Get(), + IID_PPV_ARGS(&applicationViewStatics)); + RETURN_HR_IF_FAILED("Could not access application view statics."); + ComPtr<IApplicationView> view; + hr = applicationViewStatics->GetForCurrentView(&view); + RETURN_HR_IF_FAILED("Could not access application view."); + ComPtr<IApplicationView3> view3; + hr = view.As(&view3); + Q_ASSERT_SUCCEEDED(hr); + hr = view3->ExitFullScreenMode(); + return hr; + }); + if (FAILED(hr)) { + qCDebug(lcQpaWindows) << "Failed to exit full screen mode."; + return; + } + } +#endif // _MSC_VER >= 1900 + if (state == Qt::WindowMinimized) setUIElementVisibility(d->uiElement.Get(), false); - if (d->state == Qt::WindowMinimized) + if (d->state == Qt::WindowMinimized || state == Qt::WindowNoState || state == Qt::WindowActive) setUIElementVisibility(d->uiElement.Get(), true); d->state = state; diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index 88f9e899bf..703af6b677 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -1293,8 +1293,13 @@ void TestMethods::invokeTests(QObject *testObject) const m_initTestCaseDataMethod.invoke(testObject, Qt::DirectConnection); QScopedPointer<WatchDog> watchDog; - if (!debuggerPresent()) + if (!debuggerPresent() +#ifdef QTESTLIB_USE_VALGRIND + && QBenchmarkGlobalData::current->mode() != QBenchmarkGlobalData::CallgrindChildProcess +#endif + ) { watchDog.reset(new WatchDog); + } if (!QTestResult::skipCurrentTest() && !QTest::currentTestFailed()) { if (m_initTestCaseMethod.isValid()) diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp index f08de35de2..714841d6cf 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.cpp +++ b/src/tools/uic/cpp/cppwriteinitialization.cpp @@ -84,10 +84,14 @@ namespace { const QHash<QString, DomProperty *> properties = propertyMap(node->elementProperty()); output << "new QSpacerItem("; + int w = 0; + int h = 0; if (properties.contains(QLatin1String("sizeHint"))) { const DomSize *sizeHint = properties.value(QLatin1String("sizeHint"))->elementSize(); - output << sizeHint->elementWidth() << ", " << sizeHint->elementHeight() << ", "; + w = sizeHint->elementWidth(); + h = sizeHint->elementHeight(); } + output << w << ", " << h << ", "; // size type QString sizeType = properties.contains(QLatin1String("sizeType")) ? diff --git a/src/widgets/widgets/qtabbar.cpp b/src/widgets/widgets/qtabbar.cpp index 09b7cb9d24..756833ef15 100644 --- a/src/widgets/widgets/qtabbar.cpp +++ b/src/widgets/widgets/qtabbar.cpp @@ -140,60 +140,59 @@ void QTabBarPrivate::updateMacBorderMetrics() } /*! - Initialize \a option with the values from the tab at \a tabIndex. This method - is useful for subclasses when they need a QStyleOptionTab, - but don't want to fill in all the information themselves. - - \sa QStyleOption::initFrom(), QTabWidget::initStyleOption() + \internal + This is basically QTabBar::initStyleOption() but + without the expensive QFontMetrics::elidedText() call. */ -void QTabBar::initStyleOption(QStyleOptionTab *option, int tabIndex) const + +void QTabBarPrivate::initBasicStyleOption(QStyleOptionTab *option, int tabIndex) const { - Q_D(const QTabBar); - int totalTabs = d->tabList.size(); + Q_Q(const QTabBar); + const int totalTabs = tabList.size(); if (!option || (tabIndex < 0 || tabIndex >= totalTabs)) return; - const QTabBarPrivate::Tab &tab = d->tabList.at(tabIndex); - option->initFrom(this); + const QTabBarPrivate::Tab &tab = tabList.at(tabIndex); + option->initFrom(q); option->state &= ~(QStyle::State_HasFocus | QStyle::State_MouseOver); - option->rect = tabRect(tabIndex); - bool isCurrent = tabIndex == d->currentIndex; + option->rect = q->tabRect(tabIndex); + const bool isCurrent = tabIndex == currentIndex; option->row = 0; - if (tabIndex == d->pressedIndex) + if (tabIndex == pressedIndex) option->state |= QStyle::State_Sunken; if (isCurrent) option->state |= QStyle::State_Selected; - if (isCurrent && hasFocus()) + if (isCurrent && q->hasFocus()) option->state |= QStyle::State_HasFocus; if (!tab.enabled) option->state &= ~QStyle::State_Enabled; - if (isActiveWindow()) + if (q->isActiveWindow()) option->state |= QStyle::State_Active; - if (!d->dragInProgress && option->rect == d->hoverRect) + if (!dragInProgress && option->rect == hoverRect) option->state |= QStyle::State_MouseOver; - option->shape = d->shape; + option->shape = shape; option->text = tab.text; if (tab.textColor.isValid()) - option->palette.setColor(foregroundRole(), tab.textColor); + option->palette.setColor(q->foregroundRole(), tab.textColor); option->icon = tab.icon; - option->iconSize = iconSize(); // Will get the default value then. + option->iconSize = q->iconSize(); // Will get the default value then. option->leftButtonSize = tab.leftWidget ? tab.leftWidget->size() : QSize(); option->rightButtonSize = tab.rightWidget ? tab.rightWidget->size() : QSize(); - option->documentMode = d->documentMode; + option->documentMode = documentMode; - if (tabIndex > 0 && tabIndex - 1 == d->currentIndex) + if (tabIndex > 0 && tabIndex - 1 == currentIndex) option->selectedPosition = QStyleOptionTab::PreviousIsSelected; - else if (tabIndex + 1 < totalTabs && tabIndex + 1 == d->currentIndex) + else if (tabIndex + 1 < totalTabs && tabIndex + 1 == currentIndex) option->selectedPosition = QStyleOptionTab::NextIsSelected; else option->selectedPosition = QStyleOptionTab::NotAdjacent; - bool paintBeginning = (tabIndex == 0) || (d->dragInProgress && tabIndex == d->pressedIndex + 1); - bool paintEnd = (tabIndex == totalTabs - 1) || (d->dragInProgress && tabIndex == d->pressedIndex - 1); + const bool paintBeginning = (tabIndex == 0) || (dragInProgress && tabIndex == pressedIndex + 1); + const bool paintEnd = (tabIndex == totalTabs - 1) || (dragInProgress && tabIndex == pressedIndex - 1); if (paintBeginning) { if (paintEnd) option->position = QStyleOptionTab::OnlyOneTab; @@ -206,7 +205,7 @@ void QTabBar::initStyleOption(QStyleOptionTab *option, int tabIndex) const } #ifndef QT_NO_TABWIDGET - if (const QTabWidget *tw = qobject_cast<const QTabWidget *>(parentWidget())) { + if (const QTabWidget *tw = qobject_cast<const QTabWidget *>(q->parentWidget())) { option->features |= QStyleOptionTab::HasFrame; if (tw->cornerWidget(Qt::TopLeftCorner) || tw->cornerWidget(Qt::BottomLeftCorner)) option->cornerWidgets |= QStyleOptionTab::LeftCornerWidget; @@ -214,6 +213,19 @@ void QTabBar::initStyleOption(QStyleOptionTab *option, int tabIndex) const option->cornerWidgets |= QStyleOptionTab::RightCornerWidget; } #endif +} + +/*! + Initialize \a option with the values from the tab at \a tabIndex. This method + is useful for subclasses when they need a QStyleOptionTab, + but don't want to fill in all the information themselves. + + \sa QStyleOption::initFrom(), QTabWidget::initStyleOption() +*/ +void QTabBar::initStyleOption(QStyleOptionTab *option, int tabIndex) const +{ + Q_D(const QTabBar); + d->initBasicStyleOption(option, tabIndex); QRect textRect = style()->subElementRect(QStyle::SE_TabBarTabText, option, this); option->text = fontMetrics().elidedText(option->text, d->elideMode, textRect.width(), @@ -1094,6 +1106,7 @@ void QTabBar::setTabText(int index, const QString &text) { Q_D(QTabBar); if (QTabBarPrivate::Tab *tab = d->at(index)) { + d->textSizes.remove(tab->text); tab->text = text; #ifndef QT_NO_SHORTCUT releaseShortcut(tab->shortcutId); @@ -1453,7 +1466,7 @@ QSize QTabBar::tabSizeHint(int index) const Q_D(const QTabBar); if (const QTabBarPrivate::Tab *tab = d->at(index)) { QStyleOptionTab opt; - initStyleOption(&opt, index); + d->initBasicStyleOption(&opt, index); opt.text = d->tabList.at(index).text; QSize iconSize = tab->icon.isNull() ? QSize(0, 0) : opt.iconSize; int hframe = style()->pixelMetric(QStyle::PM_TabBarTabHSpace, &opt, this); @@ -1479,13 +1492,16 @@ QSize QTabBar::tabSizeHint(int index) const if (!opt.icon.isNull()) padding += 4; + QHash<QString, QSize>::iterator it = d->textSizes.find(tab->text); + if (it == d->textSizes.end()) + it = d->textSizes.insert(tab->text, fm.size(Qt::TextShowMnemonic, tab->text)); + const int textWidth = it.value().width(); QSize csz; if (verticalTabs(d->shape)) { csz = QSize( qMax(maxWidgetWidth, qMax(fm.height(), iconSize.height())) + vframe, - fm.size(Qt::TextShowMnemonic, tab->text).width() + iconSize.width() + hframe + widgetHeight + padding); + textWidth + iconSize.width() + hframe + widgetHeight + padding); } else { - csz = QSize(fm.size(Qt::TextShowMnemonic, tab->text).width() + iconSize.width() + hframe - + widgetWidth + padding, + csz = QSize(textWidth + iconSize.width() + hframe + widgetWidth + padding, qMax(maxWidgetHeight, qMax(fm.height(), iconSize.height())) + vframe); } @@ -2157,15 +2173,21 @@ void QTabBarPrivate::setCurrentNextEnabledIndex(int offset) void QTabBar::changeEvent(QEvent *event) { Q_D(QTabBar); - if (event->type() == QEvent::StyleChange) { + switch (event->type()) { + case QEvent::StyleChange: if (!d->elideModeSetByUser) d->elideMode = Qt::TextElideMode(style()->styleHint(QStyle::SH_TabBar_ElideMode, 0, this)); if (!d->useScrollButtonsSetByUser) d->useScrollButtons = !style()->styleHint(QStyle::SH_TabBar_PreferNoArrows, 0, this); + // fallthrough + case QEvent::FontChange: + d->textSizes.clear(); d->refresh(); - } else if (event->type() == QEvent::FontChange) { - d->refresh(); + break; + default: + break; } + QWidget::changeEvent(event); } @@ -2208,6 +2230,7 @@ void QTabBar::setElideMode(Qt::TextElideMode mode) Q_D(QTabBar); d->elideMode = mode; d->elideModeSetByUser = true; + d->textSizes.clear(); d->refresh(); } diff --git a/src/widgets/widgets/qtabbar_p.h b/src/widgets/widgets/qtabbar_p.h index 48f235f050..a73c3e11e2 100644 --- a/src/widgets/widgets/qtabbar_p.h +++ b/src/widgets/widgets/qtabbar_p.h @@ -165,6 +165,7 @@ public: #endif //QT_NO_ANIMATION }; QList<Tab> tabList; + mutable QHash<QString, QSize> textSizes; int calculateNewPosition(int from, int to, int index) const; void slide(int from, int to); @@ -198,6 +199,8 @@ public: void autoHideTabs(); QRect normalizedScrollRect(int index = -1); + void initBasicStyleOption(QStyleOptionTab *option, int tabIndex) const; + void makeVisible(int index); QSize iconSize; Qt::TextElideMode elideMode; diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp index 1f0ace0dd3..59f271d727 100644 --- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp +++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp @@ -763,6 +763,7 @@ void tst_QProcess::restartProcess() // Reading and writing to a process is not supported on Qt/CE void tst_QProcess::closeWriteChannel() { + QByteArray testData("Data to read"); QProcess more; more.start("testProcessEOF/testProcessEOF"); @@ -770,19 +771,21 @@ void tst_QProcess::closeWriteChannel() QVERIFY(!more.waitForReadyRead(250)); QCOMPARE(more.error(), QProcess::Timedout); - QVERIFY(more.write("Data to read") != -1); + QCOMPARE(more.write(testData), qint64(testData.size())); QVERIFY(!more.waitForReadyRead(250)); QCOMPARE(more.error(), QProcess::Timedout); more.closeWriteChannel(); - - QVERIFY(more.waitForReadyRead(5000)); - QVERIFY(more.readAll().startsWith("Data to read")); + // During closeWriteChannel() call, we might also get an I/O completion + // on the read pipe. So, take this into account before waiting for + // the new incoming data. + while (more.bytesAvailable() < testData.size()) + QVERIFY(more.waitForReadyRead(5000)); + QCOMPARE(more.readAll(), testData); if (more.state() == QProcess::Running) - more.write("q"); - QVERIFY(more.waitForFinished(5000)); + QVERIFY(more.waitForFinished(5000)); QCOMPARE(more.exitStatus(), QProcess::NormalExit); QCOMPARE(more.exitCode(), 0); } diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp index 6aeea70cbf..44b8135410 100644 --- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp @@ -500,6 +500,8 @@ private slots: void fromLocal8Bit(); void local8Bit_data(); void local8Bit(); + void invalidToLocal8Bit_data(); + void invalidToLocal8Bit(); void nullFromLocal8Bit(); void fromLatin1Roundtrip_data(); void fromLatin1Roundtrip(); @@ -4298,6 +4300,66 @@ void tst_QString::local8Bit() QCOMPARE(local8Bit.toLocal8Bit(), QByteArray(result)); } +void tst_QString::invalidToLocal8Bit_data() +{ + QTest::addColumn<QString>("unicode"); + QTest::addColumn<QByteArray>("expect"); // Initial validly-converted prefix + + { + const QChar malformed[] = { 'A', 0xd800, 'B', 0 }; + const char expected[] = "A"; + QTest::newRow("LoneHighSurrogate") + << QString(malformed, sizeof(malformed) / sizeof(QChar)) + // Don't include the terminating '\0' of expected: + << QByteArray(expected, sizeof(expected) / sizeof(char) - 1); + } + { + const QChar malformed[] = { 'A', 0xdc00, 'B', 0 }; + const char expected[] = "A"; + QTest::newRow("LoneLowSurrogate") + << QString(malformed, sizeof(malformed) / sizeof(QChar)) + << QByteArray(expected, sizeof(expected) / sizeof(char) - 1); + } + { + const QChar malformed[] = { 'A', 0xd800, 0xd801, 'B', 0 }; + const char expected[] = "A"; + QTest::newRow("DoubleHighSurrogate") + << QString(malformed, sizeof(malformed) / sizeof(QChar)) + << QByteArray(expected, sizeof(expected) / sizeof(char) - 1); + } + { + const QChar malformed[] = { 'A', 0xdc00, 0xdc01, 'B', 0 }; + const char expected[] = "A"; + QTest::newRow("DoubleLowSurrogate") + << QString(malformed, sizeof(malformed) / sizeof(QChar)) + << QByteArray(expected, sizeof(expected) / sizeof(char) - 1); + } + { + const QChar malformed[] = { 'A', 0xdc00, 0xd800, 'B', 0 }; + const char expected[] = "A"; + QTest::newRow("ReversedSurrogates") // low before high + << QString(malformed, sizeof(malformed) / sizeof(QChar)) + << QByteArray(expected, sizeof(expected) / sizeof(char) - 1); + } +} + +void tst_QString::invalidToLocal8Bit() +{ + QFETCH(QString, unicode); + QFETCH(QByteArray, expect); + QByteArray local = unicode.toLocal8Bit(); + /* + The main concern of this test is to check that any error-reporting that + toLocal8Bit() prompts on failure isn't dependent on outputting the data + it's converting via toLocal8Bit(), which would be apt to recurse. So the + real purpose of this QVERIFY(), for all that we should indeed check we get + the borked output that matches what we can reliably expect (despite + variation in how codecs respond to errors), is to verify that we got here + - i.e. we didn't crash in such a recursive stack over-flow. + */ + QVERIFY(local.startsWith(expect)); +} + void tst_QString::nullFromLocal8Bit() { QString a; diff --git a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp index cffa444c97..00e7436c0f 100644 --- a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp +++ b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp @@ -279,6 +279,8 @@ void tst_QColor::name_data() QTest::newRow("global color darkMagenta") << QColor(Qt::darkMagenta) << "#800080" << QColor::HexRgb; QTest::newRow("global color darkYellow") << QColor(Qt::darkYellow) << "#808000" << QColor::HexRgb; QTest::newRow("transparent red") << QColor(255, 0, 0, 102) << "#66ff0000" << QColor::HexArgb; + QTest::newRow("fully_transparent_green_rgb") << QColor(0, 0, 255, 0) << "#0000ff" << QColor::HexRgb; + QTest::newRow("fully_transparent_green_argb") << QColor(0, 0, 255, 0) << "#000000ff" << QColor::HexArgb; } void tst_QColor::name() diff --git a/tests/auto/network/socket/platformsocketengine/tst_platformsocketengine.cpp b/tests/auto/network/socket/platformsocketengine/tst_platformsocketengine.cpp index 041a0ce16c..b3ecd884cd 100644 --- a/tests/auto/network/socket/platformsocketengine/tst_platformsocketengine.cpp +++ b/tests/auto/network/socket/platformsocketengine/tst_platformsocketengine.cpp @@ -111,6 +111,7 @@ void tst_PlatformSocketEngine::construction() QCOMPARE(socketDevice.peerAddress(), QHostAddress()); QCOMPARE(socketDevice.peerPort(), quint16(0)); QCOMPARE(socketDevice.error(), QAbstractSocket::UnknownSocketError); + QCOMPARE(socketDevice.option(QNativeSocketEngine::NonBlockingSocketOption), -1); QTest::ignoreMessage(QtWarningMsg, PLATFORMSOCKETENGINESTRING "::bytesAvailable() was called in QAbstractSocket::UnconnectedState"); QCOMPARE(socketDevice.bytesAvailable(), -1); diff --git a/tests/auto/tools/uic/baseline/imagedialog.ui.h b/tests/auto/tools/uic/baseline/imagedialog.ui.h index c02c40c2c1..99e853b7a8 100644 --- a/tests/auto/tools/uic/baseline/imagedialog.ui.h +++ b/tests/auto/tools/uic/baseline/imagedialog.ui.h @@ -155,7 +155,7 @@ public: vboxLayout->addLayout(gridLayout); - spacerItem = new QSpacerItem(QSizePolicy::Minimum, QSizePolicy::Expanding); + spacerItem = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); vboxLayout->addItem(spacerItem); @@ -166,7 +166,7 @@ public: hboxLayout->setContentsMargins(1, 1, 1, 1); hboxLayout->setObjectName(QStringLiteral("hboxLayout")); hboxLayout->setObjectName(QStringLiteral("")); - spacerItem1 = new QSpacerItem(QSizePolicy::Expanding, QSizePolicy::Minimum); + spacerItem1 = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum); hboxLayout->addItem(spacerItem1); diff --git a/tests/auto/tools/uic/baseline/newdynamicpropertydialog.ui.h b/tests/auto/tools/uic/baseline/newdynamicpropertydialog.ui.h index ca7bd253a8..3c4e0ba09e 100644 --- a/tests/auto/tools/uic/baseline/newdynamicpropertydialog.ui.h +++ b/tests/auto/tools/uic/baseline/newdynamicpropertydialog.ui.h @@ -91,7 +91,7 @@ public: verticalLayout->addLayout(formLayout); - spacerItem = new QSpacerItem(QSizePolicy::Minimum, QSizePolicy::Expanding); + spacerItem = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); verticalLayout->addItem(spacerItem); diff --git a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp index 8253a44b21..4e30b75dc5 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp @@ -397,6 +397,7 @@ void tst_QGraphicsProxyWidget::setWidget() QGraphicsScene scene; QGraphicsView view(&scene); view.show(); + QScopedPointer<QStyle> style(QStyleFactory::create(QLatin1String("Fusion"))); QVERIFY(QTest::qWaitForWindowExposed(&view)); QPointer<SubQGraphicsProxyWidget> proxy = new SubQGraphicsProxyWidget; SubQGraphicsProxyWidget parentProxy; @@ -419,7 +420,7 @@ void tst_QGraphicsProxyWidget::setWidget() #endif widget->setPalette(QPalette(Qt::magenta)); widget->setLayoutDirection(Qt::RightToLeft); - widget->setStyle(QStyleFactory::create(QLatin1String("Fusion"))); + widget->setStyle(style.data()); widget->setFont(QFont("Times")); widget->setVisible(true); QApplication::setActiveWindow(widget); diff --git a/tests/benchmarks/gui/painting/painting.pro b/tests/benchmarks/gui/painting/painting.pro index 0eb7fa92a7..cdcfc9b318 100644 --- a/tests/benchmarks/gui/painting/painting.pro +++ b/tests/benchmarks/gui/painting/painting.pro @@ -1,5 +1,6 @@ TEMPLATE = subdirs SUBDIRS = \ + qcolor \ qpainter \ qregion \ qtransform \ diff --git a/tests/benchmarks/gui/painting/qcolor/qcolor.pro b/tests/benchmarks/gui/painting/qcolor/qcolor.pro new file mode 100644 index 0000000000..5ceb702323 --- /dev/null +++ b/tests/benchmarks/gui/painting/qcolor/qcolor.pro @@ -0,0 +1,7 @@ +QT += testlib +QT += gui-private + +TEMPLATE = app +TARGET = tst_bench_qcolor + +SOURCES += tst_qcolor.cpp diff --git a/tests/benchmarks/gui/painting/qcolor/tst_qcolor.cpp b/tests/benchmarks/gui/painting/qcolor/tst_qcolor.cpp new file mode 100644 index 0000000000..b67fa450d7 --- /dev/null +++ b/tests/benchmarks/gui/painting/qcolor/tst_qcolor.cpp @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author David Faure <david.faure@kdab.com> +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite 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$ +** +****************************************************************************/ + +#include <qtest.h> +#include <QColor> + + +class tst_QColor : public QObject +{ + Q_OBJECT + +private slots: + void nameRgb(); + void nameArgb(); +}; + +void tst_QColor::nameRgb() +{ + QColor color(128, 255, 10); + QCOMPARE(color.name(), QStringLiteral("#80ff0a")); + QBENCHMARK { + color.name(); + } +} + +void tst_QColor::nameArgb() +{ + QColor color(128, 255, 0, 102); + QCOMPARE(color.name(QColor::HexArgb), QStringLiteral("#6680ff00")); + QBENCHMARK { + color.name(QColor::HexArgb); + } +} + +QTEST_MAIN(tst_QColor) + +#include "tst_qcolor.moc" |