From 8f85e82c5dc3d3028828e11ff59b16e3cae2844d Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Mon, 4 Jul 2016 08:07:42 +0200 Subject: 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(-) (limited to 'src') 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(); } -- cgit v1.2.3 From 3cc2884c031e0ab1098f59fae9aa6e05f54d36f8 Mon Sep 17 00:00:00 2001 From: Olivier Blin Date: Mon, 30 May 2016 11:16:19 +0200 Subject: 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(-) (limited to 'src') 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 -- cgit v1.2.3 From 4927fdb389b9fbc0d5118437274d4fa3c59fc839 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 5 Jul 2016 15:13:44 +0200 Subject: 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(-) (limited to 'src') 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)) -- cgit v1.2.3 From a91d0dd369313dfa8865f99e590b868146cb4388 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 5 Jul 2016 15:11:43 +0200 Subject: 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 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') 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; } -- cgit v1.2.3 From 631b143b3f6650b5761ac2c78e7936e1594b6e4f Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 1 Jul 2016 17:28:37 +0200 Subject: 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 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') 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 } -- cgit v1.2.3 From 9d620483c6b9ac0ba15bb3c8ea2482a09202f1a1 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Wed, 29 Jun 2016 16:36:17 -0700 Subject: 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(-) (limited to 'src') 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; } -- cgit v1.2.3 From 16fefc258ec022b0c6828c70741c2c8c43a01f12 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Thu, 30 Jun 2016 16:21:59 -0700 Subject: 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(-) (limited to 'src') 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); -- cgit v1.2.3 From 1575f2fc3cf74035716f2dc0c31442d77f136561 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 10 Jun 2016 11:03:44 -0700 Subject: 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(-) (limited to 'src') 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) { -- cgit v1.2.3 From abc29084fadf9c7d936fca55d02323090d9986cc Mon Sep 17 00:00:00 2001 From: Roger Maclean Date: Wed, 29 Oct 2014 11:06:20 -0400 Subject: 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(-) (limited to 'src') 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; -- cgit v1.2.3 From b6c10cf33107309f13c9845495d9d7d4f45f34bf Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Mon, 4 Jul 2016 15:21:19 +0200 Subject: 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(-) (limited to 'src') 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 -- cgit v1.2.3 From c8aa7eda3abfba9004eb70db571c7c537494b7f0 Mon Sep 17 00:00:00 2001 From: Boris Pek Date: Sun, 19 Jun 2016 03:15:43 +0300 Subject: 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(-) (limited to 'src') 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 -- cgit v1.2.3 From 14c6f80f4b2d8275037ed1fc3c63870e7f21570a Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 1 Jul 2016 16:18:41 +0200 Subject: 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(-) (limited to 'src') 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) -- cgit v1.2.3 From deb2728a8677b275613668d1467b636ed1776282 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Thu, 7 Jul 2016 15:23:20 +0200 Subject: [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(-) (limited to 'src') 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(); } } -- cgit v1.2.3 From 6bafb9da71044d99a95a591f7872b8b2fd97174a Mon Sep 17 00:00:00 2001 From: Anton Kudryavtsev Date: Thu, 7 Jul 2016 11:05:07 +0300 Subject: 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(-) (limited to 'src') 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 -- cgit v1.2.3 From 38b09d34210805766afa8bdd6a1ef413447a89ed Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Thu, 7 Jul 2016 14:33:30 -0700 Subject: 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(-) (limited to 'src') 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; -- cgit v1.2.3 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: 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(-) (limited to 'src') 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. -- cgit v1.2.3 From 8cee6864c6718449e3b5bedcd79173391ec188e7 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 8 Jul 2016 10:45:51 +0200 Subject: 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(-) (limited to 'src') 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 -- cgit v1.2.3 From f8dc769655959b290d70a2e66e2c3a625aa813cd Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Mon, 27 Jun 2016 14:30:59 +0200 Subject: 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(+) (limited to 'src') 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()); } -- cgit v1.2.3 From 7c279d779b32eb61987fc7d4f1143a1eaa1a1bde Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 7 Jul 2016 12:36:33 +0200 Subject: 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(-) (limited to 'src') 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); -- cgit v1.2.3 From 7a2f53647bad30a95692bb2d32a9a080f948a20a Mon Sep 17 00:00:00 2001 From: Takumi ASAKI Date: Mon, 4 Jul 2016 13:55:06 +0900 Subject: 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(+) (limited to 'src') 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); }; -- cgit v1.2.3 From 9a3bcd1c3d4914a9594d80dc0c3812fd88be42c3 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Wed, 30 Mar 2016 19:26:29 +0200 Subject: 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(-) (limited to 'src') 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; -- cgit v1.2.3 From e21bf5e6b390001ac83c403005957ddc8bfc36ae Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Wed, 30 Mar 2016 16:01:27 +0200 Subject: 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 ++++++++++++++++++++++++++++++------------- 1 file changed, 49 insertions(+), 20 deletions(-) (limited to 'src') 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); -- cgit v1.2.3 From 8beddf8328eb65436790e332b5e0c0760ada0c7d Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Wed, 29 Jun 2016 16:27:25 -0700 Subject: 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(-) (limited to 'src') 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; } -- cgit v1.2.3 From 4397a1b26c244dc4cd0d3826e0c4135ec9003914 Mon Sep 17 00:00:00 2001 From: Ralf Nolden Date: Sat, 9 Jul 2016 10:44:31 +0200 Subject: 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(-) (limited to 'src') 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 -- cgit v1.2.3 From 9131f6e56139924162778c6c0538dda58d839bbb Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 12 Jul 2016 16:02:53 +0200 Subject: 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 ++++ 1 file changed, 4 insertions(+) (limited to 'src') 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 -- cgit v1.2.3 From 1e843b41b6b2ba164615543a5683800d074e60f4 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Thu, 17 Mar 2016 15:37:39 +0100 Subject: 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(-) (limited to 'src') 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)); -- cgit v1.2.3 From 21c8a66a152e3184d8f965dc4cf2a1bee234780d Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Mon, 11 Jul 2016 13:00:15 -0700 Subject: 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(-) (limited to 'src') 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 -- cgit v1.2.3 From d7cb2fd44b7801799401dca343014bbf53ad130c Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Fri, 8 Jul 2016 14:10:34 +0200 Subject: 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(-) (limited to 'src') 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); -- cgit v1.2.3 From 5d8a33a86cb6d852716a9c871576b2f9361a61a1 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Fri, 8 Jul 2016 15:44:39 +0200 Subject: [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(-) (limited to 'src') 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) { -- cgit v1.2.3 From 6bb0bc73c809d1defdcedc31c4c464a129d3de4d Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 14 Jul 2016 09:35:50 +0200 Subject: 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 --- src/plugins/platforms/windows/qwindowscontext.cpp | 3 ++ src/plugins/platforms/windows/qwindowstheme.cpp | 49 +++++++++++++++++------ src/plugins/platforms/windows/qwindowstheme.h | 5 +++ 3 files changed, 45 insertions(+), 12 deletions(-) (limited to 'src') 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 -- cgit v1.2.3 From 9a00ae8e24a03b25476cc6200bddf4c8fc510733 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 14 Jul 2016 15:00:23 +0200 Subject: 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(-) (limited to 'src') 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) -- cgit v1.2.3 From 34de4f6a157ac10a434b719f41a06b4293023b29 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Thu, 7 Jul 2016 12:08:31 +0200 Subject: 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 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') 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."); } } -- cgit v1.2.3 From 89765ced6e9ce7e20aa1090439869509f86a070a Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 14 Jul 2016 16:19:42 +0200 Subject: 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(-) (limited to 'src') 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 ) { -- cgit v1.2.3