From a9613ba3f16cd960e222a37d83ba4cbb6810a6d8 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 5 Jul 2016 09:31:44 +0200 Subject: [PATCH 01/51] Testlib: generate_expected_output.py: Run in C locale Otherwise, float numbers are formatted using a decimal comma in German, causing huge diffs and failures. Change-Id: Icd85a293d0564cac6be244eb0793611920d0c89c Reviewed-by: Edward Welbourne --- tests/auto/testlib/selftests/generate_expected_output.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/auto/testlib/selftests/generate_expected_output.py b/tests/auto/testlib/selftests/generate_expected_output.py index 83c617fee5..b917dacc78 100755 --- a/tests/auto/testlib/selftests/generate_expected_output.py +++ b/tests/auto/testlib/selftests/generate_expected_output.py @@ -109,6 +109,7 @@ if isWindows: exit() tests = sys.argv[1:] +os.environ['LC_ALL'] = 'C' if len(tests) == 0: tests = subdirs() print("Generating " + str(len(tests)) + " test results for: " + qtver + " in: " + rootPath) From 8f85e82c5dc3d3028828e11ff59b16e3cae2844d Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Mon, 4 Jul 2016 08:07:42 +0200 Subject: [PATCH 02/51] Windows: Handle theme switching correctly if a palette is set If a palette is set on the application object and the user does something to trigger a theme change, i.e. connects via remote desktop or logs out and in again, then it will cause Qt to render incorrectly. Therefore we should only update the palette from the new theme if we don't have our own already set. Task-number: QTBUG-52962 Change-Id: I4e2288efd82ad98b698cc09f26ad188064ec7b2a Reviewed-by: Giuseppe D'Angelo Reviewed-by: Friedemann Kleint --- src/gui/kernel/qguiapplication.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 834449fec6..dec701a17d 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -3567,7 +3567,8 @@ QPixmap QGuiApplicationPrivate::getPixmapCursor(Qt::CursorShape cshape) void QGuiApplicationPrivate::notifyThemeChanged() { - if (!(applicationResourceFlags & ApplicationPaletteExplicitlySet)) { + if (!(applicationResourceFlags & ApplicationPaletteExplicitlySet) && + !QCoreApplication::testAttribute(Qt::AA_SetPalette)) { clearPalette(); initPalette(); } From 3cc2884c031e0ab1098f59fae9aa6e05f54d36f8 Mon Sep 17 00:00:00 2001 From: Olivier Blin Date: Mon, 30 May 2016 11:16:19 +0200 Subject: [PATCH 03/51] Fix defining QGuiApplication::sync() when QT_NO_SESSIONMANAGER is set sync() is unconditionally declared in the QGuiApplication header, but the definition was under QT_NO_SESSIONMANAGER guards. This commit moves the definition of sync() outside of the QT_NO_SESSIONMANAGER guards, since the sync code has nothing to do with session management. [ChangeLog][QtGui][QGuiApplication] Fixed a bug that would cause QGuiApplication::sync() to be left undefined for Qt builds without session management support. Change-Id: Ieb46f7c90c9193e89469126170117d9df672f4cb Task-number: QTBUG-51703 Reviewed-by: Thiago Macieira --- src/gui/kernel/qguiapplication.cpp | 44 +++++++++++++++--------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index dec701a17d..7b05ee562b 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -3275,28 +3275,6 @@ bool QGuiApplication::isSavingSession() const return d->is_saving_session; } -/*! - \since 5.2 - - Function that can be used to sync Qt state with the Window Systems state. - - This function will first empty Qts events by calling QCoreApplication::processEvents(), - then the platform plugin will sync up with the windowsystem, and finally Qts events - will be delived by another call to QCoreApplication::processEvents(); - - This function is timeconsuming and its use is discouraged. -*/ -void QGuiApplication::sync() -{ - QCoreApplication::processEvents(); - if (QGuiApplicationPrivate::platform_integration - && QGuiApplicationPrivate::platform_integration->hasCapability(QPlatformIntegration::SyncState)) { - QGuiApplicationPrivate::platform_integration->sync(); - QCoreApplication::processEvents(); - QWindowSystemInterface::flushWindowSystemEvents(); - } -} - void QGuiApplicationPrivate::commitData() { Q_Q(QGuiApplication); @@ -3321,6 +3299,28 @@ void QGuiApplicationPrivate::saveState() } #endif //QT_NO_SESSIONMANAGER +/*! + \since 5.2 + + Function that can be used to sync Qt state with the Window Systems state. + + This function will first empty Qts events by calling QCoreApplication::processEvents(), + then the platform plugin will sync up with the windowsystem, and finally Qts events + will be delived by another call to QCoreApplication::processEvents(); + + This function is timeconsuming and its use is discouraged. +*/ +void QGuiApplication::sync() +{ + QCoreApplication::processEvents(); + if (QGuiApplicationPrivate::platform_integration + && QGuiApplicationPrivate::platform_integration->hasCapability(QPlatformIntegration::SyncState)) { + QGuiApplicationPrivate::platform_integration->sync(); + QCoreApplication::processEvents(); + QWindowSystemInterface::flushWindowSystemEvents(); + } +} + /*! \property QGuiApplication::layoutDirection \brief the default layout direction for this application From 4927fdb389b9fbc0d5118437274d4fa3c59fc839 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 5 Jul 2016 15:13:44 +0200 Subject: [PATCH 04/51] Fix misleading code in QAbstractSpinBox::event() A static_cast never returns nullptr unless its argument already was nullptr. But we dereferenced 'event' already by the time we reach this code, so the if is always true. Fix by removing the temporary variable. Change-Id: Ia869d37eda74f0bcdd616e1f57f429cc86e9e525 Reviewed-by: Friedemann Kleint --- src/widgets/widgets/qabstractspinbox.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/widgets/widgets/qabstractspinbox.cpp b/src/widgets/widgets/qabstractspinbox.cpp index ba4bbe40a8..854befd265 100644 --- a/src/widgets/widgets/qabstractspinbox.cpp +++ b/src/widgets/widgets/qabstractspinbox.cpp @@ -751,8 +751,7 @@ bool QAbstractSpinBox::event(QEvent *event) case QEvent::HoverEnter: case QEvent::HoverLeave: case QEvent::HoverMove: - if (const QHoverEvent *he = static_cast(event)) - d->updateHoverControl(he->pos()); + d->updateHoverControl(static_cast(event)->pos()); break; case QEvent::ShortcutOverride: if (d->edit->event(event)) From a91d0dd369313dfa8865f99e590b868146cb4388 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 5 Jul 2016 15:11:43 +0200 Subject: [PATCH 05/51] Q_(U)INT64_C is not a type, so don't use it as if it was These expressions only work because they contain no non-parenthesized commas and an int literal is last. Fix by wrapping only the integer literal in Q_(U)INT64_C. Change-Id: I6b8e508b6c7c022f4b3342f65c26aab89ce17702 Reviewed-by: Thiago Macieira --- src/network/kernel/qauthenticator.cpp | 4 ++-- tests/auto/corelib/tools/qringbuffer/tst_qringbuffer.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/network/kernel/qauthenticator.cpp b/src/network/kernel/qauthenticator.cpp index 92d8779cab..1b9c0de6e1 100644 --- a/src/network/kernel/qauthenticator.cpp +++ b/src/network/kernel/qauthenticator.cpp @@ -1272,10 +1272,10 @@ static QByteArray qEncodeNtlmv2Response(const QAuthenticatorPrivate *ctx, // 369 years, 89 leap years // ((369 * 365) + 89) * 24 * 3600 = 11644473600 - time = Q_UINT64_C(currentTime.toTime_t() + 11644473600); + time = currentTime.toTime_t() + Q_UINT64_C(11644473600); // represented as 100 nano seconds - time = Q_UINT64_C(time * 10000000); + time = time * Q_UINT64_C(10000000); ds << time; } diff --git a/tests/auto/corelib/tools/qringbuffer/tst_qringbuffer.cpp b/tests/auto/corelib/tools/qringbuffer/tst_qringbuffer.cpp index 77fc6ad6ae..c978761266 100644 --- a/tests/auto/corelib/tools/qringbuffer/tst_qringbuffer.cpp +++ b/tests/auto/corelib/tools/qringbuffer/tst_qringbuffer.cpp @@ -189,9 +189,9 @@ void tst_QRingBuffer::free() ringBuffer.append(QByteArray("01234", 5)); ringBuffer.free(1); - QCOMPARE(ringBuffer.size(), Q_INT64_C(4095 + 2048 + 5)); + QCOMPARE(ringBuffer.size(), Q_INT64_C(4095) + 2048 + 5); ringBuffer.free(4096); - QCOMPARE(ringBuffer.size(), Q_INT64_C(2047 + 5)); + QCOMPARE(ringBuffer.size(), Q_INT64_C(2047) + 5); ringBuffer.free(48); ringBuffer.free(2000); QCOMPARE(ringBuffer.size(), Q_INT64_C(4)); @@ -251,9 +251,9 @@ void tst_QRingBuffer::chop() ringBuffer.reserve(4096); ringBuffer.chop(1); - QCOMPARE(ringBuffer.size(), Q_INT64_C(5 + 2048 + 4095)); + QCOMPARE(ringBuffer.size(), Q_INT64_C(5) + 2048 + 4095); ringBuffer.chop(4096); - QCOMPARE(ringBuffer.size(), Q_INT64_C(5 + 2047)); + QCOMPARE(ringBuffer.size(), Q_INT64_C(5) + 2047); ringBuffer.chop(48); ringBuffer.chop(2000); QCOMPARE(ringBuffer.size(), Q_INT64_C(4)); From 631b143b3f6650b5761ac2c78e7936e1594b6e4f Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 1 Jul 2016 17:28:37 +0200 Subject: [PATCH 06/51] QComboBox: fix crash on setEditable(false) called from editTextChanged() QLineEdit::setText() emits QLineEdit::textChanged(), which is connected to QComboBox::editTextChanged(). When a user slot connected to editTextChanged() sets QComboBox::editable to false, the line edit will be deleted in setEditable() and when control returns to QComboBoxPrivate::setCurrentIndex(), the formerly non-null 'lineEdit' has changed to nullptr, leading to a nullptr dereference when attempting to set the completionPrefix on lineEdit->completer(). Fix by re-checking 'lineEdit' after returning from the QLineEdit::setText() call. Add a test. Task-number: QTBUG-54191 Change-Id: I94154796cfde73fb490f8471c48b9d6f62825a92 Reviewed-by: Friedemann Kleint --- src/widgets/widgets/qcombobox.cpp | 4 +-- .../widgets/qcombobox/tst_qcombobox.cpp | 25 +++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index 2abcd4d3c2..181671c493 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -2100,9 +2100,9 @@ void QComboBoxPrivate::setCurrentIndex(const QModelIndex &mi) if (lineEdit) { const QString newText = itemText(normalized); if (lineEdit->text() != newText) { - lineEdit->setText(newText); + lineEdit->setText(newText); // may cause lineEdit -> nullptr (QTBUG-54191) #ifndef QT_NO_COMPLETER - if (lineEdit->completer()) + if (lineEdit && lineEdit->completer()) lineEdit->completer()->setCompletionPrefix(newText); #endif } diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp index ae516639a6..15bf686699 100644 --- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp @@ -161,6 +161,7 @@ private slots: void itemData(); void task_QTBUG_31146_popupCompletion(); void task_QTBUG_41288_completerChangesCurrentIndex(); + void task_QTBUG_54191_slotOnEditTextChangedSetsComboBoxToReadOnly(); void keyboardSelection(); void setCustomModelAndView(); void updateDelegateOnEditableChange(); @@ -3124,6 +3125,30 @@ void tst_QComboBox::task_QTBUG_41288_completerChangesCurrentIndex() } } +namespace { + struct SetReadOnly { + QComboBox *cb; + explicit SetReadOnly(QComboBox *cb) : cb(cb) {} + void operator()() const + { cb->setEditable(false); } + }; +} + +void tst_QComboBox::task_QTBUG_54191_slotOnEditTextChangedSetsComboBoxToReadOnly() +{ + QComboBox cb; + cb.addItems(QStringList() << "one" << "two"); + cb.setEditable(true); + cb.setCurrentIndex(0); + + connect(&cb, &QComboBox::editTextChanged, + SetReadOnly(&cb)); + + cb.setCurrentIndex(1); + // the real test is that it didn't crash... + QCOMPARE(cb.currentIndex(), 1); +} + void tst_QComboBox::keyboardSelection() { QComboBox comboBox; From 9d620483c6b9ac0ba15bb3c8ea2482a09202f1a1 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Wed, 29 Jun 2016 16:36:17 -0700 Subject: [PATCH 07/51] QCocoaTheme: Remove unreachable code The condition iconType != kGenericApplicationIcon is never false, therefore we will never execute the else statement. Consequently, overlyaIcon will always be null. This was triggered by the deprecation of ProcessSerialNumber related APIs since 10.9. Change-Id: If9eec1d2cc6e7e5b0c5323d4550f0c823a5eb0d8 Reviewed-by: Jake Petroules --- src/plugins/platforms/cocoa/qcocoatheme.mm | 24 ++-------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoatheme.mm b/src/plugins/platforms/cocoa/qcocoatheme.mm index 4b73d0af08..5c41c896b7 100644 --- a/src/plugins/platforms/cocoa/qcocoatheme.mm +++ b/src/plugins/platforms/cocoa/qcocoatheme.mm @@ -214,34 +214,14 @@ QPixmap QCocoaTheme::standardPixmap(StandardPixmap sp, const QSizeF &size) const } if (iconType != 0) { QPixmap pixmap; - IconRef icon; - IconRef overlayIcon = 0; - if (iconType != kGenericApplicationIcon) { - GetIconRef(kOnSystemDisk, kSystemIconsCreator, iconType, &icon); - } else { - FSRef fsRef; - ProcessSerialNumber psn = { 0, kCurrentProcess }; - GetProcessBundleLocation(&psn, &fsRef); - GetIconRefFromFileInfo(&fsRef, 0, 0, 0, 0, kIconServicesNormalUsageFlag, &icon, 0); - if (sp == MessageBoxCritical) { - overlayIcon = icon; - GetIconRef(kOnSystemDisk, kSystemIconsCreator, kAlertCautionIcon, &icon); - } - } + IconRef icon = Q_NULLPTR; + GetIconRef(kOnSystemDisk, kSystemIconsCreator, iconType, &icon); if (icon) { pixmap = qt_mac_convert_iconref(icon, size.width(), size.height()); ReleaseIconRef(icon); } - if (overlayIcon) { - QSizeF littleSize = size / 2; - QPixmap overlayPix = qt_mac_convert_iconref(overlayIcon, littleSize.width(), littleSize.height()); - QPainter painter(&pixmap); - painter.drawPixmap(littleSize.width(), littleSize.height(), overlayPix); - ReleaseIconRef(overlayIcon); - } - return pixmap; } From 16fefc258ec022b0c6828c70741c2c8c43a01f12 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Thu, 30 Jun 2016 16:21:59 -0700 Subject: [PATCH 08/51] Remove QCoreTextFontEngine::supportsColorGlyphs This is always true on the versions we currently support. Change-Id: I1aecbbd1f41e0f4f03b380358cd762ca00bb1e97 Reviewed-by: Jake Petroules Reviewed-by: Konstantin Ritt --- .../fontdatabases/mac/qcoretextfontdatabase.mm | 3 +-- .../fontdatabases/mac/qfontengine_coretext.mm | 9 ++------- .../fontdatabases/mac/qfontengine_coretext_p.h | 15 --------------- 3 files changed, 3 insertions(+), 24 deletions(-) diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm index 0b9e7a7fe0..566abf2126 100644 --- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm +++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm @@ -588,8 +588,7 @@ QStringList QCoreTextFontDatabase::fallbacksForFamily(const QString &family, QFo fallbackList.append(familyNameFromPostScriptName(item)); } - if (QCoreTextFontEngine::supportsColorGlyphs()) - fallbackList.append(QLatin1String("Apple Color Emoji")); + fallbackList.append(QLatin1String("Apple Color Emoji")); // Since we are only returning a list of default fonts for the current language, we do not // cover all unicode completely. This was especially an issue for some of the common script diff --git a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm index 703ec3a8b8..7b459584ea 100644 --- a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm +++ b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm @@ -218,11 +218,9 @@ void QCoreTextFontEngine::init() synthesisFlags = 0; CTFontSymbolicTraits traits = CTFontGetSymbolicTraits(ctfont); -#if defined(Q_OS_IOS) || MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 - if (supportsColorGlyphs() && (traits & kCTFontColorGlyphsTrait)) + if (traits & kCTFontColorGlyphsTrait) glyphFormat = QFontEngine::Format_ARGB; else -#endif glyphFormat = defaultGlyphFormat; if (traits & kCTFontItalicTrait) @@ -648,9 +646,7 @@ QImage QCoreTextFontEngine::imageForGlyph(glyph_t glyph, QFixed subPixelPosition CGContextSetTextPosition(ctx, pos_x + 0.5 * lineThickness().toReal(), pos_y); CGContextShowGlyphsWithAdvances(ctx, &cgGlyph, &CGSizeZero, 1); } - } -#if defined(Q_OS_IOS) || MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 - else if (supportsColorGlyphs()) { + } else { // CGContextSetTextMatrix does not work with color glyphs, so we use // the CTM instead. This means we must translate the CTM as well, to // set the glyph position, instead of using CGContextSetTextPosition. @@ -661,7 +657,6 @@ QImage QCoreTextFontEngine::imageForGlyph(glyph_t glyph, QFixed subPixelPosition // glyphs in the Apple Color Emoji font, so we use CTFontDrawGlyphs instead. CTFontDrawGlyphs(ctfont, &cgGlyph, &CGPointZero, 1, ctx); } -#endif CGContextRelease(ctx); CGColorSpaceRelease(colorspace); diff --git a/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h b/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h index 746c9051a0..0cfa6ed6d3 100644 --- a/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h +++ b/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h @@ -106,21 +106,6 @@ public: QFontEngine::Properties properties() const Q_DECL_OVERRIDE; - static bool supportsColorGlyphs() - { -#if defined(Q_OS_IOS) - return true; -#elif MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 - #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 - return &CTFontDrawGlyphs; - #else - return true; - #endif -#else - return false; -#endif - } - static bool ct_getSfntTable(void *user_data, uint tag, uchar *buffer, uint *length); static QFont::Weight qtWeightFromCFWeight(float value); From 1575f2fc3cf74035716f2dc0c31442d77f136561 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 10 Jun 2016 11:03:44 -0700 Subject: [PATCH 09/51] XCB: Update the high DPI scaling in more conditions I don't think fae8ee8b428ae7a406199e504b2d0eedd5059dbd was enough. I've started getting small fonts in Qt Creator under some other circumstances. Change-Id: I1cc7601489634e96833cfffd1456caea823aa84a Reviewed-by: Shawn Rutledge --- src/plugins/platforms/xcb/qxcbconnection.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index b5c5028995..29a2cfb57a 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -258,8 +258,8 @@ void QXcbConnection::updateScreens(const xcb_randr_notify_event_t *event) } else { screen = createScreen(virtualDesktop, output, outputInfo.data()); qCDebug(lcQpaScreen) << "output" << screen->name() << "is connected and enabled"; - QHighDpiScaling::updateHighDpiScaling(); } + QHighDpiScaling::updateHighDpiScaling(); } } else if (screen) { if (output.crtc == XCB_NONE && output.mode == XCB_NONE) { From abc29084fadf9c7d936fca55d02323090d9986cc Mon Sep 17 00:00:00 2001 From: Roger Maclean Date: Wed, 29 Oct 2014 11:06:20 -0400 Subject: [PATCH 10/51] QNX: Ensure invisible 1x1 raster windows are posted. Non-top level raster windows still have screen windows associated with them though they are not intended to be visible. This causes problems if they have children (as they do when QGLWidgets are used) since their children will also not be visible. So, if we have a window with a parent, force them to post but set the transparency to discard so they remain invisible. This allows the example hellogl_es2 to run correctly. Change-Id: I67e24dc59b29ce789376498c2477349fa50020e1 Reviewed-by: Rafael Roquetto --- src/plugins/platforms/qnx/qqnxrasterwindow.cpp | 9 ++++++++- src/plugins/platforms/qnx/qqnxwindow.cpp | 7 ++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/qnx/qqnxrasterwindow.cpp b/src/plugins/platforms/qnx/qqnxrasterwindow.cpp index 933fce0e33..a764bba00e 100644 --- a/src/plugins/platforms/qnx/qqnxrasterwindow.cpp +++ b/src/plugins/platforms/qnx/qqnxrasterwindow.cpp @@ -172,7 +172,7 @@ void QQnxRasterWindow::adjustBufferSize() { // When having a raster window we don't need any buffers, since // Qt will draw to the parent TLW backing store. - const QSize windowSize = window()->parent() ? QSize(1,1) : window()->size(); + const QSize windowSize = window()->parent() ? QSize(0,0) : window()->size(); if (windowSize != bufferSize()) setBufferSize(windowSize); } @@ -188,6 +188,13 @@ void QQnxRasterWindow::resetBuffers() m_currentBufferIndex = -1; m_previousDirty = QRegion(); m_scrolled = QRegion(); + if (window()->parent() && bufferSize() == QSize(1,1)) { + // If we have a parent then we're not really rendering. But if we don't render we'll + // be invisible and any children won't show up. This should be harmless since we're + // rendering into a 1x1 window that has transparency set to discard. + renderBuffer(); + post(QRegion(0,0,1,1)); + } } void QQnxRasterWindow::blitPreviousToCurrent(const QRegion ®ion, int dx, int dy, bool flush) diff --git a/src/plugins/platforms/qnx/qqnxwindow.cpp b/src/plugins/platforms/qnx/qqnxwindow.cpp index 4dc1248bd1..da2929d4c0 100644 --- a/src/plugins/platforms/qnx/qqnxwindow.cpp +++ b/src/plugins/platforms/qnx/qqnxwindow.cpp @@ -386,7 +386,12 @@ void QQnxWindow::setBufferSize(const QSize &size) // Set the transparency. According to QNX technical support, setting the window // transparency property should always be done *after* creating the window // buffers in order to guarantee the property is paid attention to. - if (window()->requestedFormat().alphaBufferSize() == 0) { + if (size.isEmpty()) { + // We can't create 0x0 buffers and instead make them 1x1. But to allow these windows to + // still be 'visible' (thus allowing their children to be visible), we need to allow + // them to be posted but still not show up. + val[0] = SCREEN_TRANSPARENCY_DISCARD; + } else if (window()->requestedFormat().alphaBufferSize() == 0) { // To avoid overhead in the composition manager, disable blending // when the underlying window buffer doesn't have an alpha channel. val[0] = SCREEN_TRANSPARENCY_NONE; From 3658354a7de9615bdf03b49736fea3ec41cecd77 Mon Sep 17 00:00:00 2001 From: Ralf Nolden Date: Sat, 2 Jul 2016 13:48:45 +0200 Subject: [PATCH 11/51] OpenBSD: redefine g++/gcc commands to eg++/egcc to use newer gcc 4.9 On OpenBSD, the system compiler shipped is still gcc 4.2.1 but for proper C++11 support in Qt, QtCreator and Qt-based projects we need to use the compilers provided in ports/packages which have the binaries renamed to eg++/egcc. Therefore, redefine the variables from g++-base.conf to use the newer compilers. Change-Id: Ic8ea1c5d2c2c0263dad5ae85c8c747bcd3985b7d Reviewed-by: Oswald Buddenhagen --- mkspecs/openbsd-g++/qmake.conf | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/mkspecs/openbsd-g++/qmake.conf b/mkspecs/openbsd-g++/qmake.conf index e7ac523486..4232759997 100644 --- a/mkspecs/openbsd-g++/qmake.conf +++ b/mkspecs/openbsd-g++/qmake.conf @@ -20,6 +20,21 @@ QMAKE_LIBDIR_OPENGL = /usr/X11R6/lib include(../common/gcc-base-unix.conf) include(../common/g++-unix.conf) +# System compiler is gcc 4.2.1 up to OpenBSD 6.0. +# For proper C++11 support, we need to use a newer gcc from ports/packages, +# where compiler commands are renamed to egcc/eg++. Therefore, redefine +# mkspecs/common/g++-base.conf compiler commands +QMAKE_CC = egcc + +QMAKE_LINK_C = $$QMAKE_CC +QMAKE_LINK_C_SHLIB = $$QMAKE_CC + +QMAKE_CXX = eg++ + +QMAKE_LINK = $$QMAKE_CXX +QMAKE_LINK_SHLIB = $$QMAKE_CXX + + # Reset g++-unix.conf's NOUNDEF flags as OpenBSD libc can't handle environ QMAKE_LFLAGS_NOUNDEF = From b6c10cf33107309f13c9845495d9d7d4f45f34bf Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Mon, 4 Jul 2016 15:21:19 +0200 Subject: [PATCH 12/51] Improve lookup speed for QAccessible::uniqueId When QAccessible::uniqueId was called, it would call QHash::key(), which has linear time performance. This can cause application slowdown if a big number of QAccessibleInterface Ids have to be found. The patch adds an additional QHash to keep track of the inverse relationship from QAccessibleInterface pointers to their Ids. Change-Id: I975e3dc0e6c628e2ea701323d8b87184ad133cfb Task-number: QTBUG-54491 Reviewed-by: Allan Sandfeld Jensen Reviewed-by: Frederik Gladhorn --- src/gui/accessible/qaccessible.cpp | 4 ++-- src/gui/accessible/qaccessiblecache.cpp | 9 ++++++++- src/gui/accessible/qaccessiblecache_p.h | 2 ++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/gui/accessible/qaccessible.cpp b/src/gui/accessible/qaccessible.cpp index 4731e8a240..658e0f26ba 100644 --- a/src/gui/accessible/qaccessible.cpp +++ b/src/gui/accessible/qaccessible.cpp @@ -755,7 +755,7 @@ void QAccessible::deleteAccessibleInterface(Id id) */ QAccessible::Id QAccessible::uniqueId(QAccessibleInterface *iface) { - Id id = QAccessibleCache::instance()->idToInterface.key(iface); + Id id = QAccessibleCache::instance()->idForInterface(iface); if (!id) id = registerAccessibleInterface(iface); return id; @@ -768,7 +768,7 @@ QAccessible::Id QAccessible::uniqueId(QAccessibleInterface *iface) */ QAccessibleInterface *QAccessible::accessibleInterface(Id id) { - return QAccessibleCache::instance()->idToInterface.value(id); + return QAccessibleCache::instance()->interfaceForId(id); } diff --git a/src/gui/accessible/qaccessiblecache.cpp b/src/gui/accessible/qaccessiblecache.cpp index 0b9366631c..5fae442370 100644 --- a/src/gui/accessible/qaccessiblecache.cpp +++ b/src/gui/accessible/qaccessiblecache.cpp @@ -77,6 +77,11 @@ QAccessibleInterface *QAccessibleCache::interfaceForId(QAccessible::Id id) const return idToInterface.value(id); } +QAccessible::Id QAccessibleCache::idForInterface(QAccessibleInterface *iface) const +{ + return interfaceToId.value(iface); +} + QAccessible::Id QAccessibleCache::insert(QObject *object, QAccessibleInterface *iface) const { Q_ASSERT(iface); @@ -84,7 +89,7 @@ QAccessible::Id QAccessibleCache::insert(QObject *object, QAccessibleInterface * // object might be 0 Q_ASSERT(!objectToId.contains(object)); - Q_ASSERT_X(!idToInterface.values().contains(iface), "", "Accessible interface inserted into cache twice!"); + Q_ASSERT_X(!interfaceToId.contains(iface), "", "Accessible interface inserted into cache twice!"); QAccessible::Id id = acquireId(); QObject *obj = iface->object(); @@ -94,6 +99,7 @@ QAccessible::Id QAccessibleCache::insert(QObject *object, QAccessibleInterface * connect(obj, &QObject::destroyed, this, &QAccessibleCache::objectDestroyed); } idToInterface.insert(id, iface); + interfaceToId.insert(iface, id); return id; } @@ -109,6 +115,7 @@ void QAccessibleCache::objectDestroyed(QObject* obj) void QAccessibleCache::deleteInterface(QAccessible::Id id, QObject *obj) { QAccessibleInterface *iface = idToInterface.take(id); + interfaceToId.take(iface); if (!obj) obj = iface->object(); if (obj) diff --git a/src/gui/accessible/qaccessiblecache_p.h b/src/gui/accessible/qaccessiblecache_p.h index ffaccbca42..bb33ea2cd4 100644 --- a/src/gui/accessible/qaccessiblecache_p.h +++ b/src/gui/accessible/qaccessiblecache_p.h @@ -64,6 +64,7 @@ class Q_GUI_EXPORT QAccessibleCache :public QObject public: static QAccessibleCache *instance(); QAccessibleInterface *interfaceForId(QAccessible::Id id) const; + QAccessible::Id idForInterface(QAccessibleInterface *iface) const; QAccessible::Id insert(QObject *object, QAccessibleInterface *iface) const; void deleteInterface(QAccessible::Id id, QObject *obj = 0); @@ -79,6 +80,7 @@ private: QAccessible::Id acquireId() const; mutable QHash idToInterface; + mutable QHash interfaceToId; mutable QHash objectToId; #ifdef Q_OS_MAC From b36c6bab8db724a59f69e5205e031cccf4520ab7 Mon Sep 17 00:00:00 2001 From: Anton Kudryavtsev Date: Thu, 7 Jul 2016 14:36:38 +0300 Subject: [PATCH 13/51] QString: add auto test for chop() Change-Id: I8fc65c65776a64cc92e8cba3993d17746be81ba1 Reviewed-by: Edward Welbourne --- .../corelib/tools/qstring/tst_qstring.cpp | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp index a922e3ad27..601987086d 100644 --- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp @@ -482,6 +482,7 @@ private slots: void sprintf(); void fill(); void truncate(); + void chop(); void constructor(); void constructorQByteArray_data(); void constructorQByteArray(); @@ -1221,6 +1222,31 @@ void tst_QString::truncate() } +void tst_QString::chop() +{ + const QString original("abcd"); + + QString str = original; + str.chop(1); + QCOMPARE(str, QLatin1String("abc")); + + str = original; + str.chop(0); + QCOMPARE(str, original); + + str = original; + str.chop(-1); + QCOMPARE(str, original); + + str = original; + str.chop(original.size()); + QVERIFY(str.isEmpty()); + + str = original; + str.chop(1000); + QVERIFY(str.isEmpty()); +} + void tst_QString::fill() { QString e; From c8aa7eda3abfba9004eb70db571c7c537494b7f0 Mon Sep 17 00:00:00 2001 From: Boris Pek Date: Sun, 19 Jun 2016 03:15:43 +0300 Subject: [PATCH 14/51] Fix build of the minimal platform plugin for MS Windows when qtbase is configured with -fontconfig and -system-freetype. This fix is necessary after 060e0f6628fd185994911307c59f5355acaaf18f. Used the same approach as in 16864c42d6bc0ee6b3e3fa03123ef5884557ceea. Change-Id: Idece0dc11d89e38266c95de1769be751c06324ef Reviewed-by: Friedemann Kleint --- src/plugins/platforms/minimal/minimal.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/platforms/minimal/minimal.pro b/src/plugins/platforms/minimal/minimal.pro index bd6f2d8e6f..3aca27b555 100644 --- a/src/plugins/platforms/minimal/minimal.pro +++ b/src/plugins/platforms/minimal/minimal.pro @@ -11,7 +11,7 @@ HEADERS = qminimalintegration.h \ OTHER_FILES += minimal.json CONFIG += qpa/genericunixfontdatabase -darwin: DEFINES += QT_NO_FONTCONFIG +win32|darwin: DEFINES += QT_NO_FONTCONFIG PLUGIN_TYPE = platforms PLUGIN_CLASS_NAME = QMinimalIntegrationPlugin From 14c6f80f4b2d8275037ed1fc3c63870e7f21570a Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 1 Jul 2016 16:18:41 +0200 Subject: [PATCH 15/51] Testlib: Replace QString::arg() formatting by snprintf() Formatting of values needs to be fast since QTestlib always pessimistically formats the values passed to QCOMPARE even if they match. Speeds up tst_qrect by factor 1.5..2. Task-number: QTBUG-38890 Change-Id: I3627db77a305a46c1d51a14c04b88db8018faa60 Reviewed-by: Edward Welbourne --- src/testlib/qtest.h | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/src/testlib/qtest.h b/src/testlib/qtest.h index 8da16af91e..a8cc02710e 100644 --- a/src/testlib/qtest.h +++ b/src/testlib/qtest.h @@ -101,37 +101,57 @@ template<> inline char *toString(const QDateTime &dateTime) template<> inline char *toString(const QChar &c) { + const ushort uc = c.unicode(); + if (uc < 128) { + char msg[32] = {'\0'}; + qsnprintf(msg, sizeof(msg), "QChar: '%c' (0x%x)", char(uc), unsigned(uc)); + return qstrdup(msg); + } return qstrdup(qPrintable(QString::fromLatin1("QChar: '%1' (0x%2)").arg(c).arg(QString::number(static_cast(c.unicode()), 16)))); } template<> inline char *toString(const QPoint &p) { - return qstrdup(QString::fromLatin1("QPoint(%1,%2)").arg(p.x()).arg(p.y()).toLatin1().constData()); + char msg[128] = {'\0'}; + qsnprintf(msg, sizeof(msg), "QPoint(%d,%d)", p.x(), p.y()); + return qstrdup(msg); } template<> inline char *toString(const QSize &s) { - return qstrdup(QString::fromLatin1("QSize(%1x%2)").arg(s.width()).arg(s.height()).toLatin1().constData()); + char msg[128] = {'\0'}; + qsnprintf(msg, sizeof(msg), "QSize(%dx%d)", s.width(), s.height()); + return qstrdup(msg); } template<> inline char *toString(const QRect &s) { - return qstrdup(QString::fromLatin1("QRect(%1,%2 %5x%6) (bottomright %3,%4)").arg(s.left()).arg(s.top()).arg(s.right()).arg(s.bottom()).arg(s.width()).arg(s.height()).toLatin1().constData()); + char msg[256] = {'\0'}; + qsnprintf(msg, sizeof(msg), "QRect(%d,%d %dx%d) (bottomright %d,%d)", + s.left(), s.top(), s.width(), s.height(), s.right(), s.bottom()); + return qstrdup(msg); } template<> inline char *toString(const QPointF &p) { - return qstrdup(QString::fromLatin1("QPointF(%1,%2)").arg(p.x()).arg(p.y()).toLatin1().constData()); + char msg[64] = {'\0'}; + qsnprintf(msg, sizeof(msg), "QPointF(%g,%g)", p.x(), p.y()); + return qstrdup(msg); } template<> inline char *toString(const QSizeF &s) { - return qstrdup(QString::fromLatin1("QSizeF(%1x%2)").arg(s.width()).arg(s.height()).toLatin1().constData()); + char msg[64] = {'\0'}; + qsnprintf(msg, sizeof(msg), "QSizeF(%gx%g)", s.width(), s.height()); + return qstrdup(msg); } template<> inline char *toString(const QRectF &s) { - return qstrdup(QString::fromLatin1("QRectF(%1,%2 %5x%6) (bottomright %3,%4)").arg(s.left()).arg(s.top()).arg(s.right()).arg(s.bottom()).arg(s.width()).arg(s.height()).toLatin1().constData()); + char msg[256] = {'\0'}; + qsnprintf(msg, sizeof(msg), "QRectF(%g,%g %gx%g) (bottomright %g,%g)", + s.left(), s.top(), s.width(), s.height(), s.right(), s.bottom()); + return qstrdup(msg); } template<> inline char *toString(const QUrl &uri) From deb2728a8677b275613668d1467b636ed1776282 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Thu, 7 Jul 2016 15:23:20 +0200 Subject: [PATCH 16/51] [macOS] Check that the screen's index is still valid after updating It is possible for a screen to be disconnected while it is doing an update of the available screens. Therefore before returning the pointer to the screen then it should be rechecked that the index is still within the range of available screens. Change-Id: Iaa08070e79a72cb309d8a24cea786a5dccf6b719 Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/cocoa/qcocoaintegration.mm | 4 ++++ src/plugins/platforms/cocoa/qnsview.mm | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index 933160b2ca..659c803a19 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -450,6 +450,10 @@ QCocoaScreen *QCocoaIntegration::screenAtIndex(int index) if (index >= mScreens.count()) updateScreens(); + // It is possible that the screen got removed while updateScreens was called + // so we do a sanity check to be certain + if (index >= mScreens.count()) + return 0; return mScreens.at(index); } diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 4e482fb146..913ce08d17 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -469,7 +469,8 @@ QT_WARNING_POP NSUInteger screenIndex = [[NSScreen screens] indexOfObject:self.window.screen]; if (screenIndex != NSNotFound) { QCocoaScreen *cocoaScreen = QCocoaIntegration::instance()->screenAtIndex(screenIndex); - QWindowSystemInterface::handleWindowScreenChanged(m_window, cocoaScreen->screen()); + if (cocoaScreen) + QWindowSystemInterface::handleWindowScreenChanged(m_window, cocoaScreen->screen()); m_platformWindow->updateExposedGeometry(); } } From 6bafb9da71044d99a95a591f7872b8b2fd97174a Mon Sep 17 00:00:00 2001 From: Anton Kudryavtsev Date: Thu, 7 Jul 2016 11:05:07 +0300 Subject: [PATCH 17/51] QString: fix incomplete doc of chop() Change-Id: I84de848681e793e68e0c290719a7f961aca48f4e Reviewed-by: Edward Welbourne Reviewed-by: Thiago Macieira --- 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 8eadc9330d..3d63a540dd 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -4978,7 +4978,7 @@ void QString::truncate(int pos) Removes \a n characters from the end of the string. If \a n is greater than or equal to size(), the result is an - empty string. + empty string; if \a n is negative, it is equivalent to passing zero. Example: \snippet qstring/main.cpp 15 From 38b09d34210805766afa8bdd6a1ef413447a89ed Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Thu, 7 Jul 2016 14:33:30 -0700 Subject: [PATCH 18/51] QCocoaMenu: Attach late items to their submenu Because the QMenu::aboutToShow() signal is emitted way after -[QCocoaMenuDelegate menu:updateItem: atIndex:shouldCancel:], we miss the opportunity to attach the submenu to the menu item. The solution is to track the "open" state of the NSMenu. Then, if any submenu item gets added while the NSMenu is open, then we immediately attach the native item to the menu. Change-Id: I1f3a84ed3832520344da07e06cb3483ad6bd4ffd Task-number: QTBUG-54633 Reviewed-by: Jake Petroules --- src/plugins/platforms/cocoa/qcocoamenu.h | 6 +++++- src/plugins/platforms/cocoa/qcocoamenu.mm | 17 ++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoamenu.h b/src/plugins/platforms/cocoa/qcocoamenu.h index c975de166d..98b0eb9c54 100644 --- a/src/plugins/platforms/cocoa/qcocoamenu.h +++ b/src/plugins/platforms/cocoa/qcocoamenu.h @@ -87,6 +87,9 @@ public: void setAttachedItem(NSMenuItem *item); NSMenuItem *attachedItem() const; + bool isOpen() const; + void setIsOpen(bool isOpen); + private: QCocoaMenuItem *itemOrNull(int index) const; void insertNative(QCocoaMenuItem *item, QCocoaMenuItem *beforeItem); @@ -94,9 +97,10 @@ private: QList m_menuItems; NSMenu *m_nativeMenu; NSMenuItem *m_attachedItem; + quintptr m_tag; bool m_enabled; bool m_visible; - quintptr m_tag; + bool m_isOpen; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoamenu.mm b/src/plugins/platforms/cocoa/qcocoamenu.mm index 878c96d33a..155abcc7ea 100644 --- a/src/plugins/platforms/cocoa/qcocoamenu.mm +++ b/src/plugins/platforms/cocoa/qcocoamenu.mm @@ -131,12 +131,14 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QCocoaMenuDelegate); - (void) menuWillOpen:(NSMenu*)m { Q_UNUSED(m); + m_menu->setIsOpen(true); emit m_menu->aboutToShow(); } - (void) menuDidClose:(NSMenu*)m { Q_UNUSED(m); + m_menu->setIsOpen(false); // wrong, but it's the best we can do emit m_menu->aboutToHide(); } @@ -251,9 +253,10 @@ QT_BEGIN_NAMESPACE QCocoaMenu::QCocoaMenu() : m_attachedItem(0), + m_tag(0), m_enabled(true), m_visible(true), - m_tag(0) + m_isOpen(false) { QMacAutoReleasePool pool; @@ -324,6 +327,8 @@ void QCocoaMenu::insertNative(QCocoaMenuItem *item, QCocoaMenuItem *beforeItem) item->nsItem().target = m_nativeMenu.delegate; if (!item->menu()) [item->nsItem() setAction:@selector(itemFired:)]; + else if (isOpen() && item->nsItem()) // Someone's adding new items after aboutToShow() was emitted + item->menu()->setAttachedItem(item->nsItem()); if (item->isMerged()) return; @@ -347,6 +352,16 @@ void QCocoaMenu::insertNative(QCocoaMenuItem *item, QCocoaMenuItem *beforeItem) item->setMenuParent(this); } +bool QCocoaMenu::isOpen() const +{ + return m_isOpen; +} + +void QCocoaMenu::setIsOpen(bool isOpen) +{ + m_isOpen = isOpen; +} + void QCocoaMenu::removeMenuItem(QPlatformMenuItem *menuItem) { QMacAutoReleasePool pool; From a0bb2fc4061a91edab8222158fd88454f40dab27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Martins?= Date: Fri, 24 Jun 2016 10:01:01 +0100 Subject: [PATCH 19/51] Fix typo in QStyle documentation Change-Id: Id1f65dcc473effbdd0ccd7362b2986382c827ed8 Reviewed-by: Martin Smith --- src/widgets/styles/qstyle.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widgets/styles/qstyle.cpp b/src/widgets/styles/qstyle.cpp index 97ed8eec3d..6a03d73c72 100644 --- a/src/widgets/styles/qstyle.cpp +++ b/src/widgets/styles/qstyle.cpp @@ -725,7 +725,7 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, \value State_None Indicates that the widget does not have a state. \value State_Active Indicates that the widget is active. - \value State_AutoRaise Used to indicate if auto-raise appearance should be usd on a tool button. + \value State_AutoRaise Used to indicate if auto-raise appearance should be used on a tool button. \value State_Children Used to indicate if an item view branch has children. \value State_DownArrow Used to indicate if a down arrow should be visible on the widget. \value State_Editing Used to indicate if an editor is opened on the widget. From e27c07389bcf8b6c5cc1c356a3ee1759045270a8 Mon Sep 17 00:00:00 2001 From: Anton Kudryavtsev Date: Fri, 8 Jul 2016 11:27:50 +0300 Subject: [PATCH 20/51] QString: adapt chop() auto test as data-driven test Thiago Macieira asked to do that. Change-Id: I9a07dad7ff2bfebc2f863e0e9f151aab66450bcf Reviewed-by: Edward Welbourne Reviewed-by: Thiago Macieira --- .../corelib/tools/qstring/tst_qstring.cpp | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp index 601987086d..3bacf5d942 100644 --- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp @@ -482,6 +482,7 @@ private slots: void sprintf(); void fill(); void truncate(); + void chop_data(); void chop(); void constructor(); void constructorQByteArray_data(); @@ -1222,29 +1223,29 @@ void tst_QString::truncate() } -void tst_QString::chop() +void tst_QString::chop_data() { + QTest::addColumn("input"); + QTest::addColumn("count" ); + QTest::addColumn("result"); + const QString original("abcd"); - QString str = original; - str.chop(1); - QCOMPARE(str, QLatin1String("abc")); + QTest::newRow("data0") << original << 1 << QString("abc"); + QTest::newRow("data1") << original << 0 << original; + QTest::newRow("data2") << original << -1 << original; + QTest::newRow("data3") << original << original.size() << QString(); + QTest::newRow("data4") << original << 1000 << QString(); +} - str = original; - str.chop(0); - QCOMPARE(str, original); +void tst_QString::chop() +{ + QFETCH(QString, input); + QFETCH(int, count); + QFETCH(QString, result); - str = original; - str.chop(-1); - QCOMPARE(str, original); - - str = original; - str.chop(original.size()); - QVERIFY(str.isEmpty()); - - str = original; - str.chop(1000); - QVERIFY(str.isEmpty()); + input.chop(count); + QCOMPARE(input, result); } void tst_QString::fill() From 8cee6864c6718449e3b5bedcd79173391ec188e7 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 8 Jul 2016 10:45:51 +0200 Subject: [PATCH 21/51] QStringBuilderCommon: drop const from resolved() result type The const qualification prevented toUpper() etc from calling the rvalue overloads of the corresponding QString functions. Since resolved() always returns a non-shared object, the rvalue overloads can re-use the object's capacity for storing their result, saving up to one memory allocation per QStringBuilderCommon::to*() invocation. Change-Id: Ica97fcd906cdd949ffe56055654578b93407e2d3 Reviewed-by: Thiago Macieira --- src/corelib/tools/qstringbuilder.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/tools/qstringbuilder.h b/src/corelib/tools/qstringbuilder.h index 69bd344f47..fdd1aa3478 100644 --- a/src/corelib/tools/qstringbuilder.h +++ b/src/corelib/tools/qstringbuilder.h @@ -76,7 +76,7 @@ struct QStringBuilderCommon T toLower() const { return resolved().toLower(); } protected: - const T resolved() const { return *static_cast(this); } + T resolved() const { return *static_cast(this); } }; template From f8dc769655959b290d70a2e66e2c3a625aa813cd Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Mon, 27 Jun 2016 14:30:59 +0200 Subject: [PATCH 22/51] QMacTimeZonePrivate - correctly initialize m_nstz data-member The default ctor never initializes m_nstz but calls init with [NSTimeZone systemTimeZone].name. Init (re)sets m_nstz _only_ if this ianaId is in [NSTimeZone knownTimeZoneName], which is not guaranteed (a good example is "US/Pacific" that can be returned by systemTimeZoneId() - the similar problem is described in [*]. Set m_nstz to nil in ctor, so if 'init' fails we still have a valid (nil) pointer. [*] http://stackoverflow.com/questions/19819268/convert-ios-localtimezone-to-a-knowntimezone. Task-number: QTBUG-54330 Change-Id: I68917926350aad3158d44a06f06721f25b3fdb74 Reviewed-by: Edward Welbourne --- src/corelib/tools/qtimezoneprivate_mac.mm | 1 + 1 file changed, 1 insertion(+) diff --git a/src/corelib/tools/qtimezoneprivate_mac.mm b/src/corelib/tools/qtimezoneprivate_mac.mm index f316fe0a6d..4e5034516b 100644 --- a/src/corelib/tools/qtimezoneprivate_mac.mm +++ b/src/corelib/tools/qtimezoneprivate_mac.mm @@ -53,6 +53,7 @@ QT_BEGIN_NAMESPACE // Create the system default time zone QMacTimeZonePrivate::QMacTimeZonePrivate() + : m_nstz(0) { init(systemTimeZoneId()); } From 7c279d779b32eb61987fc7d4f1143a1eaa1a1bde Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 7 Jul 2016 12:36:33 +0200 Subject: [PATCH 23/51] QWindowsTabletSupport: fix new[]/delete mismatch QScopedPointer deletes with delete, but a pointer returned from new[] needs to be deleted with delete[]. Fix by using QVarLengthArray instead of QScopedPointer(new TCHAR[]). Change-Id: I2f1f252379a9ac1ee919901b5efcec9cec31261e Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qwindowstabletsupport.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowstabletsupport.cpp b/src/plugins/platforms/windows/qwindowstabletsupport.cpp index 222551a86f..87f3eff409 100644 --- a/src/plugins/platforms/windows/qwindowstabletsupport.cpp +++ b/src/plugins/platforms/windows/qwindowstabletsupport.cpp @@ -47,7 +47,7 @@ #include #include #include -#include +#include #include #include @@ -227,7 +227,7 @@ QString QWindowsTabletSupport::description() const const unsigned size = m_winTab32DLL.wTInfo(WTI_INTERFACE, IFC_WINTABID, 0); if (!size) return QString(); - QScopedPointer winTabId(new TCHAR[size + 1]); + QVarLengthArray winTabId(size + 1); m_winTab32DLL.wTInfo(WTI_INTERFACE, IFC_WINTABID, winTabId.data()); WORD implementationVersion = 0; m_winTab32DLL.wTInfo(WTI_INTERFACE, IFC_IMPLVERSION, &implementationVersion); From 6a7bae9a26aac877bceaf2810328064abc71c768 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 11 Jul 2016 12:11:14 +0200 Subject: [PATCH 24/51] QHashFunctions: test for hash equality of null and empty string types In Qt, null QStrings compare equal to empty ones, so add an explicit check that the corresponding hash values are identical, too. Ditto for QByteArray. Change-Id: I190fc95a765305928d9b6b0e4955433865b6b247 Reviewed-by: Thiago Macieira --- .../tools/qhashfunctions/tst_qhashfunctions.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp b/tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp index bde9433a24..4d61bc393d 100644 --- a/tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp +++ b/tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp @@ -45,6 +45,8 @@ class tst_QHashFunctions : public QObject Q_OBJECT private Q_SLOTS: void qhash(); + void qhash_of_empty_and_null_qstring(); + void qhash_of_empty_and_null_qbytearray(); void fp_qhash_of_zero_is_zero(); void qthash_data(); void qthash(); @@ -117,6 +119,20 @@ void tst_QHashFunctions::qhash() } } +void tst_QHashFunctions::qhash_of_empty_and_null_qstring() +{ + QString null, empty(""); + QCOMPARE(null, empty); + QCOMPARE(qHash(null), qHash(empty)); +} + +void tst_QHashFunctions::qhash_of_empty_and_null_qbytearray() +{ + QByteArray null, empty(""); + QCOMPARE(null, empty); + QCOMPARE(qHash(null), qHash(empty)); +} + void tst_QHashFunctions::fp_qhash_of_zero_is_zero() { QCOMPARE(qHash(-0.0f), 0U); From e6a5be1d81a3f8fce7e55906b4bc84d723e11ac5 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 11 Jul 2016 11:04:52 +0200 Subject: [PATCH 25/51] QPair: add test for pair of references std::pair explicitly supports this (cf. std::tie), so check we do, too. Change-Id: Idc3c1739a4bc64a0da120dcf953def7e432f6f71 Reviewed-by: Thiago Macieira --- tests/auto/corelib/tools/qpair/tst_qpair.cpp | 30 ++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/auto/corelib/tools/qpair/tst_qpair.cpp b/tests/auto/corelib/tools/qpair/tst_qpair.cpp index 076efc5428..94740d74bc 100644 --- a/tests/auto/corelib/tools/qpair/tst_qpair.cpp +++ b/tests/auto/corelib/tools/qpair/tst_qpair.cpp @@ -40,6 +40,7 @@ class tst_QPair : public QObject { Q_OBJECT private Q_SLOTS: + void pairOfReferences(); void testConstexpr(); }; @@ -94,6 +95,35 @@ Q_STATIC_ASSERT(!QTypeInfo::isDummy ); Q_STATIC_ASSERT(!QTypeInfo::isPointer); +void tst_QPair::pairOfReferences() +{ + int i = 0; + QString s; + + QPair p(i, s); + + p.first = 1; + QCOMPARE(i, 1); + + i = 2; + QCOMPARE(p.first, 2); + + p.second = QLatin1String("Hello"); + QCOMPARE(s, QLatin1String("Hello")); + + s = QLatin1String("olleH"); + QCOMPARE(p.second, QLatin1String("olleH")); + + QPair q = p; + q.first = 3; + QCOMPARE(i, 3); + QCOMPARE(p.first, 3); + + q.second = QLatin1String("World"); + QCOMPARE(s, QLatin1String("World")); + QCOMPARE(p.second, QLatin1String("World")); +} + void tst_QPair::testConstexpr() { Q_CONSTEXPR QPair pID = qMakePair(0, 0.0); From 7a2f53647bad30a95692bb2d32a9a080f948a20a Mon Sep 17 00:00:00 2001 From: Takumi ASAKI Date: Mon, 4 Jul 2016 13:55:06 +0900 Subject: [PATCH 26/51] Bearer/ConnMan: Fix No such slot Change-Id: Icf403b2e2e86d1cb58fd74c0df054bcc43cf9210 Reviewed-by: Lorn Potter --- src/plugins/bearer/connman/qconnmanservice_linux_p.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/bearer/connman/qconnmanservice_linux_p.h b/src/plugins/bearer/connman/qconnmanservice_linux_p.h index 1a10a2260a..7292736e2e 100644 --- a/src/plugins/bearer/connman/qconnmanservice_linux_p.h +++ b/src/plugins/bearer/connman/qconnmanservice_linux_p.h @@ -211,6 +211,7 @@ protected: private: QVariantMap properties(); QVariantMap propertiesMap; +private Q_SLOTS: void scanReply(QDBusPendingCallWatcher *call); }; From 9a3bcd1c3d4914a9594d80dc0c3812fd88be42c3 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Wed, 30 Mar 2016 19:26:29 +0200 Subject: [PATCH 27/51] QString::replace(): Commentary clarifications. Also skip doing a += 0 when we had to test whether the relevant rhs was zero anyway (because we want to ++ there instead of +=ing). Change-Id: Ibd5f21eb9aaf410b09c9db8450b2d61618e628fc Reviewed-by: Robin Burchell --- src/corelib/tools/qstring.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 3d63a540dd..68681a90d0 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -2488,19 +2488,19 @@ QString &QString::replace(const QChar *before, int blen, if (index == -1) break; indices[pos++] = index; - index += blen; - // avoid infinite loop - if (!blen) + if (blen) // Step over before: + index += blen; + else // Only count one instance of empty between any two characters: index++; } - if (!pos) + if (!pos) // Nothing to replace break; replace_helper(indices, pos, blen, after, alen); - if (index == -1) + if (index == -1) // Nothing left to replace break; - // index has to be adjusted in case we get back into the loop above. + // The call to replace_helper just moved what index points at: index += pos*(alen-blen); } @@ -2545,14 +2545,14 @@ QString& QString::replace(QChar ch, const QString &after, Qt::CaseSensitivity cs index++; } } - if (!pos) + if (!pos) // Nothing to replace break; replace_helper(indices, pos, 1, after.constData(), after.d->size); - if (index == -1) + if (index == -1) // Nothing left to replace break; - // index has to be adjusted in case we get back into the loop above. + // The call to replace_helper just moved what index points at: index += pos*(after.d->size - 1); } return *this; From e21bf5e6b390001ac83c403005957ddc8bfc36ae Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Wed, 30 Mar 2016 16:01:27 +0200 Subject: [PATCH 28/51] QString::replace(): protect sought text and replacement When replacing each copy of one text with a copy of another, we do so in batches of 1024; if we get more than one batch, we need to keep a copy of the sought text and replacement if they're part of the string we're modifying, for use in later batches. Also do the replacements in full batches of 1024, not 1023 (which left the last entry in an array unused); marked some related tests as (un)likely; and move some repeated code out into a pair of little local functions to save duplcation. Those new functions can also serve replace_helper(); and it can shed a const_cast and some conditioning of free() by using them the same way replace() now does. (There was also one place it still used the raw after, rather than the replacement copy; which could have produced errors if memcpy were to exercise its right to assume no overlap in arrays. This error is what prompted me to notice all of the above.) Added tests. The last error proved untestable as my memcpy is in fact as fussy as memmove. The first two tests added were attempts to get a failure out of it. The third did get a failure, but also tripped over the problem in replace() itself. Added to an existing test function and renamed it to generally cover extra tests for replace. Change-Id: I9ba6928c84ece266dbbe52b91e333ea54ab6d95e Reviewed-by: Robin Burchell Reviewed-by: Lars Knoll --- src/corelib/tools/qstring.cpp | 69 +++++++++++++------ .../corelib/tools/qstring/tst_qstring.cpp | 42 ++++++++++- 2 files changed, 89 insertions(+), 22 deletions(-) diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 68681a90d0..b5119444b7 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -2381,26 +2381,40 @@ QString &QString::replace(const QString &before, const QString &after, Qt::CaseS return replace(before.constData(), before.size(), after.constData(), after.size(), cs); } +namespace { // helpers for replace and its helper: +QChar *textCopy(const QChar *start, int len) +{ + const size_t size = len * sizeof(QChar); + QChar *const copy = static_cast(::malloc(size)); + Q_CHECK_PTR(copy); + ::memcpy(copy, start, size); + return copy; +} + +bool pointsIntoRange(const QChar *ptr, const ushort *base, int len) +{ + const QChar *const start = reinterpret_cast(base); + return start <= ptr && ptr < start + len; +} +} // end namespace + /*! \internal */ void QString::replace_helper(uint *indices, int nIndices, int blen, const QChar *after, int alen) { - // copy *after in case it lies inside our own d->data() area - // (which we could possibly invalidate via a realloc or corrupt via memcpy operations.) - QChar *afterBuffer = const_cast(after); - if (after >= reinterpret_cast(d->data()) && after < reinterpret_cast(d->data()) + d->size) { - afterBuffer = static_cast(::malloc(alen*sizeof(QChar))); - Q_CHECK_PTR(afterBuffer); - ::memcpy(afterBuffer, after, alen*sizeof(QChar)); - } + // Copy after if it lies inside our own d->data() area (which we could + // possibly invalidate via a realloc or modify by replacement). + QChar *afterBuffer = 0; + if (pointsIntoRange(after, d->data(), d->size)) // Use copy in place of vulnerable original: + after = afterBuffer = textCopy(after, alen); QT_TRY { if (blen == alen) { // replace in place detach(); for (int i = 0; i < nIndices; ++i) - memcpy(d->data() + indices[i], afterBuffer, alen * sizeof(QChar)); + memcpy(d->data() + indices[i], after, alen * sizeof(QChar)); } else if (alen < blen) { // replace from front detach(); @@ -2416,7 +2430,7 @@ void QString::replace_helper(uint *indices, int nIndices, int blen, const QChar to += msize; } if (alen) { - memcpy(d->data() + to, afterBuffer, alen*sizeof(QChar)); + memcpy(d->data() + to, after, alen * sizeof(QChar)); to += alen; } movestart = indices[i] + blen; @@ -2439,17 +2453,15 @@ void QString::replace_helper(uint *indices, int nIndices, int blen, const QChar int moveto = insertstart + alen; memmove(d->data() + moveto, d->data() + movestart, (moveend - movestart)*sizeof(QChar)); - memcpy(d->data() + insertstart, afterBuffer, alen*sizeof(QChar)); + memcpy(d->data() + insertstart, after, alen * sizeof(QChar)); moveend = movestart-blen; } } } QT_CATCH(const std::bad_alloc &) { - if (afterBuffer != after) - ::free(afterBuffer); + ::free(afterBuffer); QT_RETHROW; } - if (afterBuffer != after) - ::free(afterBuffer); + ::free(afterBuffer); } /*! @@ -2478,12 +2490,13 @@ QString &QString::replace(const QChar *before, int blen, return *this; QStringMatcher matcher(before, blen, cs); + QChar *beforeBuffer = 0, *afterBuffer = 0; int index = 0; while (1) { uint indices[1024]; uint pos = 0; - while (pos < 1023) { + while (pos < 1024) { index = matcher.indexIn(*this, index); if (index == -1) break; @@ -2496,13 +2509,29 @@ QString &QString::replace(const QChar *before, int blen, if (!pos) // Nothing to replace break; + if (Q_UNLIKELY(index != -1)) { + /* + We're about to change data, that before and after might point + into, and we'll need that data for our next batch of indices. + */ + if (!afterBuffer && pointsIntoRange(after, d->data(), d->size)) + after = afterBuffer = textCopy(after, alen); + + if (!beforeBuffer && pointsIntoRange(before, d->data(), d->size)) { + beforeBuffer = textCopy(before, blen); + matcher = QStringMatcher(beforeBuffer, blen, cs); + } + } + replace_helper(indices, pos, blen, after, alen); - if (index == -1) // Nothing left to replace + if (Q_LIKELY(index == -1)) // Nothing left to replace break; // The call to replace_helper just moved what index points at: index += pos*(alen-blen); } + ::free(afterBuffer); + ::free(beforeBuffer); return *this; } @@ -2533,13 +2562,13 @@ QString& QString::replace(QChar ch, const QString &after, Qt::CaseSensitivity cs uint indices[1024]; uint pos = 0; if (cs == Qt::CaseSensitive) { - while (pos < 1023 && index < d->size) { + while (pos < 1024 && index < d->size) { if (d->data()[index] == cc) indices[pos++] = index; index++; } } else { - while (pos < 1023 && index < d->size) { + while (pos < 1024 && index < d->size) { if (QChar::toCaseFolded(d->data()[index]) == cc) indices[pos++] = index; index++; @@ -2550,7 +2579,7 @@ QString& QString::replace(QChar ch, const QString &after, Qt::CaseSensitivity cs replace_helper(indices, pos, 1, after.constData(), after.d->size); - if (index == -1) // Nothing left to replace + if (Q_LIKELY(index == -1)) // Nothing left to replace break; // The call to replace_helper just moved what index points at: index += pos*(after.d->size - 1); diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp index 3bacf5d942..da6cdddd4f 100644 --- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp @@ -360,7 +360,7 @@ private slots: void replace_qchar_qstring(); void replace_uint_uint_data(); void replace_uint_uint(); - void replace_uint_uint_extra(); + void replace_extra(); void replace_string_data(); void replace_string(); void replace_regexp_data(); @@ -2790,7 +2790,7 @@ void tst_QString::replace_uint_uint() } } -void tst_QString::replace_uint_uint_extra() +void tst_QString::replace_extra() { /* This test is designed to be extremely slow if QString::replace() doesn't optimize the case @@ -2827,6 +2827,44 @@ void tst_QString::replace_uint_uint_extra() QString str5("abcdefghij"); str5.replace(8, 10, str5); QCOMPARE(str5, QString("abcdefghabcdefghij")); + + // Replacements using only part of the string modified: + QString str6("abcdefghij"); + str6.replace(1, 8, str6.constData() + 3, 3); + QCOMPARE(str6, QString("adefj")); + + QString str7("abcdefghibcdefghij"); + str7.replace(str7.constData() + 1, 6, str7.constData() + 2, 3); + QCOMPARE(str7, QString("acdehicdehij")); + + const int many = 1024; + /* + QS::replace(const QChar *, int, const QChar *, int, Qt::CaseSensitivity) + does its replacements in batches of many (please keep in sync with any + changes to batch size), which lead to misbehaviour if ether QChar * array + was part of the data being modified. + */ + QString str8("abcdefg"), ans8("acdeg"); + { + // Make str8 and ans8 repeat themselves many + 1 times: + int i = many; + QString big(str8), small(ans8); + while (i && !(i & 1)) { // Exploit many being a power of 2: + big += big; + small += small; + i >>= 1; + } + while (i-- > 0) { + str8 += big; + ans8 += small; + } + } + str8.replace(str8.constData() + 1, 5, str8.constData() + 2, 3); + // Pre-test the bit where the diff happens, so it gets displayed: + QCOMPARE(str8.mid((many - 3) * 5), ans8.mid((many - 3) * 5)); + // Also check the full values match, of course: + QCOMPARE(str8.size(), ans8.size()); + QCOMPARE(str8, ans8); } void tst_QString::replace_string() From 8beddf8328eb65436790e332b5e0c0760ada0c7d Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Wed, 29 Jun 2016 16:27:25 -0700 Subject: [PATCH 29/51] QSslSocketBackendPrivate: Remove QString warnings Change-Id: I2ab758fe61ea1ba9b84672ac05ac219b85e3de6a Reviewed-by: Timur Pocheptsov --- src/network/ssl/qsslsocket_mac.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/network/ssl/qsslsocket_mac.cpp b/src/network/ssl/qsslsocket_mac.cpp index 9f0359aa47..8aa9269f4b 100644 --- a/src/network/ssl/qsslsocket_mac.cpp +++ b/src/network/ssl/qsslsocket_mac.cpp @@ -600,7 +600,7 @@ void QSslSocketBackendPrivate::startClientEncryption() // Error description/code were set, 'error' emitted // by initSslContext, but OpenSSL socket also sets error // emits a signal twice, so ... - setErrorAndEmit(QAbstractSocket::SslInternalError, "Unable to init SSL Context"); + setErrorAndEmit(QAbstractSocket::SslInternalError, QStringLiteral("Unable to init SSL Context")); return; } @@ -613,7 +613,7 @@ void QSslSocketBackendPrivate::startServerEncryption() // Error description/code were set, 'error' emitted // by initSslContext, but OpenSSL socket also sets error // emits a signal twice, so ... - setErrorAndEmit(QAbstractSocket::SslInternalError, "Unable to init SSL Context"); + setErrorAndEmit(QAbstractSocket::SslInternalError, QStringLiteral("Unable to init SSL Context")); return; } @@ -936,7 +936,7 @@ bool QSslSocketBackendPrivate::initSslContext() context.reset(qt_createSecureTransportContext(mode)); if (!context) { - setErrorAndEmit(QAbstractSocket::SslInternalError, "SSLCreateContext failed"); + setErrorAndEmit(QAbstractSocket::SslInternalError, QStringLiteral("SSLCreateContext failed")); return false; } @@ -964,7 +964,7 @@ bool QSslSocketBackendPrivate::initSslContext() if (!setSessionProtocol()) { destroySslContext(); - setErrorAndEmit(QAbstractSocket::SslInternalError, "Failed to set protocol version"); + setErrorAndEmit(QAbstractSocket::SslInternalError, QStringLiteral("Failed to set protocol version")); return false; } @@ -1406,8 +1406,7 @@ bool QSslSocketBackendPrivate::startHandshake() // check protocol version ourselves, as Secure Transport does not enforce // the requested min / max versions. if (!verifySessionProtocol()) { - setErrorAndEmit(QAbstractSocket::SslHandshakeFailedError, - "Protocol version mismatch"); + setErrorAndEmit(QAbstractSocket::SslHandshakeFailedError, QStringLiteral("Protocol version mismatch")); plainSocket->disconnectFromHost(); return false; } From d6177b55eaf2f6545af2e7b70def51940a1f3ab8 Mon Sep 17 00:00:00 2001 From: Ralf Nolden Date: Thu, 7 Jul 2016 13:35:35 +0200 Subject: [PATCH 30/51] OpenBSD: add X11R6/lib to QMAKE_RPATHDIR As OpenBSD ships its own X11, linker errors occur when not explicitly adding the X11R6/lib dir to rpath dirs. Change-Id: I75991e9d7de115d2d212a017d9c8f9aa93cecc27 Reviewed-by: Oswald Buddenhagen --- mkspecs/openbsd-g++/qmake.conf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mkspecs/openbsd-g++/qmake.conf b/mkspecs/openbsd-g++/qmake.conf index 4232759997..6124d31439 100644 --- a/mkspecs/openbsd-g++/qmake.conf +++ b/mkspecs/openbsd-g++/qmake.conf @@ -17,6 +17,8 @@ QMAKE_LIBDIR_X11 = /usr/X11R6/lib QMAKE_INCDIR_OPENGL = /usr/X11R6/include QMAKE_LIBDIR_OPENGL = /usr/X11R6/lib +QMAKE_RPATHDIR += $$QMAKE_LIBDIR_X11 + include(../common/gcc-base-unix.conf) include(../common/g++-unix.conf) From 4397a1b26c244dc4cd0d3826e0c4135ec9003914 Mon Sep 17 00:00:00 2001 From: Ralf Nolden Date: Sat, 9 Jul 2016 10:44:31 +0200 Subject: [PATCH 31/51] FreeBSD: move order of includes for compiling The previous patch works for FreeBSD 10 but however not for 9 and 11 due to the order of includes. Move down to fix those compile issues due to unknown types when user.h is included first. Change-Id: Ica3d3ddf335a543c4a473e8b80d1667cb81667cf Reviewed-by: Thiago Macieira --- src/corelib/io/qlockfile_unix.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/corelib/io/qlockfile_unix.cpp b/src/corelib/io/qlockfile_unix.cpp index eed3158fbe..57c689ac81 100644 --- a/src/corelib/io/qlockfile_unix.cpp +++ b/src/corelib/io/qlockfile_unix.cpp @@ -59,12 +59,12 @@ # include # include #elif defined(Q_OS_BSD4) && !defined(Q_OS_IOS) -# if !defined(Q_OS_NETBSD) -# include -# endif # include # include # include +# if !defined(Q_OS_NETBSD) +# include +# endif #endif QT_BEGIN_NAMESPACE From 9131f6e56139924162778c6c0538dda58d839bbb Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 12 Jul 2016 16:02:53 +0200 Subject: [PATCH 32/51] QCompleter::setModel(): Restore completion role When setting a QFileSystemModel as model, the completion role is set to QFileSystemModel::FileNameRole. This needs to be reset to the default Qt::EditRole when setting another model. Task-number: QTBUG-54642 Change-Id: Ie78d5d417e008ad05a2f995bdbc218b3ad1bc49c Reviewed-by: Andy Shaw --- src/widgets/util/qcompleter.cpp | 4 ++++ .../util/qcompleter/tst_qcompleter.cpp | 19 +++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/widgets/util/qcompleter.cpp b/src/widgets/util/qcompleter.cpp index 55bb51d0a3..a036071893 100644 --- a/src/widgets/util/qcompleter.cpp +++ b/src/widgets/util/qcompleter.cpp @@ -1038,6 +1038,10 @@ void QCompleter::setModel(QAbstractItemModel *model) { Q_D(QCompleter); QAbstractItemModel *oldModel = d->proxy->sourceModel(); +#ifndef QT_NO_FILESYSTEMMODEL + if (qobject_cast(oldModel)) + setCompletionRole(Qt::EditRole); // QTBUG-54642, clear FileNameRole set by QFileSystemModel +#endif d->proxy->setSourceModel(model); if (d->popup) setPopup(d->popup); // set the model and make new connections diff --git a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp index e8ac9aa5d2..86a0bdf901 100644 --- a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp +++ b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp @@ -291,8 +291,8 @@ retry: // Testing get/set functions void tst_QCompleter::getSetCheck() { - QStandardItemModel model(3,3); - QCompleter completer(&model); + QStandardItemModel standardItemModel(3,3); + QCompleter completer(&standardItemModel); // QString QCompleter::completionPrefix() // void QCompleter::setCompletionPrefix(QString) @@ -352,6 +352,21 @@ void tst_QCompleter::getSetCheck() QCOMPARE(completer.wrapAround(), true); // default value completer.setWrapAround(false); QCOMPARE(completer.wrapAround(), false); + +#ifndef QT_NO_FILESYSTEMMODEL + // QTBUG-54642, changing from QFileSystemModel to another model should restore role. + completer.setCompletionRole(Qt::EditRole); + QCOMPARE(completer.completionRole(), static_cast(Qt::EditRole)); // default value + QFileSystemModel fileSystemModel; + completer.setModel(&fileSystemModel); + QCOMPARE(completer.completionRole(), static_cast(QFileSystemModel::FileNameRole)); + completer.setModel(&standardItemModel); + QCOMPARE(completer.completionRole(), static_cast(Qt::EditRole)); + completer.setCompletionRole(Qt::ToolTipRole); + QStandardItemModel standardItemModel2(2, 2); // Do not clobber a custom role when changing models + completer.setModel(&standardItemModel2); + QCOMPARE(completer.completionRole(), static_cast(Qt::ToolTipRole)); +#endif // QT_NO_FILESYSTEMMODEL } void tst_QCompleter::csMatchingOnCsSortedModel_data() From 07d3cbbe8450f870446f4bd2af2ec47baff23dc3 Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Mon, 20 Jun 2016 00:11:34 +0200 Subject: [PATCH 33/51] Add warning when using pkg-config with a Qt build with it disabled This patch adds a warning that will be shown when link_pkgconfig is used in a project but Qt's configuration has it disabled. This can happen when Qt is built before pkg-config has been installed or if it's not detected. This will avoid user losing time trying to make pkg-config work while Qt just ignores it. Change-Id: Ieeff8dd6784b9430cfebef355855ec1be91bc96e Reviewed-by: Oswald Buddenhagen --- mkspecs/features/qt_functions.prf | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mkspecs/features/qt_functions.prf b/mkspecs/features/qt_functions.prf index 86396958f1..4a1d265a8b 100644 --- a/mkspecs/features/qt_functions.prf +++ b/mkspecs/features/qt_functions.prf @@ -250,7 +250,10 @@ defineReplace(pkgConfigExecutable) { } defineTest(packagesExist) { - contains(QT_CONFIG, no-pkg-config):return(false) + contains(QT_CONFIG, no-pkg-config) { + warning("pkg-config disabled, can't check package existence") + return(false) + } # this can't be done in global scope here because qt_functions is loaded # before the .pro is parsed, so if the .pro set PKG_CONFIG, we wouldn't know it From b27d4835c2ae0d8767ca914acb72a4bdcea6fc85 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 29 Jun 2016 15:40:17 +0200 Subject: [PATCH 34/51] fix error() not propagating through if() if() would simply "downgrade" a fatal error to a false condition, which is certainly not expected. Change-Id: Ie9c54f2bddf588856498bf795007b341b7c9363a Reviewed-by: Joerg Bornemann --- qmake/library/qmakebuiltins.cpp | 4 ++-- qmake/library/qmakeevaluator.cpp | 9 +++++---- qmake/library/qmakeevaluator.h | 2 +- qmake/project.h | 2 +- tests/auto/tools/qmakelib/evaltest.cpp | 6 ++++++ 5 files changed, 15 insertions(+), 8 deletions(-) diff --git a/qmake/library/qmakebuiltins.cpp b/qmake/library/qmakebuiltins.cpp index e200c7c551..d8cd8c5c90 100644 --- a/qmake/library/qmakebuiltins.cpp +++ b/qmake/library/qmakebuiltins.cpp @@ -1221,8 +1221,8 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional( evalError(fL1S("if(condition) requires one argument.")); return ReturnFalse; } - return returnBool(evaluateConditional(args.at(0).toQString(), - m_current.pro->fileName(), m_current.line)); + return evaluateConditional(args.at(0).toQString(), + m_current.pro->fileName(), m_current.line); } case T_CONFIG: { if (args.count() < 1 || args.count() > 2) { diff --git a/qmake/library/qmakeevaluator.cpp b/qmake/library/qmakeevaluator.cpp index e9da45c14d..30f8619bc1 100644 --- a/qmake/library/qmakeevaluator.cpp +++ b/qmake/library/qmakeevaluator.cpp @@ -1758,13 +1758,14 @@ ProStringList QMakeEvaluator::evaluateExpandFunction( return ProStringList(); } -bool QMakeEvaluator::evaluateConditional(const QString &cond, const QString &where, int line) +QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateConditional( + const QString &cond, const QString &where, int line) { - bool ret = false; + VisitReturn ret = ReturnFalse; ProFile *pro = m_parser->parsedProBlock(cond, where, line, QMakeParser::TestGrammar); if (pro->isOk()) { m_locationStack.push(m_current); - ret = visitProBlock(pro, pro->tokPtr()) == ReturnTrue; + ret = visitProBlock(pro, pro->tokPtr()); m_current = m_locationStack.pop(); } pro->deref(); @@ -1776,7 +1777,7 @@ void QMakeEvaluator::checkRequirements(const ProStringList &deps) { ProStringList &failed = valuesRef(ProKey("QMAKE_FAILED_REQUIREMENTS")); foreach (const ProString &dep, deps) - if (!evaluateConditional(dep.toQString(), m_current.pro->fileName(), m_current.line)) + if (evaluateConditional(dep.toQString(), m_current.pro->fileName(), m_current.line) != ReturnTrue) failed << dep; } #endif diff --git a/qmake/library/qmakeevaluator.h b/qmake/library/qmakeevaluator.h index 312f1385fb..7db07b17ba 100644 --- a/qmake/library/qmakeevaluator.h +++ b/qmake/library/qmakeevaluator.h @@ -220,7 +220,7 @@ public: ProStringList evaluateBuiltinExpand(int func_t, const ProKey &function, const ProStringList &args); VisitReturn evaluateBuiltinConditional(int func_t, const ProKey &function, const ProStringList &args); - bool evaluateConditional(const QString &cond, const QString &where, int line = -1); + VisitReturn evaluateConditional(const QString &cond, const QString &where, int line = -1); #ifdef PROEVALUATOR_FULL void checkRequirements(const ProStringList &deps); #endif diff --git a/qmake/project.h b/qmake/project.h index 7cd49a457c..2c4883e578 100644 --- a/qmake/project.h +++ b/qmake/project.h @@ -60,7 +60,7 @@ public: ProString expand(const QString &v, const QString &file, int line); QStringList expand(const ProKey &func, const QList &args); bool test(const QString &v, const QString &file, int line) - { m_current.clear(); return evaluateConditional(v, file, line); } + { m_current.clear(); return evaluateConditional(v, file, line) == ReturnTrue; } bool test(const ProKey &func, const QList &args); bool isSet(const ProKey &v) const { return m_valuemapStack.first().contains(v); } diff --git a/tests/auto/tools/qmakelib/evaltest.cpp b/tests/auto/tools/qmakelib/evaltest.cpp index beafef5ad2..f172cda865 100644 --- a/tests/auto/tools/qmakelib/evaltest.cpp +++ b/tests/auto/tools/qmakelib/evaltest.cpp @@ -2103,6 +2103,12 @@ void tst_qmakelib::addTestFunctions(const QString &qindir) << "Project ERROR: World, you FAIL!" << false; + QTest::newRow("if(error())") + << "if(error(\\'World, you FAIL!\\')): OK = 1\nOKE = 1" + << "OK = UNDEF\nOKE = UNDEF" + << "Project ERROR: World, you FAIL!" + << false; + QTest::newRow("system()") << "system('" #ifdef Q_OS_WIN From 339b9706ccbed4063a92337c9994731793558b0a Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 29 Jun 2016 16:56:57 +0200 Subject: [PATCH 35/51] make error() propagate from custom replace functions it didn't, which is rather unexpected. Change-Id: I8cdb7b1490a8c2207809812b93cc65fbe23a1b98 Reviewed-by: Joerg Bornemann --- qmake/library/qmakeevaluator.cpp | 110 +++++++++++++++---------- qmake/library/qmakeevaluator.h | 14 ++-- qmake/project.cpp | 9 +- tests/auto/tools/qmakelib/evaltest.cpp | 66 +++++++++++++++ 4 files changed, 144 insertions(+), 55 deletions(-) diff --git a/qmake/library/qmakeevaluator.cpp b/qmake/library/qmakeevaluator.cpp index 30f8619bc1..1243a77afa 100644 --- a/qmake/library/qmakeevaluator.cpp +++ b/qmake/library/qmakeevaluator.cpp @@ -409,7 +409,7 @@ static ALWAYS_INLINE void addStrList( } } -void QMakeEvaluator::evaluateExpression( +QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateExpression( const ushort *&tokPtr, ProStringList *ret, bool joined) { debugMsg(2, joined ? "evaluating joined expression" : "evaluating expression"); @@ -459,12 +459,15 @@ void QMakeEvaluator::evaluateExpression( case TokFuncName: { const ProKey &func = pro->getHashStr(tokPtr); debugMsg(2, "function %s", dbgKey(func)); - addStrList(evaluateExpandFunction(func, tokPtr), tok, ret, pending, joined); + ProStringList val; + if (evaluateExpandFunction(func, tokPtr, &val) == ReturnError) + return ReturnError; + addStrList(val, tok, ret, pending, joined); break; } default: debugMsg(2, "evaluated expression => %s", dbgStrList(*ret)); tokPtr--; - return; + return ReturnTrue; } } } @@ -536,7 +539,9 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProBlock( case TokAppendUnique: case TokRemove: case TokReplace: - visitProVariable(tok, curr, tokPtr); + ret = visitProVariable(tok, curr, tokPtr); + if (ret == ReturnError) + break; curr.clear(); continue; case TokBranch: @@ -696,9 +701,9 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProBlock( continue; default: { const ushort *oTokPtr = --tokPtr; - evaluateExpression(tokPtr, &curr, false); - if (tokPtr != oTokPtr) - continue; + ret = evaluateExpression(tokPtr, &curr, false); + if (ret == ReturnError || tokPtr != oTokPtr) + break; } Q_ASSERT_X(false, "visitProBlock", "unexpected item type"); continue; @@ -731,7 +736,10 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProLoop( int index = 0; ProKey variable; ProStringList oldVarVal; - ProString it_list = expandVariableReferences(exprPtr, 0, true).at(0); + ProStringList it_list_out; + if (expandVariableReferences(exprPtr, 0, &it_list_out, true) == ReturnError) + return ReturnError; + ProString it_list = it_list_out.at(0); if (_variable.isEmpty()) { if (it_list != statics.strever) { evalError(fL1S("Invalid loop expression.")); @@ -828,7 +836,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProLoop( return ret; } -void QMakeEvaluator::visitProVariable( +QMakeEvaluator::VisitReturn QMakeEvaluator::visitProVariable( ushort tok, const ProStringList &curr, const ushort *&tokPtr) { int sizeHint = *tokPtr++; @@ -837,24 +845,26 @@ void QMakeEvaluator::visitProVariable( skipExpression(tokPtr); if (!m_cumulative || !curr.isEmpty()) evalError(fL1S("Left hand side of assignment must expand to exactly one word.")); - return; + return ReturnTrue; } const ProKey &varName = map(curr.first()); if (tok == TokReplace) { // ~= // DEFINES ~= s/a/b/?[gqi] - const ProStringList &varVal = expandVariableReferences(tokPtr, sizeHint, true); + ProStringList varVal; + if (expandVariableReferences(tokPtr, sizeHint, &varVal, true) == ReturnError) + return ReturnError; const QString &val = varVal.at(0).toQString(m_tmp1); if (val.length() < 4 || val.at(0) != QLatin1Char('s')) { evalError(fL1S("The ~= operator can handle only the s/// function.")); - return; + return ReturnTrue; } QChar sep = val.at(1); QStringList func = val.split(sep); if (func.count() < 3 || func.count() > 4) { evalError(fL1S("The s/// function expects 3 or 4 arguments.")); - return; + return ReturnTrue; } bool global = false, quote = false, case_sense = false; @@ -875,7 +885,9 @@ void QMakeEvaluator::visitProVariable( replaceInList(&valuesRef(varName), regexp, replace, global, m_tmp2); debugMsg(2, "replaced %s with %s", dbgQStr(pattern), dbgQStr(replace)); } else { - ProStringList varVal = expandVariableReferences(tokPtr, sizeHint); + ProStringList varVal; + if (expandVariableReferences(tokPtr, sizeHint, &varVal, false) == ReturnError) + return ReturnError; switch (tok) { default: // whatever - cannot happen case TokAssign: // = @@ -923,6 +935,8 @@ void QMakeEvaluator::visitProVariable( else if (varName == statics.strREQUIRES) checkRequirements(values(varName)); #endif + + return ReturnTrue; } void QMakeEvaluator::setTemplate() @@ -1610,18 +1624,18 @@ bool QMakeEvaluator::isActiveConfig(const QString &config, bool regex) return false; } -ProStringList QMakeEvaluator::expandVariableReferences( - const ushort *&tokPtr, int sizeHint, bool joined) +QMakeEvaluator::VisitReturn QMakeEvaluator::expandVariableReferences( + const ushort *&tokPtr, int sizeHint, ProStringList *ret, bool joined) { - ProStringList ret; - ret.reserve(sizeHint); + ret->reserve(sizeHint); forever { - evaluateExpression(tokPtr, &ret, joined); + if (evaluateExpression(tokPtr, ret, joined) == ReturnError) + return ReturnError; switch (*tokPtr) { case TokValueTerminator: case TokFuncTerminator: tokPtr++; - return ret; + return ReturnTrue; case TokArgSeparator: if (joined) { tokPtr++; @@ -1635,28 +1649,28 @@ ProStringList QMakeEvaluator::expandVariableReferences( } } -QList QMakeEvaluator::prepareFunctionArgs(const ushort *&tokPtr) +QMakeEvaluator::VisitReturn QMakeEvaluator::prepareFunctionArgs( + const ushort *&tokPtr, QList *ret) { - QList args_list; if (*tokPtr != TokFuncTerminator) { for (;; tokPtr++) { ProStringList arg; - evaluateExpression(tokPtr, &arg, false); - args_list << arg; + if (evaluateExpression(tokPtr, &arg, false) == ReturnError) + return ReturnError; + *ret << arg; if (*tokPtr == TokFuncTerminator) break; Q_ASSERT(*tokPtr == TokArgSeparator); } } tokPtr++; - return args_list; + return ReturnTrue; } -ProStringList QMakeEvaluator::evaluateFunction( - const ProFunctionDef &func, const QList &argumentsList, VisitReturn *ok) +QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateFunction( + const ProFunctionDef &func, const QList &argumentsList, ProStringList *ret) { VisitReturn vr; - ProStringList ret; if (m_valuemapStack.count() >= 100) { evalError(fL1S("Ran into infinite recursion (depth > 100).")); @@ -1675,25 +1689,22 @@ ProStringList QMakeEvaluator::evaluateFunction( vr = visitProBlock(func.pro(), func.tokPtr()); if (vr == ReturnReturn) vr = ReturnTrue; - ret = m_returnValue; + if (vr == ReturnTrue) + *ret = m_returnValue; m_returnValue.clear(); m_current = m_locationStack.pop(); m_valuemapStack.pop(); } - if (ok) - *ok = vr; - if (vr == ReturnTrue) - return ret; - return ProStringList(); + return vr; } QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBoolFunction( const ProFunctionDef &func, const QList &argumentsList, const ProString &function) { - VisitReturn vr; - ProStringList ret = evaluateFunction(func, argumentsList, &vr); + ProStringList ret; + VisitReturn vr = evaluateFunction(func, argumentsList, &ret); if (vr == ReturnTrue) { if (ret.isEmpty()) return ReturnTrue; @@ -1721,13 +1732,18 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateConditionalFunction( { if (int func_t = statics.functions.value(func)) { //why don't the builtin functions just use args_list? --Sam - return evaluateBuiltinConditional(func_t, func, expandVariableReferences(tokPtr, 5, true)); + ProStringList args; + if (expandVariableReferences(tokPtr, 5, &args, true) == ReturnError) + return ReturnError; + return evaluateBuiltinConditional(func_t, func, args); } QHash::ConstIterator it = m_functionDefs.testFunctions.constFind(func); if (it != m_functionDefs.testFunctions.constEnd()) { - const QList args = prepareFunctionArgs(tokPtr); + QList args; + if (prepareFunctionArgs(tokPtr, &args) == ReturnError) + return ReturnError; traceMsg("calling %s(%s)", dbgKey(func), dbgStrListList(args)); return evaluateBoolFunction(*it, args, func); } @@ -1737,25 +1753,31 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateConditionalFunction( return ReturnFalse; } -ProStringList QMakeEvaluator::evaluateExpandFunction( - const ProKey &func, const ushort *&tokPtr) +QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateExpandFunction( + const ProKey &func, const ushort *&tokPtr, ProStringList *ret) { if (int func_t = statics.expands.value(func)) { //why don't the builtin functions just use args_list? --Sam - return evaluateBuiltinExpand(func_t, func, expandVariableReferences(tokPtr, 5, true)); + ProStringList args; + if (expandVariableReferences(tokPtr, 5, &args, true) == ReturnError) + return ReturnError; + *ret = evaluateBuiltinExpand(func_t, func, args); + return ReturnTrue; } QHash::ConstIterator it = m_functionDefs.replaceFunctions.constFind(func); if (it != m_functionDefs.replaceFunctions.constEnd()) { - const QList args = prepareFunctionArgs(tokPtr); + QList args; + if (prepareFunctionArgs(tokPtr, &args) == ReturnError) + return ReturnError; traceMsg("calling $$%s(%s)", dbgKey(func), dbgStrListList(args)); - return evaluateFunction(*it, args, 0); + return evaluateFunction(*it, args, ret); } skipExpression(tokPtr); evalError(fL1S("'%1' is not a recognized replace function.").arg(func.toQString(m_tmp1))); - return ProStringList(); + return ReturnFalse; } QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateConditional( diff --git a/qmake/library/qmakeevaluator.h b/qmake/library/qmakeevaluator.h index 7db07b17ba..9625c8b8df 100644 --- a/qmake/library/qmakeevaluator.h +++ b/qmake/library/qmakeevaluator.h @@ -153,7 +153,7 @@ public: { return b ? ReturnTrue : ReturnFalse; } static ALWAYS_INLINE uint getBlockLen(const ushort *&tokPtr); - void evaluateExpression(const ushort *&tokPtr, ProStringList *ret, bool joined); + VisitReturn evaluateExpression(const ushort *&tokPtr, ProStringList *ret, bool joined); static ALWAYS_INLINE void skipStr(const ushort *&tokPtr); static ALWAYS_INLINE void skipHashStr(const ushort *&tokPtr); void skipExpression(const ushort *&tokPtr); @@ -173,7 +173,7 @@ public: VisitReturn visitProLoop(const ProKey &variable, const ushort *exprPtr, const ushort *tokPtr); void visitProFunctionDef(ushort tok, const ProKey &name, const ushort *tokPtr); - void visitProVariable(ushort tok, const ProStringList &curr, const ushort *&tokPtr); + VisitReturn visitProVariable(ushort tok, const ProStringList &curr, const ushort *&tokPtr); ALWAYS_INLINE const ProKey &map(const ProString &var) { return map(var.toKey()); } const ProKey &map(const ProKey &var); @@ -182,7 +182,7 @@ public: void setTemplate(); ProStringList split_value_list(const QString &vals, const ProFile *source = 0); - ProStringList expandVariableReferences(const ushort *&tokPtr, int sizeHint = 0, bool joined = false); + VisitReturn expandVariableReferences(const ushort *&tokPtr, int sizeHint, ProStringList *ret, bool joined); QString currentFileName() const; QString currentDirectory() const; @@ -207,14 +207,14 @@ public: void deprecationWarning(const QString &msg) const { message(QMakeHandler::EvalWarnDeprecated, msg); } - QList prepareFunctionArgs(const ushort *&tokPtr); - ProStringList evaluateFunction(const ProFunctionDef &func, - const QList &argumentsList, VisitReturn *ok); + VisitReturn prepareFunctionArgs(const ushort *&tokPtr, QList *ret); + VisitReturn evaluateFunction(const ProFunctionDef &func, + const QList &argumentsList, ProStringList *ret); VisitReturn evaluateBoolFunction(const ProFunctionDef &func, const QList &argumentsList, const ProString &function); - ProStringList evaluateExpandFunction(const ProKey &function, const ushort *&tokPtr); + VisitReturn evaluateExpandFunction(const ProKey &function, const ushort *&tokPtr, ProStringList *ret); VisitReturn evaluateConditionalFunction(const ProKey &function, const ushort *&tokPtr); ProStringList evaluateBuiltinExpand(int func_t, const ProKey &function, const ProStringList &args); diff --git a/qmake/project.cpp b/qmake/project.cpp index faea6da650..9c06f7ef5d 100644 --- a/qmake/project.cpp +++ b/qmake/project.cpp @@ -110,9 +110,8 @@ QStringList QMakeProject::expand(const ProKey &func, const QList QHash::ConstIterator it = m_functionDefs.replaceFunctions.constFind(func); if (it != m_functionDefs.replaceFunctions.constEnd()) { - QMakeProject::VisitReturn vr; - ProStringList ret = evaluateFunction(*it, args, &vr); - if (vr == QMakeProject::ReturnError) + ProStringList ret; + if (evaluateFunction(*it, args, &ret) == QMakeProject::ReturnError) exit(3); return ret.toQStringList(); } @@ -130,7 +129,9 @@ ProString QMakeProject::expand(const QString &expr, const QString &where, int li m_current.pro = pro; m_current.line = 0; const ushort *tokPtr = pro->tokPtr(); - ProStringList result = expandVariableReferences(tokPtr, 1, true); + ProStringList result; + if (expandVariableReferences(tokPtr, 1, &result, true) == ReturnError) + exit(3); if (!result.isEmpty()) ret = result.at(0); } diff --git a/tests/auto/tools/qmakelib/evaltest.cpp b/tests/auto/tools/qmakelib/evaltest.cpp index f172cda865..b7acf70e88 100644 --- a/tests/auto/tools/qmakelib/evaltest.cpp +++ b/tests/auto/tools/qmakelib/evaltest.cpp @@ -641,6 +641,72 @@ void tst_qmakelib::addControlStructs() << "VAR = final" << "" << true; + + QTest::newRow("error() from replace function (assignment)") + << "defineReplace(func) {\nerror(error)\n}\n" + "VAR = $$func()\n" + "OKE = 1" + << "VAR = UNDEF\nOKE = UNDEF" + << "Project ERROR: error" + << false; + + QTest::newRow("error() from replace function (replacement)") + << "defineReplace(func) {\nerror(error)\n}\n" + "VAR = $$func()\n" + "OKE = 1" + << "VAR = UNDEF\nOKE = UNDEF" + << "Project ERROR: error" + << false; + + QTest::newRow("error() from replace function (LHS)") + << "defineReplace(func) {\nerror(error)\nreturn(VAR)\n}\n" + "$$func() = 1\n" + "OKE = 1" + << "VAR = UNDEF\nOKE = UNDEF" + << "Project ERROR: error" + << false; + + QTest::newRow("error() from replace function (loop variable)") + << "defineReplace(func) {\nerror(error)\nreturn(BLAH)\n}\n" + "for($$func()) {\nVAR = $$BLAH\nbreak()\n}\n" + "OKE = 1" + << "VAR = UNDEF\nOKE = UNDEF" + << "Project ERROR: error" + << false; + + QTest::newRow("error() from replace function (built-in test arguments)") + << "defineReplace(func) {\nerror(error)\n}\n" + "message($$func()): VAR = 1\n" + "OKE = 1" + << "VAR = UNDEF\nOKE = UNDEF" + << "Project ERROR: error" + << false; + + QTest::newRow("error() from replace function (built-in replace arguments)") + << "defineReplace(func) {\nerror(error)\n}\n" + "VAR = $$upper($$func())\n" + "OKE = 1" + << "VAR = UNDEF\nOKE = UNDEF" + << "Project ERROR: error" + << false; + + QTest::newRow("error() from replace function (custom test arguments)") + << "defineReplace(func) {\nerror(error)\n}\n" + "defineTest(custom) {\n}\n" + "custom($$func()): VAR = 1\n" + "OKE = 1" + << "VAR = UNDEF\nOKE = UNDEF" + << "Project ERROR: error" + << false; + + QTest::newRow("error() from replace function (custom replace arguments)") + << "defineReplace(func) {\nerror(error)\nreturn(1)\n}\n" + "defineReplace(custom) {\nreturn($$1)\n}\n" + "VAR = $$custom($$func(1))\n" + "OKE = 1" + << "VAR = UNDEF\nOKE = UNDEF" + << "Project ERROR: error" + << false; } void tst_qmakelib::addReplaceFunctions(const QString &qindir) From 1b4ea11332f74984a62a4cc4597ad49f5b5269dc Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 30 Jun 2016 16:02:29 +0200 Subject: [PATCH 36/51] make error() propagate from requires() and REQUIRES= that can make sense if a function which determines the availability of a dependency fails to do so for unexpected reasons. Change-Id: If6cd113df25aee66830c120a2fab067c822a4543 Reviewed-by: Joerg Bornemann --- qmake/library/qmakebuiltins.cpp | 3 ++- qmake/library/qmakeevaluator.cpp | 13 +++++++++---- qmake/library/qmakeevaluator.h | 2 +- tests/auto/tools/qmakelib/evaltest.cpp | 14 ++++++++++++++ 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/qmake/library/qmakebuiltins.cpp b/qmake/library/qmakebuiltins.cpp index d8cd8c5c90..272b0cc30d 100644 --- a/qmake/library/qmakebuiltins.cpp +++ b/qmake/library/qmakebuiltins.cpp @@ -1200,7 +1200,8 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional( return ReturnFalse; case T_REQUIRES: #ifdef PROEVALUATOR_FULL - checkRequirements(args); + if (checkRequirements(args) == ReturnError) + return ReturnError; #endif return ReturnFalse; // Another qmake breakage case T_EVAL: { diff --git a/qmake/library/qmakeevaluator.cpp b/qmake/library/qmakeevaluator.cpp index 1243a77afa..a09168876a 100644 --- a/qmake/library/qmakeevaluator.cpp +++ b/qmake/library/qmakeevaluator.cpp @@ -933,7 +933,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProVariable( } #ifdef PROEVALUATOR_FULL else if (varName == statics.strREQUIRES) - checkRequirements(values(varName)); + return checkRequirements(values(varName)); #endif return ReturnTrue; @@ -1795,12 +1795,17 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateConditional( } #ifdef PROEVALUATOR_FULL -void QMakeEvaluator::checkRequirements(const ProStringList &deps) +QMakeEvaluator::VisitReturn QMakeEvaluator::checkRequirements(const ProStringList &deps) { ProStringList &failed = valuesRef(ProKey("QMAKE_FAILED_REQUIREMENTS")); - foreach (const ProString &dep, deps) - if (evaluateConditional(dep.toQString(), m_current.pro->fileName(), m_current.line) != ReturnTrue) + foreach (const ProString &dep, deps) { + VisitReturn vr = evaluateConditional(dep.toQString(), m_current.pro->fileName(), m_current.line); + if (vr == ReturnError) + return ReturnError; + if (vr != ReturnTrue) failed << dep; + } + return ReturnTrue; } #endif diff --git a/qmake/library/qmakeevaluator.h b/qmake/library/qmakeevaluator.h index 9625c8b8df..f370898cc9 100644 --- a/qmake/library/qmakeevaluator.h +++ b/qmake/library/qmakeevaluator.h @@ -222,7 +222,7 @@ public: VisitReturn evaluateConditional(const QString &cond, const QString &where, int line = -1); #ifdef PROEVALUATOR_FULL - void checkRequirements(const ProStringList &deps); + VisitReturn checkRequirements(const ProStringList &deps); #endif void updateMkspecPaths(); diff --git a/tests/auto/tools/qmakelib/evaltest.cpp b/tests/auto/tools/qmakelib/evaltest.cpp index b7acf70e88..934ee580ed 100644 --- a/tests/auto/tools/qmakelib/evaltest.cpp +++ b/tests/auto/tools/qmakelib/evaltest.cpp @@ -707,6 +707,20 @@ void tst_qmakelib::addControlStructs() << "VAR = UNDEF\nOKE = UNDEF" << "Project ERROR: error" << false; + + QTest::newRow("REQUIRES = error()") + << "REQUIRES = error(error)\n" + "OKE = 1" + << "OKE = UNDEF" + << "Project ERROR: error" + << false; + + QTest::newRow("requires(error())") + << "requires(error(error))\n" + "OKE = 1" + << "OKE = UNDEF" + << "Project ERROR: error" + << false; } void tst_qmakelib::addReplaceFunctions(const QString &qindir) From dacf3994ba29106132c3a377dba303acdb74daca Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 30 Jun 2016 17:26:01 +0200 Subject: [PATCH 37/51] fix custom functions inheriting other functions' arguments Task-number: QTBUG-41830 Change-Id: Iba3eee4975a1ee671b7190e52c0efc9a18147c62 Reviewed-by: Joerg Bornemann Reviewed-by: Lars Knoll Reviewed-by: Oswald Buddenhagen --- qmake/library/qmakeevaluator.cpp | 56 ++++++++++++++++++-------- tests/auto/tools/qmakelib/evaltest.cpp | 17 ++++++++ 2 files changed, 56 insertions(+), 17 deletions(-) diff --git a/qmake/library/qmakeevaluator.cpp b/qmake/library/qmakeevaluator.cpp index a09168876a..48bd17e789 100644 --- a/qmake/library/qmakeevaluator.cpp +++ b/qmake/library/qmakeevaluator.cpp @@ -1809,19 +1809,35 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::checkRequirements(const ProStringLis } #endif +static bool isFunctParam(const ProKey &variableName) +{ + const int len = variableName.size(); + const QChar *data = variableName.constData(); + for (int i = 0; i < len; i++) { + ushort c = data[i].unicode(); + if (c < '0' || c > '9') + return false; + } + return true; +} + ProValueMap *QMakeEvaluator::findValues(const ProKey &variableName, ProValueMap::Iterator *rit) { ProValueMapStack::Iterator vmi = m_valuemapStack.end(); - do { + for (bool first = true; ; first = false) { --vmi; ProValueMap::Iterator it = (*vmi).find(variableName); if (it != (*vmi).end()) { if (it->constBegin() == statics.fakeValue.constBegin()) - return 0; + break; *rit = it; return &(*vmi); } - } while (vmi != m_valuemapStack.begin()); + if (vmi == m_valuemapStack.begin()) + break; + if (first && isFunctParam(variableName)) + break; + } return 0; } @@ -1833,18 +1849,20 @@ ProStringList &QMakeEvaluator::valuesRef(const ProKey &variableName) it->clear(); return *it; } - ProValueMapStack::Iterator vmi = m_valuemapStack.end(); - if (--vmi != m_valuemapStack.begin()) { - do { - --vmi; - ProValueMap::ConstIterator it = (*vmi).constFind(variableName); - if (it != (*vmi).constEnd()) { - ProStringList &ret = m_valuemapStack.top()[variableName]; - if (it->constBegin() != statics.fakeValue.constBegin()) - ret = *it; - return ret; - } - } while (vmi != m_valuemapStack.begin()); + if (!isFunctParam(variableName)) { + ProValueMapStack::Iterator vmi = m_valuemapStack.end(); + if (--vmi != m_valuemapStack.begin()) { + do { + --vmi; + ProValueMap::ConstIterator it = (*vmi).constFind(variableName); + if (it != (*vmi).constEnd()) { + ProStringList &ret = m_valuemapStack.top()[variableName]; + if (it->constBegin() != statics.fakeValue.constBegin()) + ret = *it; + return ret; + } + } while (vmi != m_valuemapStack.begin()); + } } return m_valuemapStack.top()[variableName]; } @@ -1852,7 +1870,7 @@ ProStringList &QMakeEvaluator::valuesRef(const ProKey &variableName) ProStringList QMakeEvaluator::values(const ProKey &variableName) const { ProValueMapStack::ConstIterator vmi = m_valuemapStack.constEnd(); - do { + for (bool first = true; ; first = false) { --vmi; ProValueMap::ConstIterator it = (*vmi).constFind(variableName); if (it != (*vmi).constEnd()) { @@ -1860,7 +1878,11 @@ ProStringList QMakeEvaluator::values(const ProKey &variableName) const break; return *it; } - } while (vmi != m_valuemapStack.constBegin()); + if (vmi == m_valuemapStack.constBegin()) + break; + if (first && isFunctParam(variableName)) + break; + } return ProStringList(); } diff --git a/tests/auto/tools/qmakelib/evaltest.cpp b/tests/auto/tools/qmakelib/evaltest.cpp index 934ee580ed..f70ee683e2 100644 --- a/tests/auto/tools/qmakelib/evaltest.cpp +++ b/tests/auto/tools/qmakelib/evaltest.cpp @@ -599,6 +599,23 @@ void tst_qmakelib::addControlStructs() << "" << true; + QTest::newRow("function arguments") + << "defineTest(func) {\n" + "defined(1, var) {\nd1 = 1\nexport(d1)\n}\n" + "defined(3, var) {\nd3 = 1\nexport(d3)\n}\n" + "x1 = $$1\nexport(x1)\n" + "2 += foo\nx2 = $$2\nexport(x2)\n" + "x3 = $$3\nexport(x3)\n" + "4 += foo\nx4 = $$4\nexport(x4)\n" + "x5 = $$5\nexport(x5)\n" + "6 += foo\nx6 = $$6\nexport(x6)\n" + "}\n" + "1 = first\n2 = second\n3 = third\n4 = fourth\nfunc(one, two)" + << "1 = first\n2 = second\n3 = third\n4 = fourth\n5 = UNDEF\n6 = UNDEF\n" + "d1 = 1\nd3 = UNDEF\nx1 = one\nx2 = two foo\nx3 =\nx4 = foo\nx5 =\nx6 = foo" + << "" + << true; + QTest::newRow("ARGC and ARGS") << "defineTest(func) {\n" "export(ARGC)\n" From d459a6b0e0d4f128caceaafe981ecf374bb3e420 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 5 Jul 2016 20:00:17 +0200 Subject: [PATCH 38/51] fix calculations of worst-case size requirements for token buffer Change-Id: I3aa4c736acec44f95a0a33c7baae9276568f684f Reviewed-by: Joerg Bornemann Reviewed-by: Oswald Buddenhagen --- qmake/library/qmakeparser.cpp | 15 +++++++++------ tests/auto/tools/qmakelib/parsertest.cpp | 7 +++++++ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/qmake/library/qmakeparser.cpp b/qmake/library/qmakeparser.cpp index 8170eee76c..180fe90878 100644 --- a/qmake/library/qmakeparser.cpp +++ b/qmake/library/qmakeparser.cpp @@ -304,27 +304,30 @@ void QMakeParser::read(ProFile *pro, const QString &in, int line, SubGrammar gra // Worst-case size calculations: // - line marker adds 1 (2-nl) to 1st token of each line // - empty assignment "A=":2 => - // TokHashLiteral(1) + hash(2) + len(1) + "A"(1) + TokAssign(1) + 0(1) + + // TokHashLiteral(1) + hash(2) + len(1) + "A"(1) + TokAssign(1) + size_hint(1) + // TokValueTerminator(1) == 8 (9) // - non-empty assignment "A=B C":5 => - // TokHashLiteral(1) + hash(2) + len(1) + "A"(1) + TokAssign(1) + 2(1) + + // TokHashLiteral(1) + hash(2) + len(1) + "A"(1) + TokAssign(1) + size_hint(1) + // TokLiteral(1) + len(1) + "B"(1) + // TokLiteral(1) + len(1) + "C"(1) + TokValueTerminator(1) == 14 (15) // - variable expansion: "$$f":3 => // TokVariable(1) + hash(2) + len(1) + "f"(1) = 5 // - function expansion: "$$f()":5 => // TokFuncName(1) + hash(2) + len(1) + "f"(1) + TokFuncTerminator(1) = 6 + // - test literal: "X":1 => + // TokHashLiteral(1) + hash(2) + len(1) + "A"(1) + TokCondition(1) = 6 (7) // - scope: "X:":2 => // TokHashLiteral(1) + hash(2) + len(1) + "A"(1) + TokCondition(1) + - // TokBranch(1) + len(2) + ... + len(2) + ... == 10 - // - test: "X():":4 => + // TokBranch(1) + len(2) + ... + len(2) + ... == 11 (12) + // - test call: "X():":4 => // TokHashLiteral(1) + hash(2) + len(1) + "A"(1) + TokTestCall(1) + TokFuncTerminator(1) + - // TokBranch(1) + len(2) + ... + len(2) + ... == 11 + // TokBranch(1) + len(2) + ... + len(2) + ... == 12 (13) // - "for(A,B):":9 => // TokForLoop(1) + hash(2) + len(1) + "A"(1) + // len(2) + TokLiteral(1) + len(1) + "B"(1) + TokValueTerminator(1) + // len(2) + ... + TokTerminator(1) == 14 (15) - tokBuff.reserve((in.size() + 1) * 5); + // One extra for possibly missing trailing newline. + tokBuff.reserve((in.size() + 1) * 7); ushort *tokPtr = (ushort *)tokBuff.constData(); // Current writing position // Expression precompiler buffer. diff --git a/tests/auto/tools/qmakelib/parsertest.cpp b/tests/auto/tools/qmakelib/parsertest.cpp index a7b7431a98..7e6757a2ff 100644 --- a/tests/auto/tools/qmakelib/parsertest.cpp +++ b/tests/auto/tools/qmakelib/parsertest.cpp @@ -1872,6 +1872,13 @@ void tst_qmakelib::addParseAbuse() /* 24 */ /* else branch */ << I(0)) << "in:1: OR operator without prior condition." << false; + + // Token buffer overflow. Verify with Valgrind or asan. + QTest::newRow("QTCREATORBUG-16508") + << "a{b{c{d{" + << TS() + << "in:2: Missing closing brace(s)." + << false; } void tst_qmakelib::proParser_data() From 3c8134958c66f40bb86588aa91b83bf58b5de0c9 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 5 Jul 2016 18:07:14 +0200 Subject: [PATCH 39/51] fix raw data leak in $$absolute_path() when the file name is empty, the path will be returned verbatim. this must be considered when constructing the return value. Task-number: QTBUG-54550 Change-Id: Ie108ed52275e66a154ef63bd6f7193f55b3e0454 Reviewed-by: Joerg Bornemann --- qmake/library/qmakebuiltins.cpp | 6 +++++- tests/auto/tools/qmakelib/evaltest.cpp | 8 ++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/qmake/library/qmakebuiltins.cpp b/qmake/library/qmakebuiltins.cpp index 272b0cc30d..c1d23295e7 100644 --- a/qmake/library/qmakebuiltins.cpp +++ b/qmake/library/qmakebuiltins.cpp @@ -1027,7 +1027,11 @@ ProStringList QMakeEvaluator::evaluateBuiltinExpand( QString rstr = QDir::cleanPath( QDir(args.count() > 1 ? args.at(1).toQString(m_tmp2) : currentDirectory()) .absoluteFilePath(args.at(0).toQString(m_tmp1))); - ret << (rstr.isSharedWith(m_tmp1) ? args.at(0) : ProString(rstr).setSource(args.at(0))); + ret << (rstr.isSharedWith(m_tmp1) + ? args.at(0) + : args.count() > 1 && rstr.isSharedWith(m_tmp2) + ? args.at(1) + : ProString(rstr).setSource(args.at(0))); } break; case E_RELATIVE_PATH: diff --git a/tests/auto/tools/qmakelib/evaltest.cpp b/tests/auto/tools/qmakelib/evaltest.cpp index f70ee683e2..09482d86d9 100644 --- a/tests/auto/tools/qmakelib/evaltest.cpp +++ b/tests/auto/tools/qmakelib/evaltest.cpp @@ -2482,6 +2482,14 @@ void tst_qmakelib::proEval_data() "Project MESSAGE: assign split joined: word: this is a test:done\n" "Project MESSAGE: assign split quoted: word this is a test done" << true; + + // Raw data leak with empty file name. Verify with Valgrind or asan. + QTest::newRow("QTBUG-54550") + << "FULL = /there/is\n" + "VAR = $$absolute_path(, $$FULL/nothing/here/really)" + << "VAR = /there/is/nothing/here/really" + << "" + << true; } static QString formatValue(const ProStringList &vals) From fc57a6587b75a56b5f2f041c94a7ae656eba54b9 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 8 Jul 2016 19:02:59 +0200 Subject: [PATCH 40/51] remove redundant condition from private module use warning the whole point of the check is ensuring that the message is printed only once for each sub-project, so !build_pass alone is fully adequate. Change-Id: Ib8f821ead6709efc9bfa935e1d05f8caba02a814 Reviewed-by: Jake Petroules --- mkspecs/features/qt.prf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkspecs/features/qt.prf b/mkspecs/features/qt.prf index 75b84ff6aa..be08a2a051 100644 --- a/mkspecs/features/qt.prf +++ b/mkspecs/features/qt.prf @@ -156,7 +156,7 @@ for(ever) { !isEmpty(var_sfx): break() var_sfx = _PRIVATE } -!isEmpty(using_privates):!no_private_qt_headers_warning:if(!debug_and_release|!build_pass) { +!isEmpty(using_privates):!no_private_qt_headers_warning:!build_pass { message("This project is using private headers and will therefore be tied to this specific Qt module build version.") message("Running this project against other versions of the Qt modules may crash at any arbitrary point.") message("This is not a bug, but a result of using Qt internals. You have been warned!") From a42c9cfc285a7b71b971a8aa000ca8d5216592ba Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 8 Jul 2016 19:09:49 +0200 Subject: [PATCH 41/51] generalize references to exclusive builds exclusive_builds_post.prf (via default_post.prf) processes debug_and_release into BUILDS, so .prfs which can rely on being executed later (because they are loaded via CONFIG) can rely on BUILDS and related variables. Change-Id: I5677079ad5145bf493af17b4b60347208572fd21 Reviewed-by: Jake Petroules Reviewed-by: Oswald Buddenhagen --- mkspecs/features/file_copies.prf | 3 +-- mkspecs/features/qt_docs_targets.prf | 2 +- mkspecs/features/resources.prf | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/mkspecs/features/file_copies.prf b/mkspecs/features/file_copies.prf index 6df294212c..4ebf41c78f 100644 --- a/mkspecs/features/file_copies.prf +++ b/mkspecs/features/file_copies.prf @@ -1,8 +1,7 @@ isEmpty(COPIES): return() contains(TEMPLATE, .*subdirs): error("COPIES does not work with TEMPLATE=subdirs") -build_pass:build_all: \ - debug_and_release:debug { +build_pass:build_all:!isEqual(BUILD_PASS, $$first(BUILDS)) { # Avoid that multiple build passes race with each other. # This will fail to copy anything if the user explicitly invokes # only the non-primary build. This is unfixable, as at qmake time diff --git a/mkspecs/features/qt_docs_targets.prf b/mkspecs/features/qt_docs_targets.prf index 1f9e2b0b47..9e96432462 100644 --- a/mkspecs/features/qt_docs_targets.prf +++ b/mkspecs/features/qt_docs_targets.prf @@ -30,7 +30,7 @@ contains(TEMPLATE, subdirs) { for(inst, DOC_TARGETS): \ prepareRecursiveTarget($$inst) } else { - debug_and_release:!build_pass { + !isEmpty(BUILDS):!build_pass { sub = $$first(BUILDS) for(inst, DOC_TARGETS) { $${inst}.CONFIG = recursive diff --git a/mkspecs/features/resources.prf b/mkspecs/features/resources.prf index 1f04c8b0d7..bc548ced05 100644 --- a/mkspecs/features/resources.prf +++ b/mkspecs/features/resources.prf @@ -35,7 +35,7 @@ for(resource, RESOURCES) { resource_file = $$RCC_DIR/qmake_$${resource}.qrc - !debug_and_release|build_pass { + isEmpty(BUILDS)|build_pass { # Collection of files, generate qrc file prefix = $$eval($${resource}.prefix) isEmpty(prefix): \ From 5cbe16be78121b503104f57c4aab03b378823e64 Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Thu, 23 Jun 2016 16:16:06 -0700 Subject: [PATCH 42/51] Set library strip flags on Apple platforms This was missed in ab599a39313c22fd14cc5466cea5c61bbcdbba8e when QMAKE_STRIP was set as a side effect of adding support for separate debug info. Task-number: QTBUG-54212 Change-Id: I86dd040dbefec4c58879c7d029ed89dd8bad3daf Reviewed-by: Thiago Macieira Reviewed-by: Oswald Buddenhagen --- mkspecs/common/mac.conf | 1 + 1 file changed, 1 insertion(+) diff --git a/mkspecs/common/mac.conf b/mkspecs/common/mac.conf index aac9d1b3d7..d267d1f10d 100644 --- a/mkspecs/common/mac.conf +++ b/mkspecs/common/mac.conf @@ -31,6 +31,7 @@ QMAKE_LIBS_THREAD = QMAKE_DSYMUTIL = dsymutil QMAKE_STRIP = strip +QMAKE_STRIPFLAGS_LIB += -S -x QMAKE_AR = ar cq QMAKE_RANLIB = ranlib -s From 1e843b41b6b2ba164615543a5683800d074e60f4 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Thu, 17 Mar 2016 15:37:39 +0100 Subject: [PATCH 43/51] Mac: Read in the string with QString::fromUtf8() as it is UTF8 encoded Task-number: QTBUG-47358 Change-Id: I50943867d3a57c4db4fe20e55e60d097742e9104 Reviewed-by: Jake Petroules Reviewed-by: jian liang --- src/platformsupport/clipboard/qmacmime.mm | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/platformsupport/clipboard/qmacmime.mm b/src/platformsupport/clipboard/qmacmime.mm index 317648956c..2e3257cfcf 100644 --- a/src/platformsupport/clipboard/qmacmime.mm +++ b/src/platformsupport/clipboard/qmacmime.mm @@ -403,9 +403,7 @@ QVariant QMacPasteboardMimeUnicodeText::convertToMime(const QString &mimetype, Q // I can only handle two types (system and unicode) so deal with them that way QVariant ret; if (flavor == QLatin1String("public.utf8-plain-text")) { - ret = QString(QCFString(CFStringCreateWithBytes(kCFAllocatorDefault, - reinterpret_cast(firstData.constData()), - firstData.size(), CFStringGetSystemEncoding(), false))); + ret = QString::fromUtf8(firstData); } else if (flavor == QLatin1String("public.utf16-plain-text")) { ret = QString(reinterpret_cast(firstData.constData()), firstData.size() / sizeof(QChar)); From 21c8a66a152e3184d8f965dc4cf2a1bee234780d Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Mon, 11 Jul 2016 13:00:15 -0700 Subject: [PATCH 44/51] QCocoaMenuBar: Sync items only when they are attached to a menu Another one of Cocoa's capricious behaviors. Evidence shows that the menu item's submenu property needs to be set before we can set the item's hidden property. We ensure this is the case by getting the NSMenuItem through QCocoaMenu::attachedItem() instead of QCocoaMenuBar::nativeItemForMenu() in QCocoaMenuBar::syncMenu(). Change-Id: Id50356dae5f556fa3d745ba9a5982e5a72bf0ac2 Task-number: QTBUG-54637 Reviewed-by: Jake Petroules Reviewed-by: Jason Haslam --- src/plugins/platforms/cocoa/qcocoamenubar.mm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoamenubar.mm b/src/plugins/platforms/cocoa/qcocoamenubar.mm index a534d2064e..9b03ea17c4 100644 --- a/src/plugins/platforms/cocoa/qcocoamenubar.mm +++ b/src/plugins/platforms/cocoa/qcocoamenubar.mm @@ -173,9 +173,11 @@ void QCocoaMenuBar::syncMenu(QPlatformMenu *menu) } } - NSMenuItem *nativeMenuItem = nativeItemForMenu(cocoaMenu); - nativeMenuItem.title = cocoaMenu->nsMenu().title; - nativeMenuItem.hidden = shouldHide; + if (NSMenuItem *attachedItem = cocoaMenu->attachedItem()) { + // Non-nil attached item means the item's submenu is set + attachedItem.title = cocoaMenu->nsMenu().title; + attachedItem.hidden = shouldHide; + } } NSMenuItem *QCocoaMenuBar::nativeItemForMenu(QCocoaMenu *menu) const From d7cb2fd44b7801799401dca343014bbf53ad130c Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Fri, 8 Jul 2016 14:10:34 +0200 Subject: [PATCH 45/51] QMacStyle::styleHint - test pixmap sizes styleHint for SH_FocusFrame_Mask calls drawControl with a painter created for pixmap. We only test pixmapSize.isValid(), but the size (0,0) is also 'isValid', and we end up with a QPainter with an invalid paintEngine (null) crashing in drawControl. Task-number: QTBUG-54630 Change-Id: I84d1785f04ffb3e608812076a6d1bc36ffb92adc Reviewed-by: Gabriel de Dietrich --- src/widgets/styles/qmacstyle_mac.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index 18ba2f45f5..3352c5d589 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -2961,7 +2961,7 @@ int QMacStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w QImage img; QSize pixmapSize = opt->rect.size(); - if (pixmapSize.isValid()) { + if (!pixmapSize.isEmpty()) { QPixmap pix(pixmapSize); pix.fill(QColor(fillR, fillG, fillB)); QPainter pix_paint(&pix); From 5d8a33a86cb6d852716a9c871576b2f9361a61a1 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Fri, 8 Jul 2016 15:44:39 +0200 Subject: [PATCH 46/51] [iOS] Blacklist iOS with regards to bgra support A number of devices are indicating that there is a problem with using bgra so instead of blacklisting all of them individually it is best to blacklist them all on the iOS platform. This ensures QQuickItem::grabToImage() will work then. Task-number: QTBUG-45902 Change-Id: I900857cfa996924469aaaeeee8037dc84a4fd575 Reviewed-by: Laszlo Agocs --- src/gui/opengl/qopenglframebufferobject.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gui/opengl/qopenglframebufferobject.cpp b/src/gui/opengl/qopenglframebufferobject.cpp index db7de5e8bf..6fc18b1d01 100644 --- a/src/gui/opengl/qopenglframebufferobject.cpp +++ b/src/gui/opengl/qopenglframebufferobject.cpp @@ -1282,6 +1282,7 @@ static inline QImage qt_gl_read_framebuffer_rgba8(const QSize &size, bool includ const char *ver = reinterpret_cast(funcs->glGetString(GL_VERSION)); // Blacklist GPU chipsets that have problems with their BGRA support. +#ifndef Q_OS_IOS const bool blackListed = (qstrcmp(renderer, "PowerVR Rogue G6200") == 0 && ::strstr(ver, "1.3") != 0) || (qstrcmp(renderer, "Mali-T760") == 0 @@ -1289,7 +1290,9 @@ static inline QImage qt_gl_read_framebuffer_rgba8(const QSize &size, bool includ (qstrcmp(renderer, "Mali-T720") == 0 && ::strstr(ver, "3.1") != 0) || qstrcmp(renderer, "PowerVR SGX 554") == 0; - +#else + const bool blackListed = true; +#endif const bool supports_bgra = has_bgra_ext && !blackListed; if (supports_bgra) { From 6bb0bc73c809d1defdcedc31c4c464a129d3de4d Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 14 Jul 2016 09:35:50 +0200 Subject: [PATCH 47/51] QWindowsTheme: Fix the available file icon sizes Previously, QWindowsTheme had a hardcoded list of of available file icon sizes. As the sizes depend on the Windows display scale factor, this can lead to undesired scaling of icons. Maintain an array of the standard sizes against which the sizes are matched; refresh in display change. Task-number: QTBUG-54561 Change-Id: If36de2f30c8a230cc7bd8eeb4dfc9f201aeda5e4 Reviewed-by: Oliver Wolff --- .../platforms/windows/qwindowscontext.cpp | 3 ++ .../platforms/windows/qwindowstheme.cpp | 49 ++++++++++++++----- src/plugins/platforms/windows/qwindowstheme.h | 5 ++ 3 files changed, 45 insertions(+), 12 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index 39054b6a64..b6118431d3 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -41,6 +41,7 @@ #include "qwindowsmime.h" #include "qwindowsinputcontext.h" #include "qwindowstabletsupport.h" +#include "qwindowstheme.h" #include #ifndef QT_NO_ACCESSIBILITY # include "accessible/qwindowsaccessibility.h" @@ -1007,6 +1008,8 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message, #endif case QtWindows::DisplayChangedEvent: return d->m_screenManager.handleDisplayChange(wParam, lParam); + if (QWindowsTheme *t = QWindowsTheme::instance()) + t->displayChanged(); case QtWindows::SettingChangedEvent: return d->m_screenManager.handleScreenChanges(); default: diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp index f673ce5c25..ce0c69f9ed 100644 --- a/src/plugins/platforms/windows/qwindowstheme.cpp +++ b/src/plugins/platforms/windows/qwindowstheme.cpp @@ -329,6 +329,7 @@ QWindowsTheme::QWindowsTheme() std::fill(m_fonts, m_fonts + NFonts, static_cast(0)); std::fill(m_palettes, m_palettes + NPalettes, static_cast(0)); refresh(); + refreshIconPixmapSizes(); } QWindowsTheme::~QWindowsTheme() @@ -394,16 +395,8 @@ QVariant QWindowsTheme::themeHint(ThemeHint hint) const return QVariant(int(WindowsKeyboardScheme)); case UiEffects: return QVariant(uiEffects()); - case IconPixmapSizes: { - QList sizes; - sizes << 16 << 32; -#ifdef USE_IIMAGELIST - sizes << 48; // sHIL_EXTRALARGE - if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA) - sizes << 256; // SHIL_JUMBO -#endif // USE_IIMAGELIST - return QVariant::fromValue(sizes); - } + case IconPixmapSizes: + return m_fileIconSizes; case DialogSnapToDefaultButton: return QVariant(booleanSystemParametersInfo(SPI_GETSNAPTODEFBUTTON, false)); case ContextMenuOnMouseRelease: @@ -473,6 +466,15 @@ void QWindowsTheme::refreshFonts() #endif // !Q_OS_WINCE } +enum FileIconSize { + // Standard icons obtainable via shGetFileInfo(), SHGFI_SMALLICON, SHGFI_LARGEICON + SmallFileIcon, LargeFileIcon, + // Larger icons obtainable via SHGetImageList() + ExtraLargeFileIcon, + JumboFileIcon, // Vista onwards + FileIconSizeCount +}; + bool QWindowsTheme::usePlatformNativeDialog(DialogType type) const { return QWindowsDialogs::useHelper(type); @@ -489,6 +491,27 @@ void QWindowsTheme::windowsThemeChanged(QWindow * window) QWindowSystemInterface::handleThemeChange(window); } +static int fileIconSizes[FileIconSizeCount]; + +void QWindowsTheme::refreshIconPixmapSizes() +{ + // Standard sizes: 16, 32, 48, 256 + fileIconSizes[SmallFileIcon] = GetSystemMetrics(SM_CXSMICON); // corresponds to SHGFI_SMALLICON); + fileIconSizes[LargeFileIcon] = GetSystemMetrics(SM_CXICON); // corresponds to SHGFI_LARGEICON + fileIconSizes[ExtraLargeFileIcon] = + fileIconSizes[LargeFileIcon] + fileIconSizes[LargeFileIcon] / 2; + fileIconSizes[JumboFileIcon] = 8 * fileIconSizes[LargeFileIcon]; // empirical, has not been observed to work + QList sizes; + sizes << fileIconSizes[SmallFileIcon] << fileIconSizes[LargeFileIcon]; +#ifdef USE_IIMAGELIST + sizes << fileIconSizes[ExtraLargeFileIcon]; // sHIL_EXTRALARGE + if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA) + sizes << fileIconSizes[JumboFileIcon]; // SHIL_JUMBO +#endif // USE_IIMAGELIST + qCDebug(lcQpaWindows) << __FUNCTION__ << sizes; + m_fileIconSizes = QVariant::fromValue(sizes); +} + // Defined in qpixmap_win.cpp Q_GUI_EXPORT QPixmap qt_pixmapFromWinHICON(HICON icon); @@ -706,10 +729,12 @@ QPixmap QWindowsTheme::fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &s QPixmap pixmap; const QString filePath = QDir::toNativeSeparators(fileInfo.filePath()); const int width = int(size.width()); - const int iconSize = width > 16 ? SHGFI_LARGEICON : SHGFI_SMALLICON; + const int iconSize = width > fileIconSizes[SmallFileIcon] ? SHGFI_LARGEICON : SHGFI_SMALLICON; const int requestedImageListSize = #ifdef USE_IIMAGELIST - width > 48 ? sHIL_JUMBO : (width > 32 ? sHIL_EXTRALARGE : 0); + width > fileIconSizes[ExtraLargeFileIcon] + ? sHIL_JUMBO + : (width > fileIconSizes[LargeFileIcon] ? sHIL_EXTRALARGE : 0); #else 0; #endif // !USE_IIMAGELIST diff --git a/src/plugins/platforms/windows/qwindowstheme.h b/src/plugins/platforms/windows/qwindowstheme.h index cacde98601..aafcf320aa 100644 --- a/src/plugins/platforms/windows/qwindowstheme.h +++ b/src/plugins/platforms/windows/qwindowstheme.h @@ -37,6 +37,8 @@ #include "qwindowsthreadpoolrunner.h" #include +#include + QT_BEGIN_NAMESPACE class QWindow; @@ -62,6 +64,7 @@ public: QPlatformTheme::IconOptions iconOptions = 0) const Q_DECL_OVERRIDE; void windowsThemeChanged(QWindow *window); + void displayChanged() { refreshIconPixmapSizes(); } static const char *name; @@ -71,11 +74,13 @@ private: void refreshPalettes(); void clearFonts(); void refreshFonts(); + void refreshIconPixmapSizes(); static QWindowsTheme *m_instance; QPalette *m_palettes[NPalettes]; QFont *m_fonts[NFonts]; mutable QWindowsThreadPoolRunner m_threadPoolRunner; + QVariant m_fileIconSizes; }; QT_END_NAMESPACE From 9a00ae8e24a03b25476cc6200bddf4c8fc510733 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 14 Jul 2016 15:00:23 +0200 Subject: [PATCH 48/51] Windows QPA: Add warning to setHasBorderInFullScreen() Emit a warning when the function is called before show() as it does not have any effect in that case. Amends change 69839e55c13000ee9bf8d8e9d74b70096a92ae51. Task-number: QTBUG-41309 Change-Id: I7c2bb21735d8e41d525c5e00213b0e278ae5c774 Reviewed-by: Oliver Wolff --- src/plugins/platforms/windows/qwindowswindow.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 9c6cb53365..e4888d6b87 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -2402,9 +2402,10 @@ void QWindowsWindow::aboutToMakeCurrent() void QWindowsWindow::setHasBorderInFullScreenStatic(QWindow *window, bool border) { - if (!window->handle()) - return; - static_cast(window->handle())->setHasBorderInFullScreen(border); + if (QPlatformWindow *handle = window->handle()) + static_cast(handle)->setHasBorderInFullScreen(border); + else + qWarning("%s invoked without window handle; call has no effect.", Q_FUNC_INFO); } void QWindowsWindow::setHasBorderInFullScreen(bool border) From 34de4f6a157ac10a434b719f41a06b4293023b29 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Thu, 7 Jul 2016 12:08:31 +0200 Subject: [PATCH 49/51] moc: Fix a crash with malformed input MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Do not increment 'data' past the buffer in case of invalid token. Remove the left over qDebug so we can make a test. Task-number: QTBUG-54609 Change-Id: I8f0dd3381fbdea3f07d3c05c9a44a16d92538117 Reviewed-by: JÄ™drzej Nowacki --- src/tools/moc/preprocessor.cpp | 8 ++++---- tests/auto/tools/moc/tst_moc.cpp | 9 ++++++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/tools/moc/preprocessor.cpp b/src/tools/moc/preprocessor.cpp index bfe61d0895..2b04b678fa 100644 --- a/src/tools/moc/preprocessor.cpp +++ b/src/tools/moc/preprocessor.cpp @@ -188,7 +188,8 @@ Symbols Preprocessor::tokenize(const QByteArray& input, int lineNum, Preprocesso token = keywords[state].ident; if (token == NOTOKEN) { - ++data; + if (*data) + ++data; // an error really, but let's ignore this input // to not confuse moc later. However in pre-processor // only mode let's continue. @@ -361,7 +362,6 @@ Symbols Preprocessor::tokenize(const QByteArray& input, int lineNum, Preprocesso ++data; continue; } - int nextindex = pp_keywords[state].next; int next = 0; if (*data == pp_keywords[state].defchar) @@ -380,7 +380,8 @@ Symbols Preprocessor::tokenize(const QByteArray& input, int lineNum, Preprocesso switch (token) { case NOTOKEN: - ++data; + if (*data) + ++data; break; case PP_DEFINE: mode = PrepareDefine; @@ -1251,7 +1252,6 @@ void Preprocessor::parseDefineArguments(Macro *m) error("missing ')' in macro argument list"); break; } else if (!is_identifier(l.constData(), l.length())) { - qDebug() << l; error("Unexpected character in macro argument list."); } } diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp index b3f9a9f85f..9d2b883112 100644 --- a/tests/auto/tools/moc/tst_moc.cpp +++ b/tests/auto/tools/moc/tst_moc.cpp @@ -1935,6 +1935,13 @@ void tst_Moc::warnings_data() << 1 << QString("IGNORE_ALL_STDOUT") << QString(":2: Error: Macro invoked with too few parameters for a use of '#'"); + + QTest::newRow("QTBUG-54609: crash on invalid input") + << QByteArray::fromBase64("EAkJCQkJbGFzcyBjbGFzcyBiYWkcV2kgTUEKcGYjZGVmaW5lIE1BKFEs/4D/FoQ=") + << QStringList() + << 1 + << QString("IGNORE_ALL_STDOUT") + << QString(":-1: Error: Unexpected character in macro argument list."); } void tst_Moc::warnings() @@ -1950,7 +1957,7 @@ void tst_Moc::warnings() #ifdef Q_CC_MSVC // for some reasons, moc compiled with MSVC uses a different output format - QRegExp lineNumberRe(":(\\d+):"); + QRegExp lineNumberRe(":(-?\\d+):"); lineNumberRe.setMinimal(true); expectedStdErr.replace(lineNumberRe, "(\\1):"); #endif From 89765ced6e9ce7e20aa1090439869509f86a070a Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 14 Jul 2016 16:19:42 +0200 Subject: [PATCH 50/51] Windows: Add a workaround for render-to-texture widgets for translucent windows Do not attempt to switch from translucent GL windows (emulated by DWM blur behind) to translucent raster windows (using layered windows) as this produces warnings from UpdateLayeredWindowIndirect() failing. Task-number: QTBUG-54734 Change-Id: Ie05126c5cb091a00f17b88a74b287c90aa2dfebd Reviewed-by: Joni Poikelin Reviewed-by: Laszlo Agocs --- src/widgets/kernel/qwidgetbackingstore.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/widgets/kernel/qwidgetbackingstore.cpp b/src/widgets/kernel/qwidgetbackingstore.cpp index 7473dd1dfb..3f62e7913f 100644 --- a/src/widgets/kernel/qwidgetbackingstore.cpp +++ b/src/widgets/kernel/qwidgetbackingstore.cpp @@ -1018,9 +1018,11 @@ static QPlatformTextureList *widgetTexturesFor(QWidget *tlw, QWidget *widget) // The Windows compositor handles fullscreen OpenGL window specially. Besides // having trouble with popups, it also has issues with flip-flopping between // OpenGL-based and normal flushing. Therefore, stick with GL for fullscreen -// windows. (QTBUG-53515) +// windows (QTBUG-53515). Similary, translucent windows should not switch to +// layered native windows (QTBUG-54734). #if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) && !defined(Q_OS_WINCE) || tlw->windowState().testFlag(Qt::WindowFullScreen) + || tlw->testAttribute(Qt::WA_TranslucentBackground) #endif ) { From 178ab885626bcd67507fde7f67f65c1872ac3be3 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Thu, 19 May 2016 18:06:59 +0200 Subject: [PATCH 51/51] PathStrokeRenderer::initializePoints(): use float division The (example) code used a real to hold 360 / 7, which is of course 51, discarding the 3/7 that was most likely meant to be kept. Noticed by Coverity (CID 22364). Use 360.0 instead of 360 to get more accurate results. Change-Id: Ifdfbb932589d8ea728710e8b656af651c9f8a7d2 Reviewed-by: Marc Mutz --- examples/widgets/painting/pathstroke/pathstroke.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/widgets/painting/pathstroke/pathstroke.cpp b/examples/widgets/painting/pathstroke/pathstroke.cpp index d93dcfe386..db3c6f946b 100644 --- a/examples/widgets/painting/pathstroke/pathstroke.cpp +++ b/examples/widgets/painting/pathstroke/pathstroke.cpp @@ -477,7 +477,7 @@ void PathStrokeRenderer::initializePoints() m_vectors.clear(); QMatrix m; - qreal rot = 360 / count; + qreal rot = 360.0 / count; QPointF center(width() / 2, height() / 2); QMatrix vm; vm.shear(2, -1);