From 7c1326a1c390bb15eaa164f748c947f1df9f542d Mon Sep 17 00:00:00 2001 From: James McDonnell Date: Thu, 14 Apr 2016 16:48:15 -0400 Subject: Ensure -no-pch is effective Have configure add a "CONFIG -= precompile_header" to qmodule.pri when -no-pch is specified. Ensures that Qt is built without precompiled headers (as requested) even if allowing precompiled header use is the default for the toolchain. Parallels changes to Windows configure. Task-number: QTBUG-11545 Change-Id: Iab4021e74c4e9978770e917dff97b976c449dd8b Reviewed-by: Oswald Buddenhagen --- configure | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 9492cb5473..5d02827890 100755 --- a/configure +++ b/configure @@ -96,6 +96,7 @@ for i in "$@"; do done # initialize global variables +CONFIG_SEPARATORS=`printf ' \t'` QMAKE_SWITCHES= QMAKE_VARS= QMAKE_CONFIG= @@ -351,6 +352,21 @@ getXQMakeConf() getSingleQMakeVariable "$1" "$xspecvals" } +testXConfig() +{ + # Put a space on each end of the CONFIG value so that searching for the + # target with whitespace on either side will work even when it's the + # first/last/only item in the CONFIG value. + case \ `getXQMakeConf CONFIG`\ in + *[${CONFIG_SEPARATORS}]$1[${CONFIG_SEPARATORS}]*) + return 0 + ;; + *) + return 1 + ;; + esac +} + compilerSupportsFlag() { cat >conftest.cpp < Date: Thu, 5 May 2016 02:10:24 -0700 Subject: Reorder negative font weight checks in qtWeightFromCFWeight. This fixes a problem that caused the QFont::Thin and QFont::ExtraLight conditions to be unreachable. Change-Id: I62a701c53222edffbddbf868311111374ae5bea8 Reviewed-by: Allan Sandfeld Jensen --- src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm index bcb57368f5..91bf00d1a7 100644 --- a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm +++ b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm @@ -75,12 +75,12 @@ QFont::Weight QCoreTextFontEngine::qtWeightFromCFWeight(float value) return QFont::Medium; if (value == 0.0) return QFont::Normal; - if (value <= -0.4) - return QFont::Light; - if (value <= -0.6) - return QFont::ExtraLight; if (value <= -0.8) return QFont::Thin; + if (value <= -0.6) + return QFont::ExtraLight; + if (value <= -0.4) + return QFont::Light; return QFont::Normal; } -- cgit v1.2.3 From db66629dddfed8e129977bec72a9a3fe0468f466 Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Thu, 5 May 2016 09:50:32 -0700 Subject: Fix crash when using QRawFont with FreeType on OS X. Change-Id: I6ca87188a46e3fe31498ed14fdce2161ecb0c966 Reviewed-by: Gabriel de Dietrich --- src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm index e24f4aac8f..c75bf4cf02 100644 --- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm +++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm @@ -367,7 +367,7 @@ static QByteArray filenameForCFUrl(CFURLRef url) if (!CFURLGetFileSystemRepresentation(url, true, buffer, sizeof(buffer))) { qWarning("QCoreTextFontDatabase::filenameForCFUrl: could not resolve file for URL %s", - qPrintable(QString::fromCFString(CFURLGetString(url)))); + url ? qPrintable(QString::fromCFString(CFURLGetString(url))) : "(null)"); } else { QCFType scheme = CFURLCopyScheme(url); if (QString::fromCFString(scheme) == QLatin1String("qrc")) -- cgit v1.2.3 From 88c4388022de192d2834ffa16b4d5f572993da58 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Mon, 25 Apr 2016 17:02:54 +0200 Subject: tst_QWidget: make it stable on OS X MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch QSKIPs all tests that: - take to much time sitting in some QTRY_VERIFY or similar before failing - result in 'not in fullscreen mode' warning (with PASS) - thus completely flaky. - Where previously determined to not apply to OS X using QT_OS_MAC The intent is to make the test run-time more reasonable, both when running the test locally and on the CI system. Reduce the BLACKLIST - to avoid a 'double elimination' the tests that are skipped now, should not be BLACKLISTed so that we fix them for good. Task-number: QTBUG-52974 Change-Id: I34dc2010d0debc6b5b99f2375a6da902b7a17b29 Reviewed-by: Morten Johan Sørvig --- tests/auto/widgets/kernel/qwidget/BLACKLIST | 14 ----- tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 62 +++++++++++++++++++---- 2 files changed, 53 insertions(+), 23 deletions(-) diff --git a/tests/auto/widgets/kernel/qwidget/BLACKLIST b/tests/auto/widgets/kernel/qwidget/BLACKLIST index 4563da8d48..773f4205af 100644 --- a/tests/auto/widgets/kernel/qwidget/BLACKLIST +++ b/tests/auto/widgets/kernel/qwidget/BLACKLIST @@ -1,10 +1,8 @@ # OSX QTBUG-25300 QTBUG-45502 [normalGeometry] ubuntu-14.04 -osx [saveRestoreGeometry] ubuntu-14.04 -osx [restoreVersion1Geometry] ubuntu-14.04 osx @@ -20,20 +18,12 @@ ubuntu-14.04 ubuntu-14.04 [largerThanScreen_QTBUG30142] ubuntu-14.04 -[windowState] -osx [showMaximized] osx [setGeometry] osx -[stackUnder] -osx [raise] osx -[widgetAt] -osx -[sheetOpacity] -osx [resizeEvent] osx [setWindowGeometry] @@ -50,10 +40,6 @@ osx osx [render_systemClip] osx -[update] -osx -[doubleRepaint] -osx [childAt_unifiedToolBar] osx [showMinimizedKeepsFocus] diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index c2b01ea087..20bdf00292 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -1877,6 +1877,10 @@ void tst_QWidget::activation() void tst_QWidget::windowState() { +#ifdef Q_OS_OSX + QSKIP("QTBUG-52974"); +#endif + if (m_platform == QStringLiteral("xcb")) QSKIP("X11: Many window managers do not support window state properly, which causes this test to fail."); if (m_platform == QStringLiteral("wayland")) @@ -2088,6 +2092,10 @@ void tst_QWidget::showMaximized() void tst_QWidget::showFullScreen() { +#ifdef Q_OS_OSX + QSKIP("QTBUG-52974"); +#endif + if (m_platform == QStringLiteral("wayland")) QSKIP("Wayland: This fails. Figure out why."); QWidget plain; @@ -2447,6 +2455,10 @@ void tst_QWidget::reparent() // Qt/Embedded does it differently. void tst_QWidget::icon() { +#ifdef Q_OS_OSX + QSKIP("QTBUG-52974"); +#endif + QPixmap p(20,20); p.fill(Qt::red); testWidget->setWindowIcon(p); @@ -2498,6 +2510,10 @@ void tst_QWidget::hideWhenFocusWidgetIsChild() void tst_QWidget::normalGeometry() { +#ifdef Q_OS_OSX + QSKIP("QTBUG-52974"); +#endif + if (m_platform == QStringLiteral("wayland")) QSKIP("Wayland: This fails. Figure out why."); QWidget parent; @@ -2848,8 +2864,6 @@ void tst_QWidget::raise() } } -// Cocoa has no Z-Order for views, we hack it, but it results in paint events. -#ifndef QT_OS_MAC void tst_QWidget::lower() { QScopedPointer parent(new QWidget); @@ -2911,12 +2925,13 @@ void tst_QWidget::lower() list2 << child4 << child1 << child2 << child3; QCOMPARE(parent->children(), list2); } -#endif -// Cocoa has no Z-Order for views, we hack it, but it results in paint events. -#ifndef QT_OS_MAC void tst_QWidget::stackUnder() { +#ifdef Q_OS_OSX + QSKIP("QTBUG-52974: Cocoa has no Z-Order for views, we hack it, but it results in paint events."); +#endif + QScopedPointer parent(new QWidget); parent->setObjectName(QLatin1String("stackUnder")); parent->setWindowTitle(parent->objectName()); @@ -2997,7 +3012,6 @@ void tst_QWidget::stackUnder() child->reset(); } } -#endif void drawPolygon(QPaintDevice *dev, int w, int h) { @@ -3086,6 +3100,10 @@ void tst_QWidget::testContentsPropagation() void tst_QWidget::saveRestoreGeometry() { +#ifdef Q_OS_OSX + QSKIP("QTBUG-52974"); +#endif + if (m_platform == QStringLiteral("wayland")) QSKIP("Wayland: This fails. Figure out why."); const QPoint position = m_availableTopLeft + QPoint(100, 100); @@ -3311,6 +3329,10 @@ void tst_QWidget::restoreVersion1Geometry() void tst_QWidget::widgetAt() { +#ifdef Q_OS_OSX + QSKIP("QTBUG-52974"); +#endif + if (m_platform == QStringLiteral("wayland")) QSKIP("Wayland: This fails. Figure out why."); Q_CHECK_PAINTEVENTS @@ -3526,6 +3548,7 @@ void tst_QWidget::testDeletionInEventHandlers() #ifdef Q_OS_OSX void tst_QWidget::sheetOpacity() { + QSKIP("QTBUG-52974: this test will most probably be deleted - to be investigated."); QWidget tmpWindow; QWidget sheet(&tmpWindow, Qt::Sheet); tmpWindow.show(); @@ -4176,6 +4199,10 @@ void tst_QWidget::showHideEventWhileMinimize() void tst_QWidget::update() { +#ifdef Q_OS_OSX + QSKIP("QTBUG-52974"); +#endif + QTest::qWait(10); // Wait for the initStuff to do it's stuff. Q_CHECK_PAINTEVENTS @@ -5165,10 +5192,13 @@ void tst_QWidget::showAndMoveChild() VERIFY_COLOR(parent, QRegion(parent.rect()) - child.geometry(), Qt::red); } -// Cocoa only has rect granularity. -#ifndef QT_OS_MAC + void tst_QWidget::subtractOpaqueSiblings() { +#ifdef Q_OS_OSX + QSKIP("QTBUG-52974: Cocoa only has rect granularity."); +#endif + QWidget w; w.setGeometry(50, 50, 300, 300); @@ -5201,7 +5231,6 @@ void tst_QWidget::subtractOpaqueSiblings() QRegion(medium->geometry().translated(large->pos())) - tall->geometry()); } -#endif void tst_QWidget::deleteStyle() { @@ -5243,6 +5272,10 @@ public slots: void tst_QWidget::multipleToplevelFocusCheck() { +#ifdef Q_OS_OSX + QSKIP("QTBUG-52974"); +#endif + if (m_platform == QStringLiteral("wayland")) QSKIP("Wayland: This fails. Figure out why."); TopLevelFocusCheck w1; @@ -7916,6 +7949,10 @@ void tst_QWidget::sendUpdateRequestImmediately() void tst_QWidget::doubleRepaint() { +#ifdef Q_OS_OSX + QSKIP("QTBUG-52974"); +#endif + #if defined(Q_OS_OSX) if (!macHasAccessToWindowsServer()) QSKIP("Not having window server access causes the wrong number of repaints to be issues"); @@ -9580,6 +9617,10 @@ void tst_QWidget::childAt_unifiedToolBar() void tst_QWidget::taskQTBUG_11373() { +#ifdef Q_OS_OSX + QSKIP("QTBUG-52974"); +#endif + QScopedPointer myWindow(new QMainWindow); QWidget * center = new QWidget(); myWindow -> setCentralWidget(center); @@ -10442,6 +10483,9 @@ public: // when mousing over it. void tst_QWidget::taskQTBUG_27643_enterEvents() { +#ifdef Q_OS_OSX + QSKIP("QTBUG-52974: this test can crash!"); +#endif // Move the mouse cursor to a safe location so it won't interfere QCursor::setPos(m_safeCursorPos); -- cgit v1.2.3 From 11ad50074b57df7559d39a0620a1e1b35d0ac061 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Wed, 27 Apr 2016 08:40:16 +0200 Subject: tst_qudpsocket - remove insignificant BLACKLIST should make it, recent regression in QUdpSocket went unnoticed (first) because of 'insignificant'. We'd like to avoid such regressions in future (again, using BLACKLIST if needed and fixig the real problem then). NB: BLACKLIST in this patch was extended to deal with previously unnoticed failures on Windows and OS X. 'multicast' and related family of of functions on OS X will probably stay like this (seems to be a Darwin's quirk), datagram size related tests - fixed in dev or 5.7 (change is in nativesocket engine, 'bytesAvailable'). Task-number: QTBUG-52714 Change-Id: I039b05935a02983ce1648de449907dfa765f7db7 Reviewed-by: Friedemann Kleint --- tests/auto/network/socket/qudpsocket/BLACKLIST | 12 ++++++++++++ tests/auto/network/socket/qudpsocket/test/test.pro | 2 -- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/auto/network/socket/qudpsocket/BLACKLIST b/tests/auto/network/socket/qudpsocket/BLACKLIST index 3e936aebf6..fb8455e6d3 100644 --- a/tests/auto/network/socket/qudpsocket/BLACKLIST +++ b/tests/auto/network/socket/qudpsocket/BLACKLIST @@ -6,3 +6,15 @@ osx osx [multicast:same bind, group ipv4 address] osx +[writeDatagramToNonExistingPeer] +windows +[asyncReadDatagram] +windows +[multicastLeaveAfterClose] +osx +[readyRead] +osx +[readyReadForEmptyDatagram] +osx +[asyncReadDatagram] +osx diff --git a/tests/auto/network/socket/qudpsocket/test/test.pro b/tests/auto/network/socket/qudpsocket/test/test.pro index 8ad16c652d..e4812416dc 100644 --- a/tests/auto/network/socket/qudpsocket/test/test.pro +++ b/tests/auto/network/socket/qudpsocket/test/test.pro @@ -22,5 +22,3 @@ wince* { } TARGET = tst_qudpsocket - -CONFIG+=insignificant_test # QTBUG-25367, QTBUG-25368 -- cgit v1.2.3 From 18048cae413c8eefefc40d73dd4a7b9005e7d137 Mon Sep 17 00:00:00 2001 From: Vladislav Tronko Date: Fri, 6 May 2016 15:14:31 +0300 Subject: Fix typo in QSqlTableModel documentation Change-Id: I4e9ab7469b028464186d3067759a2cf6fb187b07 Reviewed-by: Mark Brand --- src/sql/models/qsqltablemodel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sql/models/qsqltablemodel.cpp b/src/sql/models/qsqltablemodel.cpp index 740c1b9b5d..6aa2eeb072 100644 --- a/src/sql/models/qsqltablemodel.cpp +++ b/src/sql/models/qsqltablemodel.cpp @@ -494,7 +494,7 @@ QVariant QSqlTableModel::headerData(int section, Qt::Orientation orientation, in \since 5.0 Returns \c true if the model contains modified values that have not been - committed to the datase, otherwise false. + committed to the database, otherwise false. */ bool QSqlTableModel::isDirty() const { -- cgit v1.2.3 From 939b7bfe66221975d3a12a6d0a6dd14d9ad04344 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Mon, 2 May 2016 16:49:44 -0700 Subject: QCocoaMenuBar: set the native item's title Or, "Give Cocoa a Chance to do its Magic" Some menubar items, like the "Edit" menu, get extra items added at some point by Cocoa. Evidence points out to those extra items being added right after the NSMenu holding the menubar is set as the current menubar. At that point, both the child NSMenu and its NSMenuItem (the entry in the menubar) must have their title set. Therefore, we must set the menubar native item's title before QCocoaMenuBar::updateMenuBarImmediately() sets the main menu. Task-number: QTBUG-53085 Change-Id: Idd775cf0e3485739f38363a84cfed8d2db9cb662 Reviewed-by: Jake Petroules Reviewed-by: Liang Qi Reviewed-by: Marko Kangas Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/cocoa/qcocoamenubar.mm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/cocoa/qcocoamenubar.mm b/src/plugins/platforms/cocoa/qcocoamenubar.mm index ac48a0e310..a534d2064e 100644 --- a/src/plugins/platforms/cocoa/qcocoamenubar.mm +++ b/src/plugins/platforms/cocoa/qcocoamenubar.mm @@ -173,7 +173,9 @@ void QCocoaMenuBar::syncMenu(QPlatformMenu *menu) } } - nativeItemForMenu(cocoaMenu).hidden = shouldHide; + NSMenuItem *nativeMenuItem = nativeItemForMenu(cocoaMenu); + nativeMenuItem.title = cocoaMenu->nsMenu().title; + nativeMenuItem.hidden = shouldHide; } NSMenuItem *QCocoaMenuBar::nativeItemForMenu(QCocoaMenu *menu) const -- cgit v1.2.3 From e6c0373421a3239a828969d5c49e5418b1122dd0 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Wed, 27 Apr 2016 13:18:41 -0700 Subject: Cocoa: Clear the backing store pointer when changing window If the geometry is being changed at some point while showing the widget after reparenting, we set the Cocoa frame on the QNSView. This results in Cocoa invalidating the view and calling drawRect: before we get a chance to flush the backing store. This may be an issue if the previous parent toplevel window has been deleted. In that case, the backing store pointer is a dangling one, resulting in a crash. Change-Id: I18b5dd7794a3bde8815daf3f84e4113a37aaea90 Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/cocoa/qnsview.mm | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 4b7b50a265..34c37d8aed 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -284,6 +284,7 @@ static bool _q_dontOverrideCtrlLMB = false; - (void)viewDidMoveToWindow { + m_backingStore = Q_NULLPTR; m_isMenuView = [self.window.className isEqualToString:@"NSCarbonMenuWindow"]; if (self.window) { // This is the case of QWidgetAction's generated QWidget inserted in an NSMenu. -- cgit v1.2.3 From 6eb27afcdfb6df2e620f1ec66196600f0f9ed022 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 19 Apr 2016 13:45:12 -0700 Subject: Cocoa: Add QCocoaWindowPointer This patch extends 5b54c352edbc597ec5283bc9cfdd77906350161f by abstracting the watcher pattern. The class is specialized for QCocoaWindow since it's aware of the QObject sentinel there. We update the usage in QNSWindowHelper and extend it to the forward window (this one is used for mouse coordinate conversion when docking windows). Change-Id: I628415527593daec835bbad1b6e83d13fe7b6703 Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/cocoa/qcocoawindow.h | 39 +++++++++++++++++++++++------ src/plugins/platforms/cocoa/qcocoawindow.mm | 31 +++++++++++++++-------- src/plugins/platforms/cocoa/qnsview.mm | 2 +- 3 files changed, 53 insertions(+), 19 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h index e60ca196ac..9fcb221d37 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.h +++ b/src/plugins/platforms/cocoa/qcocoawindow.h @@ -38,6 +38,7 @@ #include #include +#include #ifndef QT_NO_OPENGL #include "qcocoaglcontext.h" @@ -47,6 +48,32 @@ QT_FORWARD_DECLARE_CLASS(QCocoaWindow) +QT_BEGIN_NAMESPACE + +class QCocoaWindowPointer +{ +public: + void assign(QCocoaWindow *w); + void clear(); + + QCocoaWindow *data() const + { return watcher.isNull() ? Q_NULLPTR : window; } + bool isNull() const + { return watcher.isNull(); } + operator QCocoaWindow*() const + { return data(); } + QCocoaWindow *operator->() const + { return data(); } + QCocoaWindow &operator*() const + { return *data(); } + +private: + QPointer watcher; + QCocoaWindow *window; +}; + +QT_END_NAMESPACE + @class QT_MANGLE_NAMESPACE(QNSWindowHelper); @protocol QNSWindowProtocol @@ -63,14 +90,13 @@ typedef NSWindow QCocoaNSWindow; @interface QT_MANGLE_NAMESPACE(QNSWindowHelper) : NSObject { QCocoaNSWindow *_window; - QCocoaWindow *_platformWindow; + QCocoaWindowPointer _platformWindow; BOOL _grabbingMouse; BOOL _releaseOnMouseUp; - QPointer _watcher; } @property (nonatomic, readonly) QCocoaNSWindow *window; -@property (nonatomic, readonly) QCocoaWindow *platformWindow; +@property (nonatomic, readonly) QCocoaWindowPointer platformWindow; @property (nonatomic) BOOL grabbingMouse; @property (nonatomic) BOOL releaseOnMouseUp; @@ -254,7 +280,7 @@ public: // for QNSView NSView *m_contentView; QNSView *m_qtView; QCocoaNSWindow *m_nsWindow; - QCocoaWindow *m_forwardWindow; + QCocoaWindowPointer m_forwardWindow; // TODO merge to one variable if possible bool m_contentViewIsEmbedded; // true if the m_contentView is actually embedded in a "foreign" NSView hiearchy @@ -317,9 +343,8 @@ public: // for QNSView QHash m_contentBorderAreas; // identifer -> uppper/lower QHash m_enabledContentBorderAreas; // identifer -> enabled state (true/false) - // This object is tracked by a 'watcher' - // object in a window helper, preventing use of dangling - // pointers. + // This object is tracked by QCocoaWindowPointer, + // preventing the use of dangling pointers. QObject sentinel; }; diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 12e85c5205..dd67946a27 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -85,7 +85,7 @@ static bool isMouseEvent(NSEvent *ev) self = [super init]; if (self) { _window = window; - _platformWindow = platformWindow; + _platformWindow.assign(platformWindow); _window.delegate = [[QNSWindowDelegate alloc] initWithQCocoaWindow:_platformWindow]; @@ -94,7 +94,6 @@ static bool isMouseEvent(NSEvent *ev) // make sure that m_nsWindow stays valid until the // QCocoaWindow is deleted by Qt. [_window setReleasedWhenClosed:NO]; - _watcher = &_platformWindow->sentinel; } return self; @@ -103,19 +102,19 @@ static bool isMouseEvent(NSEvent *ev) - (void)handleWindowEvent:(NSEvent *)theEvent { QCocoaWindow *pw = self.platformWindow; - if (_watcher && pw && pw->m_forwardWindow) { + if (pw && pw->m_forwardWindow) { if (theEvent.type == NSLeftMouseUp || theEvent.type == NSLeftMouseDragged) { QNSView *forwardView = pw->m_qtView; if (theEvent.type == NSLeftMouseUp) { [forwardView mouseUp:theEvent]; - pw->m_forwardWindow = 0; + pw->m_forwardWindow.clear(); } else { [forwardView mouseDragged:theEvent]; } } if (!pw->m_isNSWindowChild && theEvent.type == NSLeftMouseDown) { - pw->m_forwardWindow = 0; + pw->m_forwardWindow.clear(); } } @@ -142,7 +141,7 @@ static bool isMouseEvent(NSEvent *ev) if (!self.window.delegate) return; // Already detached, pending NSAppKitDefined event - if (_watcher && pw && pw->frameStrutEventsEnabled() && isMouseEvent(theEvent)) { + if (pw && pw->frameStrutEventsEnabled() && isMouseEvent(theEvent)) { NSPoint loc = [theEvent locationInWindow]; NSRect windowFrame = [self.window convertRectFromScreen:[self.window frame]]; NSRect contentFrame = [[self.window contentView] frame]; @@ -157,8 +156,7 @@ static bool isMouseEvent(NSEvent *ev) - (void)detachFromPlatformWindow { - _platformWindow = 0; - _watcher.clear(); + self.platformWindow.clear(); [self.window.delegate release]; self.window.delegate = nil; } @@ -179,7 +177,7 @@ static bool isMouseEvent(NSEvent *ev) - (void)dealloc { _window = nil; - _platformWindow = 0; + self.platformWindow.clear(); [super dealloc]; } @@ -331,6 +329,18 @@ static bool isMouseEvent(NSEvent *ev) @end +void QCocoaWindowPointer::assign(QCocoaWindow *w) +{ + window = w; + watcher = &w->sentinel; +} + +void QCocoaWindowPointer::clear() +{ + window = Q_NULLPTR; + watcher.clear(); +} + const int QCocoaWindow::NoAlertRequest = -1; QCocoaWindow::QCocoaWindow(QWindow *tlw) @@ -338,7 +348,6 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw) , m_contentView(nil) , m_qtView(nil) , m_nsWindow(0) - , m_forwardWindow(0) , m_contentViewIsEmbedded(false) , m_contentViewIsToBeEmbedded(false) , m_parentCocoaWindow(0) @@ -1320,7 +1329,7 @@ void QCocoaWindow::recreateWindow(const QPlatformWindow *parentWindow) if (oldParentCocoaWindow) { if (!m_isNSWindowChild || oldParentCocoaWindow != m_parentCocoaWindow) oldParentCocoaWindow->removeChildWindow(this); - m_forwardWindow = oldParentCocoaWindow; + m_forwardWindow.assign(oldParentCocoaWindow); } setNSWindow(m_nsWindow); diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 34c37d8aed..0d58faa5bf 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -741,7 +741,7 @@ QT_WARNING_POP if (theEvent.type == NSLeftMouseDragged || theEvent.type == NSLeftMouseUp) targetView = m_platformWindow->m_forwardWindow->m_qtView; else - m_platformWindow->m_forwardWindow = 0; + m_platformWindow->m_forwardWindow.clear(); } // Popups implicitly grap mouse events; forward to the active popup if there is one -- cgit v1.2.3 From ee516381873857e833b53b175fd3c40e4c45a5fd Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 6 May 2016 12:19:46 +0200 Subject: Windows Accessibility: Recurse up to find a window. Not all classes inheriting QAccessibleInterface implement QAccessibleInterface::window(), so, go up the hierarchy to find one that does. The window is required to be able to determine the correct scale factor for the screen when High DPI scaling is active. Fixes multimonitor issues for QtWidgets. Amends change d7a3b6145999d015997e26e12a7345f774b053f3. Task-number: QTBUG-52943 Change-Id: I81733765faee4d296bd6ea046bc2cecb018eb28d Reviewed-by: Frederik Gladhorn --- .../platforms/windows/accessible/qwindowsmsaaaccessible.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp b/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp index 5ca83fa9f2..71c197a32c 100644 --- a/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp +++ b/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp @@ -470,6 +470,15 @@ HRESULT STDMETHODCALLTYPE QWindowsMsaaAccessible::Invoke(long dispIdMember, return hr; } +static const QWindow *windowOf(const QAccessibleInterface *ai) +{ + for ( ; ai; ai = ai->parent()) { + if (const QWindow *window = ai->window()) + return window; + } + return Q_NULLPTR; +} + /* IAccessible @@ -498,7 +507,7 @@ HRESULT STDMETHODCALLTYPE QWindowsMsaaAccessible::accHitTest(long xLeft, long yT if (!accessible) return E_FAIL; - const QPoint pos = QHighDpi::fromNativeLocalPosition(QPoint(xLeft, yTop), accessible->window()); + const QPoint pos = QHighDpi::fromNativeLocalPosition(QPoint(xLeft, yTop), windowOf(accessible)); QAccessibleInterface *child = accessible->childAt(pos.x(), pos.y()); if (child == 0) { // no child found, return this item if it contains the coordinates @@ -541,7 +550,7 @@ HRESULT STDMETHODCALLTYPE QWindowsMsaaAccessible::accLocation(long *pxLeft, long QAccessibleInterface *acc = childPointer(accessible, varID); if (!acc || !acc->isValid()) return E_FAIL; - const QRect rect = QHighDpi::toNativePixels(acc->rect(), accessible->window()); + const QRect rect = QHighDpi::toNativePixels(acc->rect(), windowOf(accessible)); *pxLeft = rect.x(); *pyTop = rect.y(); -- cgit v1.2.3 From 558c5c849cfd594c9e1cfb6edaffa0b524c852e9 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 6 May 2016 11:20:49 +0200 Subject: QAccessibleWidget: Retrieve window from native parent widget. Query the native parent widget if the widget does not have a window handle. The window is required to be able to determine the correct scale factor for the screen when High DPI scaling is active. Change-Id: Ibaf5e8e7b07327ea635d2f726acea76c2c95bda3 Task-number: QTBUG-52943 Reviewed-by: Frederik Gladhorn --- src/widgets/accessible/qaccessiblewidget.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/widgets/accessible/qaccessiblewidget.cpp b/src/widgets/accessible/qaccessiblewidget.cpp index 3a9422cc26..beff27ad64 100644 --- a/src/widgets/accessible/qaccessiblewidget.cpp +++ b/src/widgets/accessible/qaccessiblewidget.cpp @@ -206,8 +206,14 @@ bool QAccessibleWidget::isValid() const /*! \reimp */ QWindow *QAccessibleWidget::window() const { - Q_ASSERT(widget()); - return widget()->windowHandle(); + const QWidget *w = widget(); + Q_ASSERT(w); + QWindow *result = w->windowHandle(); + if (!result) { + if (const QWidget *nativeParent = w->nativeParentWidget()) + result = nativeParent->windowHandle(); + } + return result; } /*! -- cgit v1.2.3 From 2c90973ebfd1ce61b4815bcef8a9ffc19f309f1a Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 6 May 2016 11:23:25 +0200 Subject: QAccessibleMenuItem: Implement QAccessibleInterface::window(). The window is required to be able to determine the correct scale factor for the screen when High DPI scaling is active. Change-Id: I8f776684396d055754093f62e0d33bd7e23cb52b Task-number: QTBUG-52943 Reviewed-by: Frederik Gladhorn --- src/widgets/accessible/qaccessiblemenu.cpp | 14 ++++++++++++++ src/widgets/accessible/qaccessiblemenu_p.h | 2 ++ 2 files changed, 16 insertions(+) diff --git a/src/widgets/accessible/qaccessiblemenu.cpp b/src/widgets/accessible/qaccessiblemenu.cpp index a0a7852851..106f724464 100644 --- a/src/widgets/accessible/qaccessiblemenu.cpp +++ b/src/widgets/accessible/qaccessiblemenu.cpp @@ -225,6 +225,20 @@ QObject *QAccessibleMenuItem::object() const return m_action; } +/*! \reimp */ +QWindow *QAccessibleMenuItem::window() const +{ + QWindow *result = Q_NULLPTR; + if (!m_owner.isNull()) { + result = m_owner->windowHandle(); + if (!result) { + if (const QWidget *nativeParent = m_owner->nativeParentWidget()) + result = nativeParent->windowHandle(); + } + } + return result; +} + QRect QAccessibleMenuItem::rect() const { QRect rect; diff --git a/src/widgets/accessible/qaccessiblemenu_p.h b/src/widgets/accessible/qaccessiblemenu_p.h index b42c852ff1..c51597bf1f 100644 --- a/src/widgets/accessible/qaccessiblemenu_p.h +++ b/src/widgets/accessible/qaccessiblemenu_p.h @@ -108,6 +108,8 @@ public: QAccessibleInterface *parent() const Q_DECL_OVERRIDE; QAccessibleInterface *child(int index) const Q_DECL_OVERRIDE; QObject * object() const Q_DECL_OVERRIDE; + QWindow *window() const Q_DECL_OVERRIDE; + QRect rect() const Q_DECL_OVERRIDE; QAccessible::Role role() const Q_DECL_OVERRIDE; void setText(QAccessible::Text t, const QString & text) Q_DECL_OVERRIDE; -- cgit v1.2.3 From 1c2210b7b1ecae021d46c8e5a3cb4a53986067c4 Mon Sep 17 00:00:00 2001 From: Lorn Potter Date: Fri, 15 Jan 2016 15:45:27 +1000 Subject: make sure QNAM reacts to configuration changes Task-number: QTBUG-49760 Change-Id: Ic52fc9f7999f3dd00ef4022c959361782bd1ccd2 Reviewed-by: Markus Goetz (Woboq GmbH) --- src/network/access/qnetworkaccessmanager.cpp | 101 +++++++++++++++++++++------ src/network/access/qnetworkaccessmanager.h | 2 + src/network/access/qnetworkaccessmanager_p.h | 5 ++ 3 files changed, 86 insertions(+), 22 deletions(-) diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp index 28553e19e6..d023228fd2 100644 --- a/src/network/access/qnetworkaccessmanager.cpp +++ b/src/network/access/qnetworkaccessmanager.cpp @@ -474,6 +474,9 @@ QNetworkAccessManager::QNetworkAccessManager(QObject *parent) // connect(&d->networkConfigurationManager, SIGNAL(onlineStateChanged(bool)), SLOT(_q_onlineStateChanged(bool))); + connect(&d->networkConfigurationManager, SIGNAL(configurationChanged(const QNetworkConfiguration &)), + SLOT(_q_configurationChanged(const QNetworkConfiguration &))); + #endif } @@ -1564,6 +1567,8 @@ void QNetworkAccessManagerPrivate::createSession(const QNetworkConfiguration &co QObject::disconnect(networkSessionStrongRef.data(), SIGNAL(closed()), q, SLOT(_q_networkSessionClosed())); QObject::disconnect(networkSessionStrongRef.data(), SIGNAL(stateChanged(QNetworkSession::State)), q, SLOT(_q_networkSessionStateChanged(QNetworkSession::State))); + QObject::disconnect(networkSessionStrongRef.data(), SIGNAL(error(QNetworkSession::SessionError)), + q, SLOT(_q_networkSessionFailed(QNetworkSession::SessionError))); } //switch to new session (null if config was invalid) @@ -1571,7 +1576,6 @@ void QNetworkAccessManagerPrivate::createSession(const QNetworkConfiguration &co networkSessionWeakRef = networkSessionStrongRef.toWeakRef(); if (!networkSessionStrongRef) { - online = false; if (networkAccessible == QNetworkAccessManager::NotAccessible || !online) emit q->networkAccessibleChanged(QNetworkAccessManager::NotAccessible); @@ -1587,6 +1591,8 @@ void QNetworkAccessManagerPrivate::createSession(const QNetworkConfiguration &co QObject::connect(networkSessionStrongRef.data(), SIGNAL(closed()), q, SLOT(_q_networkSessionClosed()), Qt::QueuedConnection); QObject::connect(networkSessionStrongRef.data(), SIGNAL(stateChanged(QNetworkSession::State)), q, SLOT(_q_networkSessionStateChanged(QNetworkSession::State)), Qt::QueuedConnection); + QObject::connect(networkSessionStrongRef.data(), SIGNAL(error(QNetworkSession::SessionError)), + q, SLOT(_q_networkSessionFailed(QNetworkSession::SessionError))); _q_networkSessionStateChanged(networkSessionStrongRef->state()); } @@ -1603,6 +1609,9 @@ void QNetworkAccessManagerPrivate::_q_networkSessionClosed() QObject::disconnect(networkSession.data(), SIGNAL(closed()), q, SLOT(_q_networkSessionClosed())); QObject::disconnect(networkSession.data(), SIGNAL(stateChanged(QNetworkSession::State)), q, SLOT(_q_networkSessionStateChanged(QNetworkSession::State))); + QObject::disconnect(networkSessionStrongRef.data(), SIGNAL(error(QNetworkSession::SessionError)), + q, SLOT(_q_networkSessionFailed(QNetworkSession::SessionError))); + networkSessionStrongRef.clear(); networkSessionWeakRef.clear(); } @@ -1611,46 +1620,56 @@ void QNetworkAccessManagerPrivate::_q_networkSessionClosed() void QNetworkAccessManagerPrivate::_q_networkSessionStateChanged(QNetworkSession::State state) { Q_Q(QNetworkAccessManager); - + bool reallyOnline = false; //Do not emit the networkSessionConnected signal here, except for roaming -> connected //transition, otherwise it is emitted twice in a row when opening a connection. - if (state == QNetworkSession::Connected && lastSessionState == QNetworkSession::Roaming) + if (state == QNetworkSession::Connected && lastSessionState != QNetworkSession::Roaming) emit q->networkSessionConnected(); lastSessionState = state; - if (online) { + if (online && state == QNetworkSession::Disconnected) { + Q_FOREACH (const QNetworkConfiguration &cfg, networkConfigurationManager.allConfigurations()) { + if (cfg.state().testFlag(QNetworkConfiguration::Active)) { + reallyOnline = true; + } + } + } else if (state == QNetworkSession::Connected || state == QNetworkSession::Roaming) { + reallyOnline = true; + } + + if (!reallyOnline) { if (state != QNetworkSession::Connected && state != QNetworkSession::Roaming) { - online = false; if (networkAccessible != QNetworkAccessManager::NotAccessible) { networkAccessible = QNetworkAccessManager::NotAccessible; emit q->networkAccessibleChanged(networkAccessible); } } } else { - if (state == QNetworkSession::Connected || state == QNetworkSession::Roaming) { - online = true; - if (defaultAccessControl) - if (networkAccessible != QNetworkAccessManager::Accessible) { - networkAccessible = QNetworkAccessManager::Accessible; - emit q->networkAccessibleChanged(networkAccessible); - } - } + if (defaultAccessControl) + if (networkAccessible != QNetworkAccessManager::Accessible) { + networkAccessible = QNetworkAccessManager::Accessible; + emit q->networkAccessibleChanged(networkAccessible); + } + } + online = reallyOnline; + if (online && (state != QNetworkSession::Connected && state != QNetworkSession::Roaming)) { + _q_networkSessionClosed(); + createSession(q->configuration()); } } void QNetworkAccessManagerPrivate::_q_onlineStateChanged(bool isOnline) { Q_Q(QNetworkAccessManager); + // if the user set a config, we only care whether this one is active. // Otherwise, this QNAM is online if there is an online config. if (customNetworkConfiguration) { online = (networkConfiguration.state() & QNetworkConfiguration::Active); } else { if (online != isOnline) { - if (isOnline) { - networkSessionStrongRef.clear(); - networkSessionWeakRef.clear(); - } + _q_networkSessionClosed(); + createSession(q->configuration()); online = isOnline; } } @@ -1661,11 +1680,6 @@ void QNetworkAccessManagerPrivate::_q_onlineStateChanged(bool isOnline) emit q->networkAccessibleChanged(networkAccessible); } } - } else if (networkConfiguration.state().testFlag(QNetworkConfiguration::Undefined)) { - if (networkAccessible != QNetworkAccessManager::UnknownAccessibility) { - networkAccessible = QNetworkAccessManager::UnknownAccessibility; - emit q->networkAccessibleChanged(networkAccessible); - } } else { if (networkAccessible != QNetworkAccessManager::NotAccessible) { networkAccessible = QNetworkAccessManager::NotAccessible; @@ -1674,6 +1688,49 @@ void QNetworkAccessManagerPrivate::_q_onlineStateChanged(bool isOnline) } } +void QNetworkAccessManagerPrivate::_q_configurationChanged(const QNetworkConfiguration &configuration) +{ + const QString id = configuration.identifier(); + if (configuration.state().testFlag(QNetworkConfiguration::Active)) { + if (!onlineConfigurations.contains(id)) { + + QSharedPointer session(getNetworkSession()); + if (session) { + if (online && session->configuration().identifier() + != networkConfigurationManager.defaultConfiguration().identifier()) { + + onlineConfigurations.insert(id); + //this one disconnected but another one is online, + // close and create new session + _q_networkSessionClosed(); + createSession(networkConfigurationManager.defaultConfiguration()); + } + } + } + + } else if (onlineConfigurations.contains(id)) { + //this one is disconnecting + onlineConfigurations.remove(id); + if (!onlineConfigurations.isEmpty()) { + _q_networkSessionClosed(); + createSession(configuration); + } + } +} + + +void QNetworkAccessManagerPrivate::_q_networkSessionFailed(QNetworkSession::SessionError) +{ + Q_FOREACH (const QNetworkConfiguration &cfg, networkConfigurationManager.allConfigurations()) { + if (cfg.state().testFlag(QNetworkConfiguration::Active)) { + online = true; + _q_networkSessionClosed(); + createSession(networkConfigurationManager.defaultConfiguration()); + return; + } + } +} + #endif // QT_NO_BEARERMANAGEMENT QNetworkRequest QNetworkAccessManagerPrivate::prepareMultipart(const QNetworkRequest &request, QHttpMultiPart *multiPart) diff --git a/src/network/access/qnetworkaccessmanager.h b/src/network/access/qnetworkaccessmanager.h index c8df213ead..908d327e63 100644 --- a/src/network/access/qnetworkaccessmanager.h +++ b/src/network/access/qnetworkaccessmanager.h @@ -176,6 +176,8 @@ private: Q_PRIVATE_SLOT(d_func(), void _q_networkSessionClosed()) Q_PRIVATE_SLOT(d_func(), void _q_networkSessionStateChanged(QNetworkSession::State)) Q_PRIVATE_SLOT(d_func(), void _q_onlineStateChanged(bool)) + Q_PRIVATE_SLOT(d_func(), void _q_configurationChanged(const QNetworkConfiguration &)) + Q_PRIVATE_SLOT(d_func(), void _q_networkSessionFailed(QNetworkSession::SessionError)) #endif }; diff --git a/src/network/access/qnetworkaccessmanager_p.h b/src/network/access/qnetworkaccessmanager_p.h index 3fc33b5c15..2528249d17 100644 --- a/src/network/access/qnetworkaccessmanager_p.h +++ b/src/network/access/qnetworkaccessmanager_p.h @@ -143,6 +143,11 @@ public: bool isSeamless); void _q_networkSessionStateChanged(QNetworkSession::State state); void _q_onlineStateChanged(bool isOnline); + void _q_configurationChanged(const QNetworkConfiguration &configuration); + void _q_networkSessionFailed(QNetworkSession::SessionError error); + + QSet onlineConfigurations; + #endif QNetworkRequest prepareMultipart(const QNetworkRequest &request, QHttpMultiPart *multiPart); -- cgit v1.2.3 From e1d0da65261077bfd720887d6e6216497abb4c5f Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 13 Apr 2016 12:36:28 -0700 Subject: Fix Clang -Wexpansion-to-defined warning by deprecating QT_SUPPORTS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The C and C++ standards say it's undefined whether the preprocessor supports macros that expand to defined() will operate as an ifdef. Clang 3.9 started complaining about that fact. One solution was to change QT_SUPPORTS to check for zero or one, which means we need to change the #defines QT_NO_xxx to #define QT_NO_xxx 1. The C standard says we don't need to #define to 0, as an unknown token is interpreted as zero. However, that might produce a warning (GCC with -Wundef), so changing the macro this way is not recommended. Instead, we deprecate the macro and replace the uses with #ifdef/ndef. Change-Id: Id75834dab9ed466e94c7ffff1444874d5680b96a Reviewed-by: Olivier Goffart (Woboq GmbH) Reviewed-by: Thiago Macieira --- src/corelib/global/qglobal.h | 3 +++ src/corelib/tools/qarraydata.cpp | 6 ++--- src/corelib/tools/qarraydata.h | 4 +-- src/corelib/tools/qarraydatapointer.h | 2 +- src/corelib/tools/qcontiguouscache.h | 2 +- src/corelib/tools/qhash.h | 2 +- src/corelib/tools/qlinkedlist.h | 2 +- src/corelib/tools/qlist.h | 2 +- src/corelib/tools/qmap.h | 2 +- src/corelib/tools/qrefcount.h | 6 ++--- src/corelib/tools/qset.h | 2 +- src/corelib/tools/qvector.h | 8 +++--- tests/auto/corelib/tools/qarraydata/simplevector.h | 2 +- .../corelib/tools/qarraydata/tst_qarraydata.cpp | 30 +++++++++++----------- tests/auto/corelib/tools/qhash/tst_qhash.cpp | 2 +- .../corelib/tools/qlinkedlist/tst_qlinkedlist.cpp | 4 +-- tests/auto/corelib/tools/qlist/tst_qlist.cpp | 6 ++--- tests/auto/corelib/tools/qmap/tst_qmap.cpp | 4 +-- tests/auto/corelib/tools/qvector/tst_qvector.cpp | 22 ++++++++-------- 19 files changed, 57 insertions(+), 54 deletions(-) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 5bb1ce77bd..a7183cb983 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -55,6 +55,9 @@ #include #endif +// The QT_SUPPORTS macro is deprecated. Don't use it in new code. +// Instead, use #ifdef/ndef QT_NO_feature. +// ### Qt6: remove macro #ifdef _MSC_VER # define QT_SUPPORTS(FEATURE) (!defined QT_NO_##FEATURE) #else diff --git a/src/corelib/tools/qarraydata.cpp b/src/corelib/tools/qarraydata.cpp index fa6556f7d9..eb6ce21282 100644 --- a/src/corelib/tools/qarraydata.cpp +++ b/src/corelib/tools/qarraydata.cpp @@ -65,7 +65,7 @@ QArrayData *QArrayData::allocate(size_t objectSize, size_t alignment, // Don't allocate empty headers if (!(options & RawData) && !capacity) { -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) if (options & Unsharable) return const_cast(&qt_array_unsharable_empty); #endif @@ -110,7 +110,7 @@ QArrayData *QArrayData::allocate(size_t objectSize, size_t alignment, quintptr data = (quintptr(header) + sizeof(QArrayData) + alignment - 1) & ~(alignment - 1); -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) header->ref.atomic.store(bool(!(options & Unsharable))); #else header->ref.atomic.store(1); @@ -132,7 +132,7 @@ void QArrayData::deallocate(QArrayData *data, size_t objectSize, && !(alignment & (alignment - 1))); Q_UNUSED(objectSize) Q_UNUSED(alignment) -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) if (data == &qt_array_unsharable_empty) return; #endif diff --git a/src/corelib/tools/qarraydata.h b/src/corelib/tools/qarraydata.h index 865bd4325d..cbbfe1bea2 100644 --- a/src/corelib/tools/qarraydata.h +++ b/src/corelib/tools/qarraydata.h @@ -72,7 +72,7 @@ struct Q_CORE_EXPORT QArrayData enum AllocationOption { CapacityReserved = 0x1, -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) Unsharable = 0x2, #endif RawData = 0x4, @@ -249,7 +249,7 @@ struct QTypedArrayData return allocate(/* capacity */ 0); } -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) static QTypedArrayData *unsharableEmpty() { Q_STATIC_ASSERT(sizeof(QTypedArrayData) == sizeof(QArrayData)); diff --git a/src/corelib/tools/qarraydatapointer.h b/src/corelib/tools/qarraydatapointer.h index 9804d2c2d5..615d7c5f80 100644 --- a/src/corelib/tools/qarraydatapointer.h +++ b/src/corelib/tools/qarraydatapointer.h @@ -127,7 +127,7 @@ public: return (!d->isMutable() || d->ref.isShared()); } -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) void setSharable(bool sharable) { if (needsDetach()) { diff --git a/src/corelib/tools/qcontiguouscache.h b/src/corelib/tools/qcontiguouscache.h index 41d198f9bc..d546e949c2 100644 --- a/src/corelib/tools/qcontiguouscache.h +++ b/src/corelib/tools/qcontiguouscache.h @@ -96,7 +96,7 @@ public: inline void detach() { if (d->ref.load() != 1) detach_helper(); } inline bool isDetached() const { return d->ref.load() == 1; } -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) inline void setSharable(bool sharable) { if (!sharable) detach(); d->sharable = sharable; } #endif diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h index a18dd74706..a5bde40fb8 100644 --- a/src/corelib/tools/qhash.h +++ b/src/corelib/tools/qhash.h @@ -266,7 +266,7 @@ public: inline void detach() { if (d->ref.isShared()) detach_helper(); } inline bool isDetached() const { return !d->ref.isShared(); } -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) inline void setSharable(bool sharable) { if (!sharable) detach(); if (d != &QHashData::shared_null) d->sharable = sharable; } #endif bool isSharedWith(const QHash &other) const { return d == other.d; } diff --git a/src/corelib/tools/qlinkedlist.h b/src/corelib/tools/qlinkedlist.h index 110529d843..710bf5a9f2 100644 --- a/src/corelib/tools/qlinkedlist.h +++ b/src/corelib/tools/qlinkedlist.h @@ -99,7 +99,7 @@ public: inline void detach() { if (d->ref.isShared()) detach_helper2(this->e); } inline bool isDetached() const { return !d->ref.isShared(); } -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) inline void setSharable(bool sharable) { if (!sharable) detach(); if (d != &QLinkedListData::shared_null) d->sharable = sharable; } #endif inline bool isSharedWith(const QLinkedList &other) const { return d == other.d; } diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index e04a6be1ab..381875e96f 100644 --- a/src/corelib/tools/qlist.h +++ b/src/corelib/tools/qlist.h @@ -169,7 +169,7 @@ public: } inline bool isDetached() const { return !d->ref.isShared(); } -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) inline void setSharable(bool sharable) { if (sharable == d->ref.isSharable()) diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h index ed49e70f4e..7b5a643a1e 100644 --- a/src/corelib/tools/qmap.h +++ b/src/corelib/tools/qmap.h @@ -359,7 +359,7 @@ public: inline void detach() { if (d->ref.isShared()) detach_helper(); } inline bool isDetached() const { return !d->ref.isShared(); } -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) inline void setSharable(bool sharable) { if (sharable == d->ref.isSharable()) diff --git a/src/corelib/tools/qrefcount.h b/src/corelib/tools/qrefcount.h index a390989e76..bff6885d65 100644 --- a/src/corelib/tools/qrefcount.h +++ b/src/corelib/tools/qrefcount.h @@ -47,7 +47,7 @@ class RefCount public: inline bool ref() Q_DECL_NOTHROW { int count = atomic.load(); -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) if (count == 0) // !isSharable return false; #endif @@ -58,7 +58,7 @@ public: inline bool deref() Q_DECL_NOTHROW { int count = atomic.load(); -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) if (count == 0) // !isSharable return false; #endif @@ -67,7 +67,7 @@ public: return atomic.deref(); } -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) bool setSharable(bool sharable) Q_DECL_NOTHROW { Q_ASSERT(!isShared()); diff --git a/src/corelib/tools/qset.h b/src/corelib/tools/qset.h index 3f4208e8b3..7e7eb5210c 100644 --- a/src/corelib/tools/qset.h +++ b/src/corelib/tools/qset.h @@ -79,7 +79,7 @@ public: inline void detach() { q_hash.detach(); } inline bool isDetached() const { return q_hash.isDetached(); } -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) inline void setSharable(bool sharable) { q_hash.setSharable(sharable); } #endif diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index 691872cb36..3154220634 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -100,7 +100,7 @@ public: inline void detach(); inline bool isDetached() const { return !d->ref.isShared(); } -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) inline void setSharable(bool sharable) { if (sharable == d->ref.isSharable()) @@ -376,7 +376,7 @@ template void QVector::detach() { if (!isDetached()) { -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) if (!d->alloc) d = Data::unsharableEmpty(); else @@ -533,7 +533,7 @@ void QVector::reallocData(const int asize, const int aalloc, QArrayData::Allo x = Data::allocate(aalloc, options); Q_CHECK_PTR(x); // aalloc is bigger then 0 so it is not [un]sharedEmpty -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) Q_ASSERT(x->ref.isSharable() || options.testFlag(QArrayData::Unsharable)); #endif Q_ASSERT(!x->ref.isStatic()); @@ -601,7 +601,7 @@ void QVector::reallocData(const int asize, const int aalloc, QArrayData::Allo Q_ASSERT(d->data()); Q_ASSERT(uint(d->size) <= d->alloc); -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) Q_ASSERT(d != Data::unsharableEmpty()); #endif Q_ASSERT(aalloc ? d != Data::sharedNull() : d == Data::sharedNull()); diff --git a/tests/auto/corelib/tools/qarraydata/simplevector.h b/tests/auto/corelib/tools/qarraydata/simplevector.h index 091d871e82..9c7e1ae228 100644 --- a/tests/auto/corelib/tools/qarraydata/simplevector.h +++ b/tests/auto/corelib/tools/qarraydata/simplevector.h @@ -93,7 +93,7 @@ public: bool isStatic() const { return d->ref.isStatic(); } bool isShared() const { return d->ref.isShared(); } bool isSharedWith(const SimpleVector &other) const { return d == other.d; } -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) bool isSharable() const { return d->ref.isSharable(); } void setSharable(bool sharable) { d.setSharable(sharable); } #endif diff --git a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp index 31e44bc3ae..31ade26067 100644 --- a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp +++ b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp @@ -44,7 +44,7 @@ struct SharedNullVerifier { Q_ASSERT(QArrayData::shared_null[0].ref.isStatic()); Q_ASSERT(QArrayData::shared_null[0].ref.isShared()); -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) Q_ASSERT(QArrayData::shared_null[0].ref.isSharable()); #endif } @@ -101,7 +101,7 @@ void tst_QArrayData::referenceCounting() QCOMPARE(array.ref.atomic.load(), 1); QVERIFY(!array.ref.isStatic()); -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) QVERIFY(array.ref.isSharable()); #endif @@ -123,7 +123,7 @@ void tst_QArrayData::referenceCounting() // Now would be a good time to free/release allocated data } -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) { // Reference counting initialized to 0 (non-sharable) QArrayData array = { { Q_BASIC_ATOMIC_INITIALIZER(0) }, 0, 0, 0, 0 }; @@ -151,7 +151,7 @@ void tst_QArrayData::referenceCounting() QCOMPARE(array.ref.atomic.load(), -1); QVERIFY(array.ref.isStatic()); -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) QVERIFY(array.ref.isSharable()); #endif @@ -178,7 +178,7 @@ void tst_QArrayData::sharedNullEmpty() QCOMPARE(null->ref.atomic.load(), -1); QCOMPARE(empty->ref.atomic.load(), -1); -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) QVERIFY(null->ref.isSharable()); QVERIFY(empty->ref.isSharable()); #endif @@ -309,7 +309,7 @@ void tst_QArrayData::simpleVector() QVERIFY(!v7.isShared()); QVERIFY(!v8.isShared()); -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) QVERIFY(v1.isSharable()); QVERIFY(v2.isSharable()); QVERIFY(v3.isSharable()); @@ -502,7 +502,7 @@ void tst_QArrayData::simpleVector() for (int i = 0; i < 120; ++i) QCOMPARE(v1[i], v8[i % 10]); -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) { v7.setSharable(true); QVERIFY(v7.isSharable()); @@ -672,7 +672,7 @@ void tst_QArrayData::allocate_data() QArrayData *shared_empty = QArrayData::allocate(0, Q_ALIGNOF(QArrayData), 0); QVERIFY(shared_empty); -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) QArrayData *unsharable_empty = QArrayData::allocate(0, Q_ALIGNOF(QArrayData), 0, QArrayData::Unsharable); QVERIFY(unsharable_empty); #endif @@ -686,7 +686,7 @@ void tst_QArrayData::allocate_data() } options[] = { { "Default", QArrayData::Default, false, true, shared_empty }, { "Reserved", QArrayData::CapacityReserved, true, true, shared_empty }, -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) { "Reserved | Unsharable", QArrayData::CapacityReserved | QArrayData::Unsharable, true, false, unsharable_empty }, @@ -736,7 +736,7 @@ void tst_QArrayData::allocate() else QCOMPARE(data->alloc, uint(capacity)); QCOMPARE(data->capacityReserved, uint(isCapacityReserved)); -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) QFETCH(bool, isSharable); QCOMPARE(data->ref.isSharable(), isSharable); #endif @@ -1316,7 +1316,7 @@ static inline bool arrayIsFilledWith(const QArrayDataPointer &array, void tst_QArrayData::setSharable_data() { -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) QTest::addColumn >("array"); QTest::addColumn("size"); QTest::addColumn("capacity"); @@ -1362,7 +1362,7 @@ void tst_QArrayData::setSharable_data() void tst_QArrayData::setSharable() { -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) QFETCH(QArrayDataPointer, array); QFETCH(size_t, size); QFETCH(size_t, capacity); @@ -1492,7 +1492,7 @@ void fromRawData_impl() QVERIFY((const T *)raw.constBegin() != array); } -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) { // Immutable, unsharable SimpleVector raw = SimpleVector::fromRawData(array, @@ -1578,7 +1578,7 @@ void tst_QArrayData::literals() QVERIFY(v.isStatic()); #endif -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) QVERIFY(v.isSharable()); #endif QCOMPARE((void*)(const char*)(v.constBegin() + v.size()), (void*)(const char*)v.constEnd()); @@ -1629,7 +1629,7 @@ void tst_QArrayData::variadicLiterals() QVERIFY(v.isStatic()); -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) QVERIFY(v.isSharable()); #endif QCOMPARE((const int *)(v.constBegin() + v.size()), (const int *)v.constEnd()); diff --git a/tests/auto/corelib/tools/qhash/tst_qhash.cpp b/tests/auto/corelib/tools/qhash/tst_qhash.cpp index 6a5c6b5670..d485040a14 100644 --- a/tests/auto/corelib/tools/qhash/tst_qhash.cpp +++ b/tests/auto/corelib/tools/qhash/tst_qhash.cpp @@ -1191,7 +1191,7 @@ void tst_QHash::noNeedlessRehashes() void tst_QHash::const_shared_null() { QHash hash2; -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) QHash hash1; hash1.setSharable(false); QVERIFY(hash1.isDetached()); diff --git a/tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp b/tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp index d3ace40164..848fdae445 100644 --- a/tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp +++ b/tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp @@ -1027,7 +1027,7 @@ template void tst_QLinkedList::constSharedNull() const { QLinkedList list2; -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) QLinkedList list1; list1.setSharable(false); QVERIFY(list1.isDetached()); @@ -1059,7 +1059,7 @@ void tst_QLinkedList::constSharedNullComplex() const void tst_QLinkedList::setSharableInt() const { -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) QLinkedList orglist; orglist << 0 << 1 << 2 << 3 << 4 << 5; int size = 6; diff --git a/tests/auto/corelib/tools/qlist/tst_qlist.cpp b/tests/auto/corelib/tools/qlist/tst_qlist.cpp index 1bb31afa9c..87f0012002 100644 --- a/tests/auto/corelib/tools/qlist/tst_qlist.cpp +++ b/tests/auto/corelib/tools/qlist/tst_qlist.cpp @@ -1892,7 +1892,7 @@ template void tst_QList::constSharedNull() const { QList list2; -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) QList list1; list1.setSharable(false); QVERIFY(list1.isDetached()); @@ -1926,7 +1926,7 @@ void tst_QList::constSharedNullComplex() const template void generateSetSharableData() { -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) QTest::addColumn >("list"); QTest::addColumn("size"); @@ -1938,7 +1938,7 @@ void generateSetSharableData() template void runSetSharableTest() { -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) QFETCH(QList, list); QFETCH(int, size); diff --git a/tests/auto/corelib/tools/qmap/tst_qmap.cpp b/tests/auto/corelib/tools/qmap/tst_qmap.cpp index bb6535b635..1fb9dc6d7d 100644 --- a/tests/auto/corelib/tools/qmap/tst_qmap.cpp +++ b/tests/auto/corelib/tools/qmap/tst_qmap.cpp @@ -1012,7 +1012,7 @@ void tst_QMap::qmultimap_specific() void tst_QMap::const_shared_null() { QMap map2; -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) QMap map1; map1.setSharable(false); QVERIFY(map1.isDetached()); @@ -1109,7 +1109,7 @@ const T &const_(const T &t) void tst_QMap::setSharable() { -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) QMap map; map.insert(1, "um"); diff --git a/tests/auto/corelib/tools/qvector/tst_qvector.cpp b/tests/auto/corelib/tools/qvector/tst_qvector.cpp index 87822bca6f..edcf4c72b6 100644 --- a/tests/auto/corelib/tools/qvector/tst_qvector.cpp +++ b/tests/auto/corelib/tools/qvector/tst_qvector.cpp @@ -431,7 +431,7 @@ void tst_QVector::copyConstructor() const QVector v2(v1); QCOMPARE(v1, v2); } -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) // ### Qt6 remove this section { QVector v1; @@ -595,7 +595,7 @@ void tst_QVector::append() const QVERIFY(v.size() == 3); QCOMPARE(v.at(v.size() - 1), SimpleValue::at(0)); } -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) // ### Qt6 remove this section { QVector v(2); @@ -930,7 +930,7 @@ void tst_QVector::eraseEmpty() const v.erase(v.begin(), v.end()); QCOMPARE(v.size(), 0); } -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) // ### Qt6 remove this section { QVector v; @@ -969,7 +969,7 @@ void tst_QVector::eraseEmptyReserved() const v.erase(v.begin(), v.end()); QCOMPARE(v.size(), 0); } -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) // ### Qt6 remove this section { QVector v; @@ -1085,7 +1085,7 @@ void tst_QVector::erase(bool shared) const if (shared) QCOMPARE(SimpleValue::vector(12), *svc.copy); } -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) // ### Qt6 remove this section { QVector v = SimpleValue::vector(10); @@ -1172,7 +1172,7 @@ template void tst_QVector::eraseReserved() const v.erase(v.begin() + 1, v.end() - 1); QCOMPARE(v.size(), 2); } -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) // ### Qt6 remove this section { QVector v(10); @@ -1907,7 +1907,7 @@ void tst_QVector::resizePOD_data() const QTest::newRow("nonEmpty") << nonEmpty << 10; QTest::newRow("nonEmptyReserved") << nonEmptyReserved << 10; -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) // ### Qt6 remove this section QVector nullNotShared; QVector emptyNotShared(0, 5); @@ -1982,7 +1982,7 @@ void tst_QVector::resizeComplexMovable_data() const QTest::newRow("nonEmpty") << nonEmpty << 10; QTest::newRow("nonEmptyReserved") << nonEmptyReserved << 10; -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) // ### Qt6 remove this section QVector nullNotShared; QVector emptyNotShared(0, 'Q'); @@ -2061,7 +2061,7 @@ void tst_QVector::resizeComplex_data() const QTest::newRow("nonEmpty") << nonEmpty << 10; QTest::newRow("nonEmptyReserved") << nonEmptyReserved << 10; -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) // ### Qt6 remove this section QVector nullNotShared; QVector emptyNotShared(0, '0'); @@ -2500,7 +2500,7 @@ void tst_QVector::initializeListCustom() void tst_QVector::const_shared_null() { QVector v2; -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) // ### Qt6 remove this section QVector v1; v1.setSharable(false); @@ -2511,7 +2511,7 @@ void tst_QVector::const_shared_null() QVERIFY(!v2.isDetached()); } -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) // ### Qt6 remove this section template void tst_QVector::setSharable_data() const -- cgit v1.2.3 From 9ba296cc4cefaeb9d6c5abc2e0c0b272f2288733 Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Thu, 5 May 2016 02:12:31 -0700 Subject: Add constants for the CoreText font weights. Incidentally, this corrects two small errors in the values of the Medium and Heavy font weights. Change-Id: I17d4410890f1f3bd1ed72e94f5ca0d43c21484e1 Reviewed-by: Konstantin Ritt --- .../fontdatabases/mac/qfontengine_coretext.mm | 61 ++++++++++++++++++---- 1 file changed, 52 insertions(+), 9 deletions(-) diff --git a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm index 91bf00d1a7..703ec3a8b8 100644 --- a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm +++ b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm @@ -41,6 +41,49 @@ #include +#if defined(Q_OS_OSX) && !QT_OSX_DEPLOYMENT_TARGET_BELOW(__MAC_10_11) +#import +#endif + +#if defined(Q_OS_IOS) && !QT_IOS_DEPLOYMENT_TARGET_BELOW(__IPHONE_8_2) +#import +#endif + +// These are available cross platform, exported as kCTFontWeightXXX from CoreText.framework, +// but they are not documented and are not in public headers so are private API and exposed +// only through the NSFontWeightXXX and UIFontWeightXXX aliases in AppKit and UIKit (rdar://26109857) +#if QT_MAC_DEPLOYMENT_TARGET_BELOW(__MAC_10_11, __IPHONE_8_2) +#define kCTFontWeightUltraLight -0.8 +#define kCTFontWeightThin -0.6 +#define kCTFontWeightLight -0.4 +#define kCTFontWeightRegular 0 +#define kCTFontWeightMedium 0.23 +#define kCTFontWeightSemibold 0.3 +#define kCTFontWeightBold 0.4 +#define kCTFontWeightHeavy 0.56 +#define kCTFontWeightBlack 0.62 +#elif defined(Q_OS_OSX) +#define kCTFontWeightUltraLight NSFontWeightUltraLight +#define kCTFontWeightThin NSFontWeightThin +#define kCTFontWeightLight NSFontWeightLight +#define kCTFontWeightRegular NSFontWeightRegular +#define kCTFontWeightMedium NSFontWeightMedium +#define kCTFontWeightSemibold NSFontWeightSemibold +#define kCTFontWeightBold NSFontWeightBold +#define kCTFontWeightHeavy NSFontWeightHeavy +#define kCTFontWeightBlack NSFontWeightBlack +#elif defined(Q_OS_IOS) +#define kCTFontWeightUltraLight UIFontWeightUltraLight +#define kCTFontWeightThin UIFontWeightThin +#define kCTFontWeightLight UIFontWeightLight +#define kCTFontWeightRegular UIFontWeightRegular +#define kCTFontWeightMedium UIFontWeightMedium +#define kCTFontWeightSemibold UIFontWeightSemibold +#define kCTFontWeightBold UIFontWeightBold +#define kCTFontWeightHeavy UIFontWeightHeavy +#define kCTFontWeightBlack UIFontWeightBlack +#endif + QT_BEGIN_NAMESPACE static float SYNTHETIC_ITALIC_SKEW = std::tan(14.f * std::acos(0.f) / 90.f); @@ -63,23 +106,23 @@ bool QCoreTextFontEngine::ct_getSfntTable(void *user_data, uint tag, uchar *buff QFont::Weight QCoreTextFontEngine::qtWeightFromCFWeight(float value) { - if (value >= 0.62) + if (value >= kCTFontWeightBlack) return QFont::Black; - if (value >= 0.5) + if (value >= kCTFontWeightHeavy) return QFont::ExtraBold; - if (value >= 0.4) + if (value >= kCTFontWeightBold) return QFont::Bold; - if (value >= 0.3) + if (value >= kCTFontWeightSemibold) return QFont::DemiBold; - if (value >= 0.2) + if (value >= kCTFontWeightMedium) return QFont::Medium; - if (value == 0.0) + if (value == kCTFontWeightRegular) return QFont::Normal; - if (value <= -0.8) + if (value <= kCTFontWeightUltraLight) return QFont::Thin; - if (value <= -0.6) + if (value <= kCTFontWeightThin) return QFont::ExtraLight; - if (value <= -0.4) + if (value <= kCTFontWeightLight) return QFont::Light; return QFont::Normal; } -- cgit v1.2.3 From 194a56ea79a4aa11a01dda0491427bb5ba4b37fd Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 1 Dec 2015 17:44:34 -0800 Subject: QTest: Fix printing of values of Q_ENUMs QMetaEnum::key(n) returns the n-th key, which is not necessarily the one of value n. For the key of value n, we want QMetaEnum::valueToKey(n). Change-Id: Ic90fe6b1cbe84978a02fffff141bf4a06074917a Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/testlib/qtestcase.h | 2 +- tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp | 5 +++-- tests/auto/testlib/selftests/expected_cmptest.lightxml | 4 ++-- tests/auto/testlib/selftests/expected_cmptest.txt | 4 ++-- tests/auto/testlib/selftests/expected_cmptest.xml | 4 ++-- tests/auto/testlib/selftests/expected_cmptest.xunitxml | 4 ++-- 6 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/testlib/qtestcase.h b/src/testlib/qtestcase.h index 9d79439e04..14ee0865eb 100644 --- a/src/testlib/qtestcase.h +++ b/src/testlib/qtestcase.h @@ -238,7 +238,7 @@ namespace QTest inline typename QtPrivate::QEnableIf::Value, char*>::Type toString(T e) { QMetaEnum me = QMetaEnum::fromType(); - return qstrdup(me.key(int(e))); // int cast is necessary to support enum classes + return qstrdup(me.valueToKey(int(e))); // int cast is necessary to support enum classes } template // Fallback diff --git a/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp b/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp index 6446fec510..09a90508d3 100644 --- a/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp +++ b/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp @@ -156,8 +156,9 @@ void tst_Cmptest::compare_unregistered_enums() void tst_Cmptest::compare_registered_enums() { - QCOMPARE(Qt::ArrowCursor, Qt::ArrowCursor); - QCOMPARE(Qt::ArrowCursor, Qt::BusyCursor); + // use an enum that doesn't start at 0 + QCOMPARE(Qt::Monday, Qt::Monday); + QCOMPARE(Qt::Monday, Qt::Sunday); } static bool boolfunc() { return true; } diff --git a/tests/auto/testlib/selftests/expected_cmptest.lightxml b/tests/auto/testlib/selftests/expected_cmptest.lightxml index 36929cec6b..8f02e2e1ad 100644 --- a/tests/auto/testlib/selftests/expected_cmptest.lightxml +++ b/tests/auto/testlib/selftests/expected_cmptest.lightxml @@ -16,8 +16,8 @@ + Actual (Qt::Monday): Monday + Expected (Qt::Sunday): Sunday]]> diff --git a/tests/auto/testlib/selftests/expected_cmptest.txt b/tests/auto/testlib/selftests/expected_cmptest.txt index 70c54704f9..9205658509 100644 --- a/tests/auto/testlib/selftests/expected_cmptest.txt +++ b/tests/auto/testlib/selftests/expected_cmptest.txt @@ -4,8 +4,8 @@ PASS : tst_Cmptest::initTestCase() FAIL! : tst_Cmptest::compare_unregistered_enums() Compared values are not the same Loc: [tst_cmptest.cpp(154)] FAIL! : tst_Cmptest::compare_registered_enums() Compared values are not the same - Actual (Qt::ArrowCursor): ArrowCursor - Expected (Qt::BusyCursor) : BusyCursor + Actual (Qt::Monday): Monday + Expected (Qt::Sunday): Sunday Loc: [tst_cmptest.cpp(160)] PASS : tst_Cmptest::compare_boolfuncs() PASS : tst_Cmptest::compare_pointerfuncs() diff --git a/tests/auto/testlib/selftests/expected_cmptest.xml b/tests/auto/testlib/selftests/expected_cmptest.xml index 9437e8e4b7..55a9706227 100644 --- a/tests/auto/testlib/selftests/expected_cmptest.xml +++ b/tests/auto/testlib/selftests/expected_cmptest.xml @@ -18,8 +18,8 @@ + Actual (Qt::Monday): Monday + Expected (Qt::Sunday): Sunday]]> diff --git a/tests/auto/testlib/selftests/expected_cmptest.xunitxml b/tests/auto/testlib/selftests/expected_cmptest.xunitxml index fa970d4172..c26f723cfc 100644 --- a/tests/auto/testlib/selftests/expected_cmptest.xunitxml +++ b/tests/auto/testlib/selftests/expected_cmptest.xunitxml @@ -11,8 +11,8 @@ + Actual (Qt::Monday): Monday + Expected (Qt::Sunday): Sunday" result="fail"/> -- cgit v1.2.3 From 558718ff4406638410364db7c1310cb38963d6df Mon Sep 17 00:00:00 2001 From: Vyacheslav Grigoryev Date: Fri, 6 May 2016 01:29:27 +0300 Subject: QTableView: Fix selection for reordered or hidden rows/columns MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The old code sometimes made incorrect selections when rows or columns were hidden or moved. It used logical top left and bottom right indexes to create a selection rectangle. However on moved or hidden cells a wrong rectangle was made. This fix calculates a simple rectangle without hidden cells and makes use of the row/column select functionality provided by the selection model, to make the right selection. [ChangeLog][QtWidgets][QTableView] Fixed a selection bug when rows or columns were hidden (QTBUG-50171) Task-number: QTBUG-50171 Change-Id: Id186012af26da7b2051ff5eb1c13e6b7494cca77 Reviewed-by: Thorbjørn Lund Martsum --- src/widgets/itemviews/qtableview.cpp | 23 ++++++-------- .../itemviews/qtableview/tst_qtableview.cpp | 36 ++++++++++++++++++++++ 2 files changed, 46 insertions(+), 13 deletions(-) diff --git a/src/widgets/itemviews/qtableview.cpp b/src/widgets/itemviews/qtableview.cpp index ee0d41ce15..b68c105aba 100644 --- a/src/widgets/itemviews/qtableview.cpp +++ b/src/widgets/itemviews/qtableview.cpp @@ -3249,13 +3249,12 @@ void QTableViewPrivate::selectRow(int row, bool anchor) command |= QItemSelectionModel::Current; } - QModelIndex tl = model->index(qMin(rowSectionAnchor, row), logicalColumn(0), root); - QModelIndex br = model->index(qMax(rowSectionAnchor, row), logicalColumn(model->columnCount(root) - 1), root); - if ((verticalHeader->sectionsMoved() && tl.row() != br.row()) - || horizontalHeader->sectionsMoved()) { - q->setSelection(q->visualRect(tl)|q->visualRect(br), command); + QModelIndex upper = model->index(qMin(rowSectionAnchor, row), column, root); + QModelIndex lower = model->index(qMax(rowSectionAnchor, row), column, root); + if ((verticalHeader->sectionsMoved() && upper.row() != lower.row())) { + q->setSelection(q->visualRect(upper) | q->visualRect(lower), command | QItemSelectionModel::Rows); } else { - selectionModel->select(QItemSelection(tl, br), command); + selectionModel->select(QItemSelection(upper, lower), command | QItemSelectionModel::Rows); } } } @@ -3289,14 +3288,12 @@ void QTableViewPrivate::selectColumn(int column, bool anchor) command |= QItemSelectionModel::Current; } - QModelIndex tl = model->index(logicalRow(0), qMin(columnSectionAnchor, column), root); - QModelIndex br = model->index(logicalRow(model->rowCount(root) - 1), - qMax(columnSectionAnchor, column), root); - if ((horizontalHeader->sectionsMoved() && tl.column() != br.column()) - || verticalHeader->sectionsMoved()) { - q->setSelection(q->visualRect(tl)|q->visualRect(br), command); + QModelIndex left = model->index(row, qMin(columnSectionAnchor, column), root); + QModelIndex right = model->index(row, qMax(columnSectionAnchor, column), root); + if ((horizontalHeader->sectionsMoved() && left.column() != right.column())) { + q->setSelection(q->visualRect(left) | q->visualRect(right), command | QItemSelectionModel::Columns); } else { - selectionModel->select(QItemSelection(tl, br), command); + selectionModel->select(QItemSelection(left, right), command | QItemSelectionModel::Columns); } } } diff --git a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp index e5abd6bc46..2bb3f6a136 100644 --- a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp +++ b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp @@ -203,6 +203,7 @@ private slots: void taskQTBUG_8777_scrollToSpans(); void taskQTBUG_10169_sizeHintForRow(); void taskQTBUG_30653_doItemsLayout(); + void taskQTBUG_50171_selectRowAfterSwapColumns(); #ifndef QT_NO_WHEELEVENT void mouseWheel_data(); @@ -4476,5 +4477,40 @@ void tst_QTableView::taskQTBUG_30653_doItemsLayout() QCOMPARE(scrollToBottomOffset, doItemsLayoutOffset); } +void tst_QTableView::taskQTBUG_50171_selectRowAfterSwapColumns() +{ + { + QtTestTableView tableView; + QtTestTableModel model(2, 3); + tableView.setModel(&model); + + tableView.horizontalHeader()->swapSections(1, 2); + tableView.horizontalHeader()->hideSection(0); + tableView.selectRow(1); + + QItemSelectionModel* tableSelectionModel = tableView.selectionModel(); + QCOMPARE(tableSelectionModel->isRowSelected(1, QModelIndex()), true); + QCOMPARE(tableSelectionModel->isSelected(tableView.model()->index(0, 0)), false); + QCOMPARE(tableSelectionModel->isSelected(tableView.model()->index(0, 1)), false); + QCOMPARE(tableSelectionModel->isSelected(tableView.model()->index(0, 2)), false); + } + + { + QtTestTableView tableView; + QtTestTableModel model(3, 2); + tableView.setModel(&model); + + tableView.verticalHeader()->swapSections(1, 2); + tableView.verticalHeader()->hideSection(0); + tableView.selectColumn(1); + + QItemSelectionModel* sModel = tableView.selectionModel(); + QCOMPARE(sModel->isColumnSelected(1, QModelIndex()), true); + QCOMPARE(sModel->isSelected(tableView.model()->index(0, 0)), false); + QCOMPARE(sModel->isSelected(tableView.model()->index(1, 0)), false); + QCOMPARE(sModel->isSelected(tableView.model()->index(2, 0)), false); + } +} + QTEST_MAIN(tst_QTableView) #include "tst_qtableview.moc" -- cgit v1.2.3 From 8de2986a42ff452d2ca7f28d23ce1156be326b62 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 6 May 2016 23:41:14 -0700 Subject: tst_QDBusMarshall: make sure we compile on linked, old dbus If we're linking to libdbus-1, qdbus_symbols_p.h #includes dbus/dbus.h, which may be old and not #define the Unix FD macros. tst_QDBusMarshall had the definition for one of the macros but not the other, so add the missing second one. Change-Id: Id69569111e7d4e619e22ffff144c35edcd6f348b Reviewed-by: Frederik Gladhorn --- tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp b/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp index 57fd5084be..b628738fe3 100644 --- a/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp +++ b/tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall.cpp @@ -41,6 +41,11 @@ #include #include +#ifndef DBUS_TYPE_UNIX_FD +# define DBUS_TYPE_UNIX_FD int('h') +# define DBUS_TYPE_UNIX_FD_AS_STRING "h" +#endif + static const char serviceName[] = "org.qtproject.autotests.qpong"; static const char objectPath[] = "/org/qtproject/qpong"; static const char *interfaceName = serviceName; @@ -1088,9 +1093,6 @@ static bool canSendUnixFd(DBusConnection *connection) can_send_type = (can_send_type_t)qdbus_resolve_conditionally("dbus_connection_can_send_type"); #endif -#ifndef DBUS_TYPE_UNIX_FD -# define DBUS_TYPE_UNIX_FD int('h') -#endif return can_send_type && can_send_type(connection, DBUS_TYPE_UNIX_FD); } -- cgit v1.2.3 From ad66dbe305cff72443f4d3484191872d56e6dfbb Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 27 Apr 2016 22:34:26 -0700 Subject: Disconnect signals from each QObject only once in QDBusConnectionPrivate Because the moment we disconnect from the object's destroyed() signal, it may get destroyed in another thread. If the same object appears more than once in the object tree or in the signal hook table, we could be accessing a dangling pointer. Task-number: QTBUG-52988 Change-Id: Ifea6e497f11a461db432ffff14496f0f83889104 Reviewed-by: Weng Xuetian Reviewed-by: Thiago Macieira --- src/dbus/qdbusconnection_p.h | 2 +- src/dbus/qdbusintegrator.cpp | 31 ++++++++++++++++++++----------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/dbus/qdbusconnection_p.h b/src/dbus/qdbusconnection_p.h index b733a68856..fff9f29b03 100644 --- a/src/dbus/qdbusconnection_p.h +++ b/src/dbus/qdbusconnection_p.h @@ -254,7 +254,7 @@ private: const QVector &metaTypes, int slotIdx); SignalHookHash::Iterator removeSignalHookNoLock(SignalHookHash::Iterator it); - void disconnectObjectTree(ObjectTreeNode &node); + void collectAllObjects(ObjectTreeNode &node, QSet &set); bool isServiceRegisteredByThread(const QString &serviceName); diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index d0468f4af0..147966b9b0 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -1071,17 +1071,18 @@ QDBusConnectionPrivate::~QDBusConnectionPrivate() } } -void QDBusConnectionPrivate::disconnectObjectTree(QDBusConnectionPrivate::ObjectTreeNode &haystack) +void QDBusConnectionPrivate::collectAllObjects(QDBusConnectionPrivate::ObjectTreeNode &haystack, + QSet &set) { QDBusConnectionPrivate::ObjectTreeNode::DataList::Iterator it = haystack.children.begin(); while (it != haystack.children.end()) { - disconnectObjectTree(*it); + collectAllObjects(*it, set); it++; } if (haystack.obj) - haystack.obj->disconnect(this); + set.insert(haystack.obj); } void QDBusConnectionPrivate::closeConnection() @@ -1110,15 +1111,23 @@ void QDBusConnectionPrivate::closeConnection() // Disconnect all signals from signal hooks and from the object tree to // avoid QObject::destroyed being sent to dbus daemon thread which has - // already quit. - SignalHookHash::iterator sit = signalHooks.begin(); - while (sit != signalHooks.end()) { - sit.value().obj->disconnect(this); - sit++; + // already quit. We need to make sure we disconnect exactly once per + // object, because if we tried a second time, we might be hitting a + // dangling pointer. + QSet allObjects; + collectAllObjects(rootNode, allObjects); + SignalHookHash::const_iterator sit = signalHooks.constBegin(); + while (sit != signalHooks.constEnd()) { + allObjects.insert(sit.value().obj); + ++sit; + } + + // now disconnect ourselves + QSet::const_iterator oit = allObjects.constBegin(); + while (oit != allObjects.constEnd()) { + (*oit)->disconnect(this); + ++oit; } - - disconnectObjectTree(rootNode); - rootNode.children.clear(); // free resources } void QDBusConnectionPrivate::handleDBusDisconnection() -- cgit v1.2.3 From 29076cf6cbd22e2e16a730787c79c2734655756e Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 29 Apr 2016 20:52:05 -0700 Subject: Fix QBasicAtomicPointer::{load,store} to actually be relaxed We were using direct loading and operator=, which for everything except std::atomic was very relaxed. But std::atomic defines the direct access to actually be the least relaxed possible, under the idea that if you didn't know any better to use a member function, you probably need the most protection. So use Ops::load and Ops::store. Change-Id: Id5480807d25e49e78b79ffff144a06a2e6398576 Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/thread/qbasicatomic.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/thread/qbasicatomic.h b/src/corelib/thread/qbasicatomic.h index c29b80d3d0..7960174277 100644 --- a/src/corelib/thread/qbasicatomic.h +++ b/src/corelib/thread/qbasicatomic.h @@ -249,8 +249,8 @@ public: AtomicType _q_value; - Type load() const Q_DECL_NOTHROW { return _q_value; } - void store(Type newValue) Q_DECL_NOTHROW { _q_value = newValue; } + Type load() const Q_DECL_NOTHROW { return Ops::load(_q_value); } + void store(Type newValue) Q_DECL_NOTHROW { Ops::store(_q_value, newValue); } operator Type() const Q_DECL_NOTHROW { return loadAcquire(); } Type operator=(Type newValue) Q_DECL_NOTHROW { storeRelease(newValue); return newValue; } -- cgit v1.2.3 From c619fc278d7e5acd8f0ae8f9e2013f351c50c355 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 25 Feb 2013 20:55:03 -0800 Subject: Fix moc warning detected by ICC moc.cpp(385): error #187: use of "=" where "==" may have been intended Change-Id: Ibb6ef27030762cbe4f7c7002581a0955f0f9086d Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/tools/moc/moc.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp index 726d1972f1..7dd94cdca7 100644 --- a/src/tools/moc/moc.cpp +++ b/src/tools/moc/moc.cpp @@ -378,8 +378,8 @@ bool Moc::parseFunction(FunctionDef *def, bool inMacro) def->isVirtual = false; def->isStatic = false; //skip modifiers and attributes - while (test(INLINE) || (test(STATIC) && (def->isStatic = true)) || - (test(VIRTUAL) && (def->isVirtual = true)) //mark as virtual + while (test(INLINE) || (test(STATIC) && (def->isStatic = true) == true) || + (test(VIRTUAL) && (def->isVirtual = true) == true) //mark as virtual || testFunctionAttribute(def) || testFunctionRevision(def)) {} bool templateFunction = (lookup() == TEMPLATE); def->type = parseType(); @@ -473,8 +473,8 @@ bool Moc::parseMaybeFunction(const ClassDef *cdef, FunctionDef *def) def->isVirtual = false; def->isStatic = false; //skip modifiers and attributes - while (test(EXPLICIT) || test(INLINE) || (test(STATIC) && (def->isStatic = true)) || - (test(VIRTUAL) && (def->isVirtual = true)) //mark as virtual + while (test(EXPLICIT) || test(INLINE) || (test(STATIC) && (def->isStatic = true) == true) || + (test(VIRTUAL) && (def->isVirtual = true) == true) //mark as virtual || testFunctionAttribute(def) || testFunctionRevision(def)) {} bool tilde = test(TILDE); def->type = parseType(); -- cgit v1.2.3 From fe23db053a5b3f2097b332ad3269cd0eb5a55168 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 18 Mar 2016 20:29:51 -0700 Subject: Add an autotest for the QtDBus message spy hook There's exactly one application that needs this functionality (kded/ kiod), but we should test it too. Change-Id: Icaa7fb2a490246bda156ffff143d210c6f5f207f Reviewed-by: David Faure --- tests/auto/dbus/dbus.pro | 1 + .../dbus/qdbusconnection/tst_qdbusconnection.cpp | 139 ++++++++++++++++++++- .../dbus/qdbusconnection/tst_qdbusconnection.h | 9 +- .../qdbusconnection_spyhook.pro | 7 ++ .../tst_qdbusconnection_spyhook.cpp | 57 +++++++++ 5 files changed, 211 insertions(+), 2 deletions(-) create mode 100644 tests/auto/dbus/qdbusconnection_spyhook/qdbusconnection_spyhook.pro create mode 100644 tests/auto/dbus/qdbusconnection_spyhook/tst_qdbusconnection_spyhook.cpp diff --git a/tests/auto/dbus/dbus.pro b/tests/auto/dbus/dbus.pro index 67cbc4bfef..c5cddee5f5 100644 --- a/tests/auto/dbus/dbus.pro +++ b/tests/auto/dbus/dbus.pro @@ -11,6 +11,7 @@ SUBDIRS+=\ qdbusconnection_no_app \ qdbusconnection_no_bus \ qdbusconnection_no_libdbus \ + qdbusconnection_spyhook \ qdbuscontext \ qdbusinterface \ qdbuslocalcalls \ diff --git a/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp b/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp index f378091c58..9b16cf74a5 100644 --- a/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp +++ b/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. -** Copyright (C) 2015 Intel Corporation. +** Copyright (C) 2016 Intel Corporation. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. @@ -55,6 +55,31 @@ void MyObjectWithoutInterface::method(const QDBusMessage &msg) //qDebug() << msg; } +int tst_QDBusConnection::hookCallCount; +tst_QDBusConnection::tst_QDBusConnection() +{ +#ifdef HAS_HOOKSETUPFUNCTION +# define QCOMPARE_HOOKCOUNT(n) QCOMPARE(hookCallCount, n); hookCallCount = 0 +# define QVERIFY_HOOKCALLED() QCOMPARE(hookCallCount, 1); hookCallCount = 0 + hookSetupFunction(); +#else +# define QCOMPARE_HOOKCOUNT(n) qt_noop() +# define QVERIFY_HOOKCALLED() qt_noop() +#endif +} + +// called before each testcase +void tst_QDBusConnection::init() +{ + hookCallCount = 0; +} + +void tst_QDBusConnection::cleanup() +{ + QVERIFY2(!hookCallCount, "Unchecked call"); +} + + void tst_QDBusConnection::noConnection() { QDBusConnection con = QDBusConnection::connectToBus("unix:path=/dev/null", "testconnection"); @@ -359,9 +384,11 @@ void tst_QDBusConnection::registerObject() QCOMPARE(con.objectRegisteredAt(path), static_cast(&obj)); QVERIFY(callMethod(con, path)); QCOMPARE(obj.path, path); + QVERIFY_HOOKCALLED(); } // make sure it's gone QVERIFY(!callMethod(con, path)); + QVERIFY_HOOKCALLED(); } void tst_QDBusConnection::registerObjectWithInterface_data() @@ -393,9 +420,11 @@ void tst_QDBusConnection::registerObjectWithInterface() QVERIFY(callMethod(con, path, interface)); QCOMPARE(obj.path, path); QCOMPARE(obj.interface, interface); + QVERIFY_HOOKCALLED(); } // make sure it's gone QVERIFY(!callMethod(con, path, interface)); + QVERIFY_HOOKCALLED(); } void tst_QDBusConnection::registerObjectPeer_data() @@ -432,6 +461,7 @@ void tst_QDBusConnection::registerObjectPeer() MyObject obj; QVERIFY(callMethodPeer(con, path)); QCOMPARE(obj.path, path); + QVERIFY_HOOKCALLED(); } QDBusConnection::connectToPeer(server.address(), "afterFoo"); @@ -441,6 +471,7 @@ void tst_QDBusConnection::registerObjectPeer() QDBusConnection con("foo"); QVERIFY(con.isConnected()); QVERIFY(callMethodPeer(con, path)); + QVERIFY_HOOKCALLED(); } server.unregisterObject(); @@ -449,6 +480,7 @@ void tst_QDBusConnection::registerObjectPeer() QDBusConnection con("foo"); QVERIFY(con.isConnected()); QVERIFY(!callMethodPeer(con, path)); + QVERIFY_HOOKCALLED(); } server.registerObject(); @@ -457,6 +489,7 @@ void tst_QDBusConnection::registerObjectPeer() QDBusConnection con("foo"); QVERIFY(con.isConnected()); QVERIFY(callMethodPeer(con, path)); + QVERIFY_HOOKCALLED(); } QDBusConnection::disconnectFromPeer("foo"); @@ -478,10 +511,15 @@ void tst_QDBusConnection::registerObject2() // make sure nothing is using our paths: QVERIFY(!callMethod(con, "/")); + QVERIFY_HOOKCALLED(); QVERIFY(!callMethod(con, "/p1")); + QVERIFY_HOOKCALLED(); QVERIFY(!callMethod(con, "/p2")); + QVERIFY_HOOKCALLED(); QVERIFY(!callMethod(con, "/p1/q")); + QVERIFY_HOOKCALLED(); QVERIFY(!callMethod(con, "/p1/q/r")); + QVERIFY_HOOKCALLED(); { // register one object at root: @@ -489,76 +527,99 @@ void tst_QDBusConnection::registerObject2() QVERIFY(con.registerObject("/", &obj, QDBusConnection::ExportAllSlots)); QVERIFY(callMethod(con, "/")); QCOMPARE(obj.path, QString("/")); + QVERIFY_HOOKCALLED(); } // make sure it's gone QVERIFY(!callMethod(con, "/")); + QVERIFY_HOOKCALLED(); { // register one at an element: MyObject obj; QVERIFY(con.registerObject("/p1", &obj, QDBusConnection::ExportAllSlots)); QVERIFY(!callMethod(con, "/")); + QVERIFY_HOOKCALLED(); QVERIFY(callMethod(con, "/p1")); QCOMPARE(obj.path, QString("/p1")); + QVERIFY_HOOKCALLED(); // re-register it somewhere else QVERIFY(con.registerObject("/p2", &obj, QDBusConnection::ExportAllSlots)); QVERIFY(callMethod(con, "/p1")); QCOMPARE(obj.path, QString("/p1")); + QVERIFY_HOOKCALLED(); QVERIFY(callMethod(con, "/p2")); QCOMPARE(obj.path, QString("/p2")); + QVERIFY_HOOKCALLED(); } // make sure it's gone QVERIFY(!callMethod(con, "/p1")); + QVERIFY_HOOKCALLED(); QVERIFY(!callMethod(con, "/p2")); + QVERIFY_HOOKCALLED(); { // register at a deep path MyObject obj; QVERIFY(con.registerObject("/p1/q/r", &obj, QDBusConnection::ExportAllSlots)); QVERIFY(!callMethod(con, "/")); + QVERIFY_HOOKCALLED(); QVERIFY(!callMethod(con, "/p1")); + QVERIFY_HOOKCALLED(); QVERIFY(!callMethod(con, "/p1/q")); + QVERIFY_HOOKCALLED(); QVERIFY(callMethod(con, "/p1/q/r")); QCOMPARE(obj.path, QString("/p1/q/r")); + QVERIFY_HOOKCALLED(); } + // make sure it's gone QVERIFY(!callMethod(con, "/p1/q/r")); + QVERIFY_HOOKCALLED(); { MyObject obj; QVERIFY(con.registerObject("/p1/q2", &obj, QDBusConnection::ExportAllSlots)); QVERIFY(callMethod(con, "/p1/q2")); QCOMPARE(obj.path, QString("/p1/q2")); + QVERIFY_HOOKCALLED(); // try unregistering con.unregisterObject("/p1/q2"); QVERIFY(!callMethod(con, "/p1/q2")); + QVERIFY_HOOKCALLED(); // register it again QVERIFY(con.registerObject("/p1/q2", &obj, QDBusConnection::ExportAllSlots)); QVERIFY(callMethod(con, "/p1/q2")); QCOMPARE(obj.path, QString("/p1/q2")); + QVERIFY_HOOKCALLED(); // now try removing things around it: con.unregisterObject("/p2"); QVERIFY(callMethod(con, "/p1/q2")); // unrelated object shouldn't affect + QVERIFY_HOOKCALLED(); con.unregisterObject("/p1"); QVERIFY(callMethod(con, "/p1/q2")); // unregistering just the parent shouldn't affect it + QVERIFY_HOOKCALLED(); con.unregisterObject("/p1/q2/r"); QVERIFY(callMethod(con, "/p1/q2")); // unregistering non-existing child shouldn't affect it either + QVERIFY_HOOKCALLED(); con.unregisterObject("/p1/q"); QVERIFY(callMethod(con, "/p1/q2")); // unregistering sibling (before) shouldn't affect + QVERIFY_HOOKCALLED(); con.unregisterObject("/p1/r"); QVERIFY(callMethod(con, "/p1/q2")); // unregistering sibling (after) shouldn't affect + QVERIFY_HOOKCALLED(); // now remove it: con.unregisterObject("/p1", QDBusConnection::UnregisterTree); QVERIFY(!callMethod(con, "/p1/q2")); // we removed the full tree + QVERIFY_HOOKCALLED(); } } @@ -577,10 +638,15 @@ void tst_QDBusConnection::registerObjectPeer2() // make sure nothing is using our paths: QVERIFY(!callMethodPeer(srv_con, "/")); + QVERIFY_HOOKCALLED(); QVERIFY(!callMethodPeer(srv_con, "/p1")); + QVERIFY_HOOKCALLED(); QVERIFY(!callMethodPeer(srv_con, "/p2")); + QVERIFY_HOOKCALLED(); QVERIFY(!callMethodPeer(srv_con, "/p1/q")); + QVERIFY_HOOKCALLED(); QVERIFY(!callMethodPeer(srv_con, "/p1/q/r")); + QVERIFY_HOOKCALLED(); { // register one object at root: @@ -588,76 +654,101 @@ void tst_QDBusConnection::registerObjectPeer2() QVERIFY(con.registerObject("/", &obj, QDBusConnection::ExportAllSlots)); QVERIFY(callMethodPeer(srv_con, "/")); QCOMPARE(obj.path, QString("/")); + QVERIFY_HOOKCALLED(); } + // make sure it's gone QVERIFY(!callMethodPeer(srv_con, "/")); + QVERIFY_HOOKCALLED(); { // register one at an element: MyObject obj; QVERIFY(con.registerObject("/p1", &obj, QDBusConnection::ExportAllSlots)); QVERIFY(!callMethodPeer(srv_con, "/")); + QVERIFY_HOOKCALLED(); QVERIFY(callMethodPeer(srv_con, "/p1")); QCOMPARE(obj.path, QString("/p1")); + QVERIFY_HOOKCALLED(); // re-register it somewhere else QVERIFY(con.registerObject("/p2", &obj, QDBusConnection::ExportAllSlots)); QVERIFY(callMethodPeer(srv_con, "/p1")); QCOMPARE(obj.path, QString("/p1")); + QVERIFY_HOOKCALLED(); QVERIFY(callMethodPeer(srv_con, "/p2")); QCOMPARE(obj.path, QString("/p2")); + QVERIFY_HOOKCALLED(); } + // make sure it's gone QVERIFY(!callMethodPeer(srv_con, "/p1")); + QVERIFY_HOOKCALLED(); QVERIFY(!callMethodPeer(srv_con, "/p2")); + QVERIFY_HOOKCALLED(); { // register at a deep path MyObject obj; QVERIFY(con.registerObject("/p1/q/r", &obj, QDBusConnection::ExportAllSlots)); QVERIFY(!callMethodPeer(srv_con, "/")); + QVERIFY_HOOKCALLED(); QVERIFY(!callMethodPeer(srv_con, "/p1")); + QVERIFY_HOOKCALLED(); QVERIFY(!callMethodPeer(srv_con, "/p1/q")); + QVERIFY_HOOKCALLED(); QVERIFY(callMethodPeer(srv_con, "/p1/q/r")); QCOMPARE(obj.path, QString("/p1/q/r")); + QVERIFY_HOOKCALLED(); } + // make sure it's gone QVERIFY(!callMethodPeer(srv_con, "/p1/q/r")); + QVERIFY_HOOKCALLED(); { MyObject obj; QVERIFY(con.registerObject("/p1/q2", &obj, QDBusConnection::ExportAllSlots)); QVERIFY(callMethodPeer(srv_con, "/p1/q2")); QCOMPARE(obj.path, QString("/p1/q2")); + QVERIFY_HOOKCALLED(); // try unregistering con.unregisterObject("/p1/q2"); QVERIFY(!callMethodPeer(srv_con, "/p1/q2")); + QVERIFY_HOOKCALLED(); // register it again QVERIFY(con.registerObject("/p1/q2", &obj, QDBusConnection::ExportAllSlots)); QVERIFY(callMethodPeer(srv_con, "/p1/q2")); QCOMPARE(obj.path, QString("/p1/q2")); + QVERIFY_HOOKCALLED(); // now try removing things around it: con.unregisterObject("/p2"); QVERIFY(callMethodPeer(srv_con, "/p1/q2")); // unrelated object shouldn't affect + QVERIFY_HOOKCALLED(); con.unregisterObject("/p1"); QVERIFY(callMethodPeer(srv_con, "/p1/q2")); // unregistering just the parent shouldn't affect it + QVERIFY_HOOKCALLED(); con.unregisterObject("/p1/q2/r"); QVERIFY(callMethodPeer(srv_con, "/p1/q2")); // unregistering non-existing child shouldn't affect it either + QVERIFY_HOOKCALLED(); con.unregisterObject("/p1/q"); QVERIFY(callMethodPeer(srv_con, "/p1/q2")); // unregistering sibling (before) shouldn't affect + QVERIFY_HOOKCALLED(); con.unregisterObject("/p1/r"); QVERIFY(callMethodPeer(srv_con, "/p1/q2")); // unregistering sibling (after) shouldn't affect + QVERIFY_HOOKCALLED(); // now remove it: con.unregisterObject("/p1", QDBusConnection::UnregisterTree); QVERIFY(!callMethodPeer(srv_con, "/p1/q2")); // we removed the full tree + QVERIFY_HOOKCALLED(); } QDBusConnection::disconnectFromPeer("foo"); @@ -669,6 +760,7 @@ void tst_QDBusConnection::registerQObjectChildren() // make sure no one is there QDBusConnection con = QDBusConnection::sessionBus(); QVERIFY(!callMethod(con, "/p1")); + QVERIFY_HOOKCALLED(); { MyObject obj, *a, *b, *c, *cc; @@ -691,32 +783,47 @@ void tst_QDBusConnection::registerQObjectChildren() // make calls QVERIFY(callMethod(con, "/p1")); QCOMPARE(obj.callCount, 1); + QVERIFY_HOOKCALLED(); QVERIFY(callMethod(con, "/p1/a")); QCOMPARE(a->callCount, 1); + QVERIFY_HOOKCALLED(); QVERIFY(callMethod(con, "/p1/b")); QCOMPARE(b->callCount, 1); + QVERIFY_HOOKCALLED(); QVERIFY(callMethod(con, "/p1/c")); QCOMPARE(c->callCount, 1); + QVERIFY_HOOKCALLED(); QVERIFY(callMethod(con, "/p1/c/cc")); QCOMPARE(cc->callCount, 1); + QVERIFY_HOOKCALLED(); QVERIFY(!callMethod(con, "/p1/d")); + QVERIFY_HOOKCALLED(); QVERIFY(!callMethod(con, "/p1/c/abc")); + QVERIFY_HOOKCALLED(); // pull an object, see if it goes away: delete b; QVERIFY(!callMethod(con, "/p1/b")); + QVERIFY_HOOKCALLED(); delete c; QVERIFY(!callMethod(con, "/p1/c")); + QVERIFY_HOOKCALLED(); QVERIFY(!callMethod(con, "/p1/c/cc")); + QVERIFY_HOOKCALLED(); } QVERIFY(!callMethod(con, "/p1")); + QVERIFY_HOOKCALLED(); QVERIFY(!callMethod(con, "/p1/a")); + QVERIFY_HOOKCALLED(); QVERIFY(!callMethod(con, "/p1/b")); + QVERIFY_HOOKCALLED(); QVERIFY(!callMethod(con, "/p1/c")); + QVERIFY_HOOKCALLED(); QVERIFY(!callMethod(con, "/p1/c/cc")); + QVERIFY_HOOKCALLED(); } void tst_QDBusConnection::registerQObjectChildrenPeer() @@ -734,6 +841,7 @@ void tst_QDBusConnection::registerQObjectChildrenPeer() QDBusConnection srv_con = server.connection(); QVERIFY(!callMethodPeer(srv_con, "/p1")); + QVERIFY_HOOKCALLED(); { MyObject obj, *a, *b, *c, *cc; @@ -756,32 +864,47 @@ void tst_QDBusConnection::registerQObjectChildrenPeer() // make calls QVERIFY(callMethodPeer(srv_con, "/p1")); QCOMPARE(obj.callCount, 1); + QVERIFY_HOOKCALLED(); QVERIFY(callMethodPeer(srv_con, "/p1/a")); QCOMPARE(a->callCount, 1); + QVERIFY_HOOKCALLED(); QVERIFY(callMethodPeer(srv_con, "/p1/b")); QCOMPARE(b->callCount, 1); + QVERIFY_HOOKCALLED(); QVERIFY(callMethodPeer(srv_con, "/p1/c")); QCOMPARE(c->callCount, 1); + QVERIFY_HOOKCALLED(); QVERIFY(callMethodPeer(srv_con, "/p1/c/cc")); QCOMPARE(cc->callCount, 1); + QVERIFY_HOOKCALLED(); QVERIFY(!callMethodPeer(srv_con, "/p1/d")); + QVERIFY_HOOKCALLED(); QVERIFY(!callMethodPeer(srv_con, "/p1/c/abc")); + QVERIFY_HOOKCALLED(); // pull an object, see if it goes away: delete b; QVERIFY(!callMethodPeer(srv_con, "/p1/b")); + QVERIFY_HOOKCALLED(); delete c; QVERIFY(!callMethodPeer(srv_con, "/p1/c")); + QVERIFY_HOOKCALLED(); QVERIFY(!callMethodPeer(srv_con, "/p1/c/cc")); + QVERIFY_HOOKCALLED(); } QVERIFY(!callMethodPeer(srv_con, "/p1")); + QVERIFY_HOOKCALLED(); QVERIFY(!callMethodPeer(srv_con, "/p1/a")); + QVERIFY_HOOKCALLED(); QVERIFY(!callMethodPeer(srv_con, "/p1/b")); + QVERIFY_HOOKCALLED(); QVERIFY(!callMethodPeer(srv_con, "/p1/c")); + QVERIFY_HOOKCALLED(); QVERIFY(!callMethodPeer(srv_con, "/p1/c/cc")); + QVERIFY_HOOKCALLED(); QDBusConnection::disconnectFromPeer("foo"); } @@ -827,20 +950,25 @@ void tst_QDBusConnection::callSelf() QVERIFY(connection.registerService(serviceName())); QDBusInterface interface(serviceName(), "/test"); QVERIFY(interface.isValid()); + QVERIFY_HOOKCALLED(); interface.call(QDBus::Block, "test0"); QCOMPARE(testObject.func, QString("test0")); + QVERIFY_HOOKCALLED(); interface.call(QDBus::Block, "test1", 42); QCOMPARE(testObject.func, QString("test1 42")); + QVERIFY_HOOKCALLED(); QDBusMessage reply = interface.call(QDBus::Block, "test2"); QCOMPARE(testObject.func, QString("test2")); QCOMPARE(reply.arguments().value(0).toInt(), 43); + QVERIFY_HOOKCALLED(); QDBusMessage msg = QDBusMessage::createMethodCall(serviceName(), "/test", QString(), "test3"); msg << 44; reply = connection.call(msg); QCOMPARE(reply.arguments().value(0).toInt(), 45); + QVERIFY_HOOKCALLED(); } void tst_QDBusConnection::callSelfByAnotherName_data() @@ -908,12 +1036,14 @@ void tst_QDBusConnection::callSelfByAnotherName() QDBusMessage reply = con.call(msg, QDBus::Block, 1000); QVERIFY(reply.type() == QDBusMessage::ReplyMessage); + QVERIFY_HOOKCALLED(); } void tst_QDBusConnection::multipleInterfacesInQObject() { QDBusConnection con = QDBusConnection::sessionBus(); QVERIFY(!callMethod(con, "/p1")); + QVERIFY_HOOKCALLED(); MyObject obj; con.registerObject("/p1", &obj, QDBusConnection::ExportAllSlots); @@ -924,6 +1054,7 @@ void tst_QDBusConnection::multipleInterfacesInQObject() QDBusMessage reply = con.call(msg, QDBus::Block); QCOMPARE(reply.type(), QDBusMessage::ReplyMessage); QVERIFY(reply.arguments().count() == 0); + QVERIFY_HOOKCALLED(); } void tst_QDBusConnection::slotsWithLessParameters() @@ -981,6 +1112,7 @@ void tst_QDBusConnection::nestedCallWithCallback() QTestEventLoop::instance().enterLoop(15); QVERIFY(!QTestEventLoop::instance().timeout()); QCOMPARE(signalsReceived, 1); + QCOMPARE_HOOKCOUNT(2); } void tst_QDBusConnection::serviceRegistrationRaceCondition() @@ -1145,6 +1277,7 @@ void tst_QDBusConnection::callVirtualObject() QTestEventLoop::instance().enterLoop(5); QVERIFY(!QTestEventLoop::instance().timeout()); + QVERIFY_HOOKCALLED(); QCOMPARE(obj.callCount, 1); QCOMPARE(obj.lastMessage.service(), con2.baseService()); @@ -1162,6 +1295,7 @@ void tst_QDBusConnection::callVirtualObject() QTestEventLoop::instance().enterLoop(5); QVERIFY(!QTestEventLoop::instance().timeout()); + QVERIFY_HOOKCALLED(); QCOMPARE(obj.callCount, 2); QCOMPARE(obj.lastMessage.service(), con2.baseService()); @@ -1179,6 +1313,7 @@ void tst_QDBusConnection::callVirtualObject() QTestEventLoop::instance().enterLoop(5); QVERIFY(!QTestEventLoop::instance().timeout()); + QVERIFY_HOOKCALLED(); QTest::qWait(100); QVERIFY(errorReply.isError()); QCOMPARE(errorReply.reply().errorName(), QString("org.freedesktop.DBus.Error.UnknownObject")); @@ -1207,6 +1342,7 @@ void tst_QDBusConnection::callVirtualObjectLocal() QCOMPARE(obj.lastMessage.interface(), QString()); QCOMPARE(obj.lastMessage.path(), path); QCOMPARE(obj.replyArguments, reply.arguments()); + QVERIFY_HOOKCALLED(); obj.replyArguments << QString("alien abduction"); QDBusMessage subPathMessage = QDBusMessage::createMethodCall(con.baseService(), childPath, QString(), "hello"); @@ -1216,6 +1352,7 @@ void tst_QDBusConnection::callVirtualObjectLocal() QCOMPARE(obj.lastMessage.interface(), QString()); QCOMPARE(obj.lastMessage.path(), childPath); QCOMPARE(obj.replyArguments, subPathReply.arguments()); + QVERIFY_HOOKCALLED(); } void tst_QDBusConnection::pendingCallWhenDisconnected() diff --git a/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.h b/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.h index 720e484cc2..b47daa118b 100644 --- a/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.h +++ b/tests/auto/dbus/qdbusconnection/tst_qdbusconnection.h @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. -** Copyright (C) 2015 Intel Corporation. +** Copyright (C) 2016 Intel Corporation. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. @@ -79,11 +79,18 @@ class tst_QDBusConnection: public QObject Q_OBJECT int signalsReceived; +public: + static int hookCallCount; + tst_QDBusConnection(); + public slots: void oneSlot() { ++signalsReceived; } void exitLoop() { ++signalsReceived; QTestEventLoop::instance().exitLoop(); } void secondCallWithCallback(); + void init(); + void cleanup(); + private slots: void noConnection(); void connectToBus(); diff --git a/tests/auto/dbus/qdbusconnection_spyhook/qdbusconnection_spyhook.pro b/tests/auto/dbus/qdbusconnection_spyhook/qdbusconnection_spyhook.pro new file mode 100644 index 0000000000..020d30380d --- /dev/null +++ b/tests/auto/dbus/qdbusconnection_spyhook/qdbusconnection_spyhook.pro @@ -0,0 +1,7 @@ +CONFIG += testcase +TARGET = tst_qdbusconnection_spyhook +QT = core dbus testlib +SOURCES += tst_qdbusconnection_spyhook.cpp +HEADERS += ../qdbusconnection/tst_qdbusconnection.h +DEFINES += SRCDIR=\\\"$$PWD/\\\" tst_QDBusConnection=tst_QDBusConnection_SpyHook +include(../dbus-testcase.pri) diff --git a/tests/auto/dbus/qdbusconnection_spyhook/tst_qdbusconnection_spyhook.cpp b/tests/auto/dbus/qdbusconnection_spyhook/tst_qdbusconnection_spyhook.cpp new file mode 100644 index 0000000000..fa1c19920a --- /dev/null +++ b/tests/auto/dbus/qdbusconnection_spyhook/tst_qdbusconnection_spyhook.cpp @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Intel Corporation. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#define HAS_HOOKSETUPFUNCTION 1 +static void hookSetupFunction(); + +// Ugly hack, look away +#include "../qdbusconnection/tst_qdbusconnection.cpp" + +QT_BEGIN_NAMESPACE +extern Q_DBUS_EXPORT void qDBusAddSpyHook(void (*Hook)(const QDBusMessage&)); +QT_END_NAMESPACE + +static void hookFunction(const QDBusMessage &) +{ +// qDebug() << "hook called"; + ++tst_QDBusConnection::hookCallCount; +} + +static void hookSetupFunction() +{ + QT_PREPEND_NAMESPACE(qDBusAddSpyHook)(hookFunction); +} + +QTEST_MAIN(tst_QDBusConnection_SpyHook) -- cgit v1.2.3 From b168c6c8248662da31dbaaf2afb8e771a9ecdc85 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 17 Nov 2015 22:21:53 -0800 Subject: QStorageInfo: fix matching of mountpoints to sibling directories The path "/usrfoo" starts with "/usr", so if you tried to get QStorageInfo("/usrfoo") when "/usr" is a mount point, you'd get the wrong filesystem. [ChangeLog][QtCore][QStorageInfo] Fixed a bug that caused QStorageInfo to report information for the wrong filesystem if there is a mounted filesystem at a path that is a prefix of the requested path (e.g., it would report "/usr" filesystem for "/usrfoo"). Task-number: QTBUG-49498 Change-Id: I3e15a26e0e424169ac2bffff1417b7a27cd0132d Reviewed-by: Jake Petroules --- src/corelib/io/qstorageinfo_unix.cpp | 58 +++++++++------- .../corelib/io/qstorageinfo/tst_qstorageinfo.cpp | 2 + tests/manual/manual.pro | 1 + tests/manual/qstorageinfo/main.cpp | 81 ++++++++++++++++++++++ tests/manual/qstorageinfo/qstorageinfo.pro | 4 ++ 5 files changed, 122 insertions(+), 24 deletions(-) create mode 100644 tests/manual/qstorageinfo/main.cpp create mode 100644 tests/manual/qstorageinfo/qstorageinfo.pro diff --git a/src/corelib/io/qstorageinfo_unix.cpp b/src/corelib/io/qstorageinfo_unix.cpp index e365d8d7e6..bbcc29c50b 100644 --- a/src/corelib/io/qstorageinfo_unix.cpp +++ b/src/corelib/io/qstorageinfo_unix.cpp @@ -102,25 +102,6 @@ QT_BEGIN_NAMESPACE -static bool isPseudoFs(const QString &mountDir, const QByteArray &type) -{ - if (mountDir.startsWith(QLatin1String("/dev")) - || mountDir.startsWith(QLatin1String("/proc")) - || mountDir.startsWith(QLatin1String("/sys")) - || mountDir.startsWith(QLatin1String("/var/run")) - || mountDir.startsWith(QLatin1String("/var/lock"))) { - return true; - } - if (type == "tmpfs") - return true; -#if defined(Q_OS_LINUX) - if (type == "rootfs" || type == "rpc_pipefs") - return true; -#endif - - return false; -} - class QStorageIterator { public: @@ -158,6 +139,36 @@ private: #endif }; +template +static bool isParentOf(const String &parent, const QString &dirName) +{ + return dirName.startsWith(parent) && + (dirName.size() == parent.size() || dirName.at(parent.size()) == QLatin1Char('/') || + parent.size() == 1); +} + +static bool isPseudoFs(const QStorageIterator &it) +{ + QString mountDir = it.rootPath(); + if (isParentOf(QLatin1String("/dev"), mountDir) + || isParentOf(QLatin1String("/proc"), mountDir) + || isParentOf(QLatin1String("/sys"), mountDir) + || isParentOf(QLatin1String("/var/run"), mountDir) + || isParentOf(QLatin1String("/var/lock"), mountDir)) { + return true; + } + + QByteArray type = it.fileSystemType(); + if (type == "tmpfs") + return true; +#if defined(Q_OS_LINUX) + if (type == "rootfs" || type == "rpc_pipefs") + return true; +#endif + + return false; +} + #if defined(Q_OS_BSD4) inline QStorageIterator::QStorageIterator() @@ -444,10 +455,10 @@ void QStorageInfoPrivate::initRootPath() while (it.next()) { const QString mountDir = it.rootPath(); const QByteArray fsName = it.fileSystemType(); - if (isPseudoFs(mountDir, fsName)) + if (isPseudoFs(it)) continue; // we try to find most suitable entry - if (oldRootPath.startsWith(mountDir) && maxLength < mountDir.length()) { + if (isParentOf(mountDir, oldRootPath) && maxLength < mountDir.length()) { maxLength = mountDir.length(); rootPath = mountDir; device = it.device(); @@ -536,11 +547,10 @@ QList QStorageInfoPrivate::mountedVolumes() QList volumes; while (it.next()) { - const QString mountDir = it.rootPath(); - const QByteArray fsName = it.fileSystemType(); - if (isPseudoFs(mountDir, fsName)) + if (isPseudoFs(it)) continue; + const QString mountDir = it.rootPath(); volumes.append(QStorageInfo(mountDir)); } diff --git a/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp b/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp index efbcdc78e0..1afcf05135 100644 --- a/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp +++ b/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp @@ -162,6 +162,7 @@ void tst_QStorageInfo::tempFile() #endif qint64 free = storage1.bytesFree(); + QVERIFY(free != -1); file.write(QByteArray(1024*1024, '1')); file.flush(); @@ -185,6 +186,7 @@ void tst_QStorageInfo::caching() qint64 free = storage1.bytesFree(); QStorageInfo storage2(storage1); QVERIFY(free == storage2.bytesFree()); + QVERIFY(free != -1); file.write(QByteArray(1024*1024, '\0')); file.flush(); diff --git a/tests/manual/manual.pro b/tests/manual/manual.pro index bec098d462..8e77a321dd 100644 --- a/tests/manual/manual.pro +++ b/tests/manual/manual.pro @@ -24,6 +24,7 @@ qnetworkaccessmanager/qget \ qnetworkconfigurationmanager \ qnetworkconfiguration \ qnetworkreply \ +qstorageinfo \ qscreen \ qssloptions \ qsslsocket \ diff --git a/tests/manual/qstorageinfo/main.cpp b/tests/manual/qstorageinfo/main.cpp new file mode 100644 index 0000000000..884e5559ce --- /dev/null +++ b/tests/manual/qstorageinfo/main.cpp @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Intel Corporation +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +#include + +int main(int argc, char *argv[]) +{ + QCoreApplication a(argc, argv); + + QList volumes; + QStringList args = a.arguments(); + args.takeFirst(); // skip application name + + foreach (const QString &path, args) { + QStorageInfo info(path); + if (!info.isValid()) { + // no error string... + fprintf(stderr, "Could not get info on %s\n", qPrintable(path)); + return 1; + } + volumes << info; + } + + if (volumes.isEmpty()) + volumes = QStorageInfo::mountedVolumes(); + + // Sample output: + // Filesystem (Type) Size Available BSize Label Mounted on + // /dev/sda2 (ext4) RO 388480 171218 1024 /boot + // /dev/mapper/system-root (btrfs) RW + // 214958080 39088272 4096 / + // /dev/disk1s2 (hfs) RW 488050672 419909696 4096 Macintosh HD2 /Volumes/Macintosh HD2 + + printf("Filesystem (Type) Size Available BSize Label Mounted on\n"); + foreach (const QStorageInfo &info, volumes) { + const QString fsAndType = info.device() + QLatin1String(" (") + + info.fileSystemType() + QLatin1Char(')'); + + printf("%-19s R%c ", qPrintable(fsAndType), info.isReadOnly() ? 'O' : 'W'); + if (fsAndType.size() > 19) + printf("\n%23s", ""); + + printf("%10llu %10llu %5u ", info.bytesTotal() / 1024, info.bytesFree() / 1024, info.blockSize()); + printf("%-16s %s\n", qPrintable(info.name()), qPrintable(info.rootPath())); + } + + return 0; +} diff --git a/tests/manual/qstorageinfo/qstorageinfo.pro b/tests/manual/qstorageinfo/qstorageinfo.pro new file mode 100644 index 0000000000..25acd24c80 --- /dev/null +++ b/tests/manual/qstorageinfo/qstorageinfo.pro @@ -0,0 +1,4 @@ +QT = core +CONFIG += console +CONFIG -= app_bundle +SOURCES += main.cpp -- cgit v1.2.3 From d9f6b6d1f836c25a8179ae7a6df18ee9cceebfb1 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 17 Nov 2015 22:25:04 -0800 Subject: QStorageInfo: update the detection of pseudo filesystems Allow tmpfs filesystems to be reported, as they're often usable by the user, mounted in /tmp and in /run (the fs for $XDG_RUNTIME_DIR). But disallow anything whose device is not a pathname. This catches most of everything else that wasn't specifically tested for before, like virtual fuse filesystems, like GVFS. Change-Id: I3e15a26e0e424169ac2bffff1417b7cee0f8ec97 Reviewed-by: Ivan Komissarov Reviewed-by: Thiago Macieira --- src/corelib/io/qstorageinfo_unix.cpp | 5 ++++- tests/manual/qstorageinfo/main.cpp | 7 ++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/corelib/io/qstorageinfo_unix.cpp b/src/corelib/io/qstorageinfo_unix.cpp index bbcc29c50b..bf998993d8 100644 --- a/src/corelib/io/qstorageinfo_unix.cpp +++ b/src/corelib/io/qstorageinfo_unix.cpp @@ -160,12 +160,15 @@ static bool isPseudoFs(const QStorageIterator &it) QByteArray type = it.fileSystemType(); if (type == "tmpfs") - return true; + return false; #if defined(Q_OS_LINUX) if (type == "rootfs" || type == "rpc_pipefs") return true; #endif + if (!it.device().startsWith('/')) + return true; + return false; } diff --git a/tests/manual/qstorageinfo/main.cpp b/tests/manual/qstorageinfo/main.cpp index 884e5559ce..5c106ff45b 100644 --- a/tests/manual/qstorageinfo/main.cpp +++ b/tests/manual/qstorageinfo/main.cpp @@ -66,10 +66,11 @@ int main(int argc, char *argv[]) printf("Filesystem (Type) Size Available BSize Label Mounted on\n"); foreach (const QStorageInfo &info, volumes) { - const QString fsAndType = info.device() + QLatin1String(" (") + - info.fileSystemType() + QLatin1Char(')'); + QByteArray fsAndType = info.device(); + if (info.fileSystemType() != fsAndType) + fsAndType += " (" + info.fileSystemType() + ')'; - printf("%-19s R%c ", qPrintable(fsAndType), info.isReadOnly() ? 'O' : 'W'); + printf("%-19s R%c ", fsAndType.constData(), info.isReadOnly() ? 'O' : 'W'); if (fsAndType.size() > 19) printf("\n%23s", ""); -- cgit v1.2.3 From 4aba3dbcb3832cb70253b7100e2a8555261a69c8 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 17 Nov 2015 22:54:19 -0800 Subject: QStorageInfo: get the label properly if the mounted device is a symlink This happens for me with LVM: $ ls -l /dev/mapper/system-root /dev/system/root /dev/disk/by-label/* lrwxrwxrwx 1 root root 10 Nov 17 22:45 /dev/disk/by-label/system -> ../../dm-1 lrwxrwxrwx 1 root root 7 Nov 17 22:45 /dev/mapper/system-root -> ../dm-1 lrwxrwxrwx 1 root root 7 Nov 17 22:45 /dev/system/root -> ../dm-1 The mounted device according to /etc/mtab (/proc/self/mounts) is /dev/mapper/system-root. Change-Id: I3e15a26e0e424169ac2bffff1417b96779d84246 Reviewed-by: Ivan Komissarov Reviewed-by: Thiago Macieira --- src/corelib/io/qstorageinfo_unix.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/corelib/io/qstorageinfo_unix.cpp b/src/corelib/io/qstorageinfo_unix.cpp index bf998993d8..bf33c160fc 100644 --- a/src/corelib/io/qstorageinfo_unix.cpp +++ b/src/corelib/io/qstorageinfo_unix.cpp @@ -475,11 +475,14 @@ static inline QString retrieveLabel(const QByteArray &device) #ifdef Q_OS_LINUX static const char pathDiskByLabel[] = "/dev/disk/by-label"; + QFileInfo devinfo(QFile::decodeName(device)); + QString devicePath = devinfo.canonicalFilePath(); + QDirIterator it(QLatin1String(pathDiskByLabel), QDir::NoDotAndDotDot); while (it.hasNext()) { it.next(); QFileInfo fileInfo(it.fileInfo()); - if (fileInfo.isSymLink() && fileInfo.symLinkTarget().toLocal8Bit() == device) + if (fileInfo.isSymLink() && fileInfo.symLinkTarget() == devicePath) return fileInfo.fileName(); } #elif defined Q_OS_HAIKU -- cgit v1.2.3 From 0453897f1ee1cdf6dc216bec975a198e386428e6 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 17 Nov 2015 23:07:49 -0800 Subject: QStorageInfo: allow getting the info of pseudo filesystems too They won't be listed in QStorageInfo::mountedVolumes, but we can now obtain their info if you know their mountpoint. For example, on Linux: $ ./qstorageinfo /dev /proc /sys Filesystem (Type) Size Available BSize Label Mounted on devtmpfs (devtmpfs) RW 4029772 4029764 4096 /dev proc (proc) RW 0 0 4096 /proc sysfs (sysfs) RW 0 0 4096 /sys Change-Id: I3e15a26e0e424169ac2bffff1417ba2429d6d9f4 Reviewed-by: Ivan Komissarov Reviewed-by: Thiago Macieira --- src/corelib/io/qstorageinfo_unix.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/corelib/io/qstorageinfo_unix.cpp b/src/corelib/io/qstorageinfo_unix.cpp index bf33c160fc..1d1b2907b7 100644 --- a/src/corelib/io/qstorageinfo_unix.cpp +++ b/src/corelib/io/qstorageinfo_unix.cpp @@ -458,8 +458,6 @@ void QStorageInfoPrivate::initRootPath() while (it.next()) { const QString mountDir = it.rootPath(); const QByteArray fsName = it.fileSystemType(); - if (isPseudoFs(it)) - continue; // we try to find most suitable entry if (isParentOf(mountDir, oldRootPath) && maxLength < mountDir.length()) { maxLength = mountDir.length(); -- cgit v1.2.3 From c0425f39d12a63238532e6e9c6634628bf1ed2de Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 9 May 2016 09:45:49 +0200 Subject: Windows Accessibility: Use QWindowsAccessibility::windowHelper(). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Amends changes ee516381873857e833b53b175fd3c40e4c45a5fd, d7a3b6145999d015997e26e12a7345f774b053f3. Task-number: QTBUG-52943 Change-Id: Icdf9d99c327bdd38dfb084e6cf77b14cd5ce073b Reviewed-by: Jan Arve Sæther --- .../windows/accessible/qwindowsmsaaaccessible.cpp | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp b/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp index 71c197a32c..5550dd4efd 100644 --- a/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp +++ b/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp @@ -470,15 +470,6 @@ HRESULT STDMETHODCALLTYPE QWindowsMsaaAccessible::Invoke(long dispIdMember, return hr; } -static const QWindow *windowOf(const QAccessibleInterface *ai) -{ - for ( ; ai; ai = ai->parent()) { - if (const QWindow *window = ai->window()) - return window; - } - return Q_NULLPTR; -} - /* IAccessible @@ -507,7 +498,8 @@ HRESULT STDMETHODCALLTYPE QWindowsMsaaAccessible::accHitTest(long xLeft, long yT if (!accessible) return E_FAIL; - const QPoint pos = QHighDpi::fromNativeLocalPosition(QPoint(xLeft, yTop), windowOf(accessible)); + const QPoint pos = QHighDpi::fromNativeLocalPosition(QPoint(xLeft, yTop), + QWindowsAccessibility::windowHelper(accessible)); QAccessibleInterface *child = accessible->childAt(pos.x(), pos.y()); if (child == 0) { // no child found, return this item if it contains the coordinates @@ -550,7 +542,8 @@ HRESULT STDMETHODCALLTYPE QWindowsMsaaAccessible::accLocation(long *pxLeft, long QAccessibleInterface *acc = childPointer(accessible, varID); if (!acc || !acc->isValid()) return E_FAIL; - const QRect rect = QHighDpi::toNativePixels(acc->rect(), windowOf(accessible)); + const QRect rect = QHighDpi::toNativePixels(acc->rect(), + QWindowsAccessibility::windowHelper(accessible)); *pxLeft = rect.x(); *pyTop = rect.y(); -- cgit v1.2.3 From 9f6f06c31906c5261e578d742c48f39c0d867f37 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 9 May 2016 10:32:37 +0200 Subject: tst_QMdiArea::subWindowActivated2(): Allow for several activated events. On some X11 window managers, 2 events are received when hiding/reshowing and activating the window, which became apparent after 91f536dd71cd154675264c27273020f4de310ec2. Change-Id: I66fdc4f69d87ac898b18d5dfddc957617bb8f916 Reviewed-by: Simon Hausmann --- tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp index 57be110c15..f832ebfee0 100644 --- a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp +++ b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp @@ -499,7 +499,7 @@ void tst_QMdiArea::subWindowActivated2() mdiArea.show(); mdiArea.activateWindow(); QVERIFY(QTest::qWaitForWindowActive(&mdiArea)); - QTRY_COMPARE(spy.count(), 1); + QTRY_VERIFY(!spy.isEmpty()); // Normally 1, but 2 events might be received on some X11 window managers QVERIFY(mdiArea.currentSubWindow()); QTRY_COMPARE(mdiArea.activeSubWindow(), activeSubWindow); spy.clear(); -- cgit v1.2.3 From ed7845098f59e5d4df7af681bc15777c0e4ca1d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A4=C3=A4tt=C3=A4=20Antti?= Date: Mon, 9 May 2016 12:58:38 +0300 Subject: Fix threading issue in creating static opengl context Add mutex lock for static opengl context creation. Task-number: QTBUG-53202 Change-Id: Iba22339776ec8885efd82b13ae56f6781a426f4b Reviewed-by: Laszlo Agocs --- src/plugins/platforms/windows/qwindowsintegration.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp index 3966a4cd77..968ef7bd3b 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.cpp +++ b/src/plugins/platforms/windows/qwindowsintegration.cpp @@ -139,7 +139,8 @@ struct QWindowsIntegrationPrivate # endif #endif #ifndef QT_NO_OPENGL - QSharedPointer m_staticOpenGLContext; + QMutex m_staticContextLock; + QScopedPointer m_staticOpenGLContext; #endif // QT_NO_OPENGL QScopedPointer m_inputContext; #ifndef QT_NO_ACCESSIBILITY @@ -435,8 +436,9 @@ QWindowsStaticOpenGLContext *QWindowsIntegration::staticOpenGLContext() if (!integration) return 0; QWindowsIntegrationPrivate *d = integration->d.data(); + QMutexLocker lock(&d->m_staticContextLock); if (d->m_staticOpenGLContext.isNull()) - d->m_staticOpenGLContext = QSharedPointer(QWindowsStaticOpenGLContext::create()); + d->m_staticOpenGLContext.reset(QWindowsStaticOpenGLContext::create()); return d->m_staticOpenGLContext.data(); } #endif // !QT_NO_OPENGL -- cgit v1.2.3 From 8edfc4e9b61d7029e90423b4e5daca87fb5a82b8 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 4 May 2016 16:08:37 +0200 Subject: make zlib_dependency auto-add QtCore as a private dep our zlib header includes qglobal.h, so we need the qtcore include dirs, and qtcore is also where the actual code is compiled into. Change-Id: I09f530a1b4e6160438215a6d7223c0771ce94f05 Reviewed-by: Simon Hausmann --- mkspecs/features/qt_helper_lib.prf | 1 + src/3rdparty/zlib_dependency.pri | 4 ++++ src/corelib/tools/tools.pri | 1 + src/tools/bootstrap/bootstrap.pro | 8 ++++++-- 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/mkspecs/features/qt_helper_lib.prf b/mkspecs/features/qt_helper_lib.prf index ebc629f57f..2bad528aea 100644 --- a/mkspecs/features/qt_helper_lib.prf +++ b/mkspecs/features/qt_helper_lib.prf @@ -13,6 +13,7 @@ load(qt_build_paths) TEMPLATE = lib CONFIG -= qt +QT = # In case qt is re-added. CONFIG -= warning_clean # Don't presume 3rd party code to be clean load(qt_common) diff --git a/src/3rdparty/zlib_dependency.pri b/src/3rdparty/zlib_dependency.pri index 0bcb9f9e5e..53e0b3ef39 100644 --- a/src/3rdparty/zlib_dependency.pri +++ b/src/3rdparty/zlib_dependency.pri @@ -7,4 +7,8 @@ contains(QT_CONFIG, system-zlib) { } } else { INCLUDEPATH += $$PWD/zlib + !no_core_dep { + CONFIG += qt + QT_PRIVATE += core + } } diff --git a/src/corelib/tools/tools.pri b/src/corelib/tools/tools.pri index ed6afe70ce..bf4c6e2912 100644 --- a/src/corelib/tools/tools.pri +++ b/src/corelib/tools/tools.pri @@ -158,6 +158,7 @@ else:SOURCES += tools/qelapsedtimer_generic.cpp contains(QT_CONFIG, zlib) { include($$PWD/../../3rdparty/zlib.pri) } else { + CONFIG += no_core_dep include($$PWD/../../3rdparty/zlib_dependency.pri) } diff --git a/src/tools/bootstrap/bootstrap.pro b/src/tools/bootstrap/bootstrap.pro index b3df192110..ae0d581a58 100644 --- a/src/tools/bootstrap/bootstrap.pro +++ b/src/tools/bootstrap/bootstrap.pro @@ -132,8 +132,12 @@ macx { ../../corelib/io/qstandardpaths_win.cpp } -if(contains(QT_CONFIG, zlib)|cross_compile):include(../../3rdparty/zlib.pri) -else:include(../../3rdparty/zlib_dependency.pri) +contains(QT_CONFIG, zlib)|cross_compile { + include(../../3rdparty/zlib.pri) +} else { + CONFIG += no_core_dep + include(../../3rdparty/zlib_dependency.pri) +} win32:LIBS += -luser32 -lole32 -ladvapi32 -lshell32 -- cgit v1.2.3 From 45bec92e7a91890dbd40d8d5d310d41a617401e4 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 4 May 2016 16:14:50 +0200 Subject: make qt-freetype use qt-zlib when present from the perspective of freetype, this looks like a system zlib. Change-Id: Idb961850b2a92d456cfa2b027bdc85ce5e4be771 Reviewed-by: Simon Hausmann --- src/3rdparty/freetype/freetype.pro | 8 ++++---- src/src.pro | 7 ++++++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/3rdparty/freetype/freetype.pro b/src/3rdparty/freetype/freetype.pro index 04aa3b8e18..e16f696372 100644 --- a/src/3rdparty/freetype/freetype.pro +++ b/src/3rdparty/freetype/freetype.pro @@ -64,10 +64,10 @@ win32 { INCLUDEPATH += $$PWD/include DEFINES += FT2_BUILD_LIBRARY -contains(QT_CONFIG, system-zlib) { - DEFINES += FT_CONFIG_OPTION_SYSTEM_ZLIB - include($$PWD/../zlib_dependency.pri) -} + +DEFINES += FT_CONFIG_OPTION_SYSTEM_ZLIB +include(../zlib_dependency.pri) + contains(QT_CONFIG, system-png) { DEFINES += FT_CONFIG_OPTION_USE_PNG include($$PWD/../png_dependency.pri) diff --git a/src/src.pro b/src/src.pro index 167133859b..8c18c8d524 100644 --- a/src/src.pro +++ b/src/src.pro @@ -129,7 +129,12 @@ src_plugins.depends = src_sql src_xml src_network src_android.subdir = $$PWD/android # this order is important -contains(QT_CONFIG, zlib)|cross_compile: SUBDIRS += src_qtzlib +contains(QT_CONFIG, zlib)|cross_compile { + SUBDIRS += src_qtzlib + contains(QT_CONFIG, zlib) { + src_3rdparty_freetype.depends += src_corelib + } +} SUBDIRS += src_tools_bootstrap src_tools_moc src_tools_rcc !contains(QT_DISABLED_FEATURES, regularexpression):pcre { SUBDIRS += src_3rdparty_pcre -- cgit v1.2.3 From 1e971f855546f1b94c7cdf7a31ad64ebe6c3e23d Mon Sep 17 00:00:00 2001 From: James McDonnell Date: Wed, 4 May 2016 16:21:26 -0400 Subject: Add FreeType libraries for Windows -system-freetype builds Add a "CONFIG += qpa/basicunixfontdatase" to the -system-freetype block so that the FreeType libraries are included in LIBS. Task-number: QTBUG-35767 Change-Id: I81e18e72e068d5ac240cba79bab880e50a033860 Reviewed-by: Oswald Buddenhagen --- src/plugins/platforms/windows/windows.pri | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/platforms/windows/windows.pri b/src/plugins/platforms/windows/windows.pri index eba0593d75..aee6927338 100644 --- a/src/plugins/platforms/windows/windows.pri +++ b/src/plugins/platforms/windows/windows.pri @@ -124,6 +124,7 @@ contains(QT_CONFIG, freetype) { SOURCES += \ $$PWD/qwindowsfontdatabase_ft.cpp } else:contains(QT_CONFIG, system-freetype) { + CONFIG += qpa/basicunixfontdatabase include($$QT_SOURCE_TREE/src/platformsupport/fontdatabases/basic/basic.pri) HEADERS += \ $$PWD/qwindowsfontdatabase_ft.h -- cgit v1.2.3 From 844ea8beea8d8edb68fea18017cdc57592b2808c Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Fri, 8 Apr 2016 17:27:14 +0200 Subject: linuxfb: Support transparency Always clearing to opaque black makes it impossible to create semi-transparent overlays with linuxfb. Instead, behave like other platforms' backingstores: if the target image has an alpha channel, clear to transparent instead and set the correct composition mode. Task-number: QTBUG-52475 Change-Id: I2db4588e0112e200a3aa5eed49f806c37d7ca8b5 Reviewed-by: Louai Al-Khanji --- src/platformsupport/fbconvenience/qfbbackingstore.cpp | 11 ++++++++++- src/platformsupport/fbconvenience/qfbscreen.cpp | 5 ++++- src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp | 7 +++++-- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/platformsupport/fbconvenience/qfbbackingstore.cpp b/src/platformsupport/fbconvenience/qfbbackingstore.cpp index 2800a81507..5eddf71145 100644 --- a/src/platformsupport/fbconvenience/qfbbackingstore.cpp +++ b/src/platformsupport/fbconvenience/qfbbackingstore.cpp @@ -37,6 +37,7 @@ #include #include +#include QT_BEGIN_NAMESPACE @@ -84,9 +85,17 @@ void QFbBackingStore::unlock() mImageMutex.unlock(); } -void QFbBackingStore::beginPaint(const QRegion &) +void QFbBackingStore::beginPaint(const QRegion ®ion) { lock(); + + if (mImage.hasAlphaChannel()) { + QPainter p(&mImage); + p.setCompositionMode(QPainter::CompositionMode_Source); + const QVector rects = region.rects(); + for (QVector::const_iterator it = rects.begin(); it != rects.end(); ++it) + p.fillRect(*it, Qt::transparent); + } } void QFbBackingStore::endPaint() diff --git a/src/platformsupport/fbconvenience/qfbscreen.cpp b/src/platformsupport/fbconvenience/qfbscreen.cpp index d00954375d..ad4c62f4a6 100644 --- a/src/platformsupport/fbconvenience/qfbscreen.cpp +++ b/src/platformsupport/fbconvenience/qfbscreen.cpp @@ -233,6 +233,7 @@ QRegion QFbScreen::doRedraw() if (!mCompositePainter) mCompositePainter = new QPainter(mScreenImage); + for (int rectIndex = 0; rectIndex < mRepaintRegion.rectCount(); rectIndex++) { QRegion rectRegion = rects[rectIndex]; @@ -250,7 +251,8 @@ QRegion QFbScreen::doRedraw() foreach (const QRect &rect, intersect.rects()) { bool firstLayer = true; if (layer == -1) { - mCompositePainter->fillRect(rect, Qt::black); + mCompositePainter->setCompositionMode(QPainter::CompositionMode_Source); + mCompositePainter->fillRect(rect, mScreenImage->hasAlphaChannel() ? Qt::transparent : Qt::black); firstLayer = false; layer = mWindowStack.size() - 1; } @@ -283,6 +285,7 @@ QRegion QFbScreen::doRedraw() QRect cursorRect; if (mCursor && (mCursor->isDirty() || mRepaintRegion.intersects(mCursor->lastPainted()))) { + mCompositePainter->setCompositionMode(QPainter::CompositionMode_SourceOver); cursorRect = mCursor->drawCursor(*mCompositePainter); touchedRegion += cursorRect; } diff --git a/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp b/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp index 8c3e73fd80..13e06ef104 100644 --- a/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp +++ b/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp @@ -405,9 +405,12 @@ QRegion QLinuxFbScreen::doRedraw() if (!mBlitter) mBlitter = new QPainter(&mFbScreenImage); - QVector rects = touched.rects(); - for (int i = 0; i < rects.size(); i++) + const QVector rects = touched.rects(); + mBlitter->setCompositionMode(QPainter::CompositionMode_Source); + + for (int i = 0; i < rects.size(); ++i) mBlitter->drawImage(rects[i], *mScreenImage, rects[i]); + return touched; } -- cgit v1.2.3 From 50723bf3d0d56ba58dbf2343ea890b2d874239e9 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sun, 4 Oct 2015 01:00:09 -0400 Subject: Make sure the QDBusVirtualObject virtuals are called in the right thread Change-Id: I42e7ef1a481840699a8dffff1409e30f191e822f Reviewed-by: Frederik Gladhorn --- tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp b/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp index 93d3eacb08..91cae3272a 100644 --- a/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp +++ b/tests/auto/dbus/qdbusinterface/tst_qdbusinterface.cpp @@ -407,6 +407,7 @@ public: VirtualObject() :success(true) {} QString introspect(const QString &path) const { + Q_ASSERT(QThread::currentThread() == thread()); if (path == "/some/path/superNode") return "zitroneneis"; if (path == "/some/path/superNode/foo") @@ -417,6 +418,7 @@ public: } bool handleMessage(const QDBusMessage &message, const QDBusConnection &connection) { + Q_ASSERT(QThread::currentThread() == thread()); ++callCount; lastMessage = message; -- cgit v1.2.3 From ab2cf73440e5fbda9e2a3ba15dc1df7895c49679 Mon Sep 17 00:00:00 2001 From: Alberto Mardegan Date: Wed, 13 Apr 2016 16:28:57 +0300 Subject: QXcbDrag: forward mouse release event to initiator window MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The mouse release event which ends the drag and drop operation must be forwarded to the window where the drag started, and not to the QShapedPixmapWindow, which is not supposed to handle input events. Task-number: QTBUG-52541 Change-Id: I24a7c7b331a06342ac28b420ff9467aa05fe00dd Reviewed-by: Friedemann Kleint Reviewed-by: Błażej Szczygieł Reviewed-by: Dmitry Shachnev Reviewed-by: Shawn Rutledge --- src/plugins/platforms/xcb/qxcbdrag.cpp | 14 ++++++++++++++ src/plugins/platforms/xcb/qxcbdrag.h | 2 ++ 2 files changed, 16 insertions(+) diff --git a/src/plugins/platforms/xcb/qxcbdrag.cpp b/src/plugins/platforms/xcb/qxcbdrag.cpp index 529f91e1ec..6fa5dfa483 100644 --- a/src/plugins/platforms/xcb/qxcbdrag.cpp +++ b/src/plugins/platforms/xcb/qxcbdrag.cpp @@ -50,6 +50,7 @@ #include +#include #include #include #include @@ -170,6 +171,17 @@ QMimeData *QXcbDrag::platformDropData() return dropData; } +bool QXcbDrag::eventFilter(QObject *o, QEvent *e) +{ + /* We are setting a mouse grab on the QShapedPixmapWindow in order not to + * lose the grab when the virtual desktop changes, but + * QBasicDrag::eventFilter() expects the events to be coming from the + * window where the drag was started. */ + if (initiatorWindow && o == shapedPixmapWindow()) + o = initiatorWindow.data(); + return QBasicDrag::eventFilter(o, e); +} + void QXcbDrag::startDrag() { // #fixme enableEventFilter(); @@ -194,6 +206,7 @@ void QXcbDrag::startDrag() setUseCompositing(current_virtual_desktop->compositingActive()); setScreen(current_virtual_desktop->screens().constFirst()->screen()); + initiatorWindow = QGuiApplicationPrivate::currentMouseWindow; QBasicDrag::startDrag(); if (connection()->mouseGrabber() == Q_NULLPTR) shapedPixmapWindow()->setMouseGrabEnabled(true); @@ -202,6 +215,7 @@ void QXcbDrag::startDrag() void QXcbDrag::endDrag() { QBasicDrag::endDrag(); + initiatorWindow.clear(); } static xcb_translate_coordinates_reply_t * diff --git a/src/plugins/platforms/xcb/qxcbdrag.h b/src/plugins/platforms/xcb/qxcbdrag.h index c9d257906f..738da1268d 100644 --- a/src/plugins/platforms/xcb/qxcbdrag.h +++ b/src/plugins/platforms/xcb/qxcbdrag.h @@ -69,6 +69,7 @@ public: ~QXcbDrag(); virtual QMimeData *platformDropData() Q_DECL_OVERRIDE; + bool eventFilter(QObject *o, QEvent *e) Q_DECL_OVERRIDE; void startDrag() Q_DECL_OVERRIDE; void cancel() Q_DECL_OVERRIDE; @@ -106,6 +107,7 @@ private: Qt::DropAction toDropAction(xcb_atom_t atom) const; xcb_atom_t toXdndAction(Qt::DropAction a) const; + QPointer initiatorWindow; QPointer currentWindow; QPoint currentPosition; -- cgit v1.2.3 From d6cbf9efb7c42b10de5fe293589176019faf0373 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C5=82a=C5=BCej=20Szczygie=C5=82?= Date: Thu, 5 May 2016 14:03:56 +0200 Subject: xcb: Properly unset mousePressWindow() In some cases the mouse release event won't arrive, i.e. when window is minimized on button press. Check for mouse buttons state on mouse move event and properly unset the mousePressWindow to avoid blocking enter/leave events in this case. Amends: c511466d747d99ee76465cfe90ce594fa1f27469 Change-Id: I543a75104f528df1bf644bace13f78a6af017455 Reviewed-by: Shawn Rutledge --- src/plugins/platforms/xcb/qxcbwindow.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 226507f7a0..429ba8df71 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -2351,9 +2351,14 @@ void QXcbWindow::handleMotionNotifyEvent(int event_x, int event_y, int root_x, i QPoint local(event_x, event_y); QPoint global(root_x, root_y); - // "mousePressWindow" can be NULL i.e. if a window will be grabbed or umnapped, so set it again here - if (connection()->buttons() != Qt::NoButton && connection()->mousePressWindow() == Q_NULLPTR) + // "mousePressWindow" can be NULL i.e. if a window will be grabbed or unmapped, so set it again here. + // Unset "mousePressWindow" when mouse button isn't pressed - in some cases the release event won't arrive. + const bool isMouseButtonPressed = (connection()->buttons() != Qt::NoButton); + const bool hasMousePressWindow = (connection()->mousePressWindow() != Q_NULLPTR); + if (isMouseButtonPressed && !hasMousePressWindow) connection()->setMousePressWindow(this); + else if (hasMousePressWindow && !isMouseButtonPressed) + connection()->setMousePressWindow(Q_NULLPTR); handleMouseEvent(timestamp, local, global, modifiers, source); } -- cgit v1.2.3 From 7f5e8a5e3475c7f400a47ca821e78feb2e590222 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Tue, 3 May 2016 11:51:41 +0200 Subject: OS X: Remove unified toolbar test. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Qt 5 unified toolbar implementation does not move the toolbar to the “non-client” area. This test is no longer relevant. Change-Id: Ia32de2260f8ef400a0dc5acf3e5e3ff59083657a Reviewed-by: Timur Pocheptsov --- tests/auto/widgets/kernel/qwidget/BLACKLIST | 2 -- tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 41 +---------------------- 2 files changed, 1 insertion(+), 42 deletions(-) diff --git a/tests/auto/widgets/kernel/qwidget/BLACKLIST b/tests/auto/widgets/kernel/qwidget/BLACKLIST index 773f4205af..8fc882112e 100644 --- a/tests/auto/widgets/kernel/qwidget/BLACKLIST +++ b/tests/auto/widgets/kernel/qwidget/BLACKLIST @@ -40,8 +40,6 @@ osx osx [render_systemClip] osx -[childAt_unifiedToolBar] -osx [showMinimizedKeepsFocus] osx-10.10 [moveWindowInShowEvent:1] diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 20bdf00292..7e72007ac0 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -435,7 +435,6 @@ private slots: void movedAndResizedAttributes(); void childAt(); #ifdef Q_OS_OSX - void childAt_unifiedToolBar(); void taskQTBUG_11373(); #endif void taskQTBUG_17333_ResizeInfiniteRecursion(); @@ -9577,49 +9576,10 @@ void tst_QWidget::childAt() } #ifdef Q_OS_OSX -void tst_QWidget::childAt_unifiedToolBar() -{ - QLabel *label = new QLabel(QLatin1String("foo")); - QToolBar *toolBar = new QToolBar; - toolBar->addWidget(new QLabel("dummy")); - toolBar->addWidget(label); - - QMainWindow mainWindow; - mainWindow.addToolBar(toolBar); - mainWindow.show(); - - // Calculate the top-left corner of the tool bar and the label (in mainWindow's coordinates). - QPoint labelTopLeft = label->mapTo(&mainWindow, QPoint()); - QPoint toolBarTopLeft = toolBar->mapTo(&mainWindow, QPoint()); - - QCOMPARE(mainWindow.childAt(toolBarTopLeft), static_cast(toolBar)); - QCOMPARE(mainWindow.childAt(labelTopLeft), static_cast(label)); - - // Enable unified tool bars. - mainWindow.setUnifiedTitleAndToolBarOnMac(true); - QTest::qWait(50); - - // The tool bar is now in the "non-client" area of QMainWindow, i.e. - // outside the mainWindow's rect(), and since mapTo et al. doesn't work - // in that case (see commit 35667fd45ada49269a5987c235fdedfc43e92bb8), - // we use mapToGlobal/mapFromGlobal to re-calculate the corners. - QPoint oldToolBarTopLeft = toolBarTopLeft; - toolBarTopLeft = mainWindow.mapFromGlobal(toolBar->mapToGlobal(QPoint())); - QVERIFY2(toolBarTopLeft != oldToolBarTopLeft, - msgComparisonFailed(toolBarTopLeft, "!=", oldToolBarTopLeft)); - QVERIFY2(toolBarTopLeft.y() < 0, - msgComparisonFailed(toolBarTopLeft.y(), "<", 0)); - labelTopLeft = mainWindow.mapFromGlobal(label->mapToGlobal(QPoint())); - - QCOMPARE(mainWindow.childAt(toolBarTopLeft), static_cast(toolBar)); - QCOMPARE(mainWindow.childAt(labelTopLeft), static_cast(label)); -} void tst_QWidget::taskQTBUG_11373() { -#ifdef Q_OS_OSX QSKIP("QTBUG-52974"); -#endif QScopedPointer myWindow(new QMainWindow); QWidget * center = new QWidget(); @@ -9636,6 +9596,7 @@ void tst_QWidget::taskQTBUG_11373() // The drawer should still not be visible, since we haven't shown it. QCOMPARE(drawer->isVisible(), false); } + #endif void tst_QWidget::taskQTBUG_17333_ResizeInfiniteRecursion() -- cgit v1.2.3 From 95b8dfdb6fa834d93646352cf3715d0c71fe29da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Tue, 10 May 2016 12:18:24 +0200 Subject: tst_qwidget: remove sheetOpacity test Sheets are no longer transparent on newer OS X versions. Change-Id: Iaaed5aea9c9b130a5d991acd36717b76c3927cfb Reviewed-by: Timur Pocheptsov --- tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 7e72007ac0..183feb4020 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -269,7 +269,6 @@ private slots: void widgetAt(); #ifdef Q_OS_OSX - void sheetOpacity(); void setMask(); #endif void optimizedResizeMove(); @@ -3545,18 +3544,6 @@ void tst_QWidget::testDeletionInEventHandlers() } #ifdef Q_OS_OSX -void tst_QWidget::sheetOpacity() -{ - QSKIP("QTBUG-52974: this test will most probably be deleted - to be investigated."); - QWidget tmpWindow; - QWidget sheet(&tmpWindow, Qt::Sheet); - tmpWindow.show(); - sheet.show(); - QCOMPARE(int(sheet.windowOpacity() * 255), 242); // 95% - sheet.setParent(0, Qt::Dialog); - QCOMPARE(int(sheet.windowOpacity() * 255), 255); -} - class MaskedPainter : public QWidget { public: -- cgit v1.2.3 From 7e539002eec2229df21d405acd76dc4f1e1c0ae5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Tue, 3 May 2016 09:25:11 +0200 Subject: Enable movedAndResizedAttributes test. The test passes on OS X now. Task-number: QTBUG-8941 Change-Id: I7b57dc30ede7c1ed0bcb8bacb458ea56f222d987 Reviewed-by: Timur Pocheptsov --- tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 183feb4020..10d32472be 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -9455,10 +9455,6 @@ void tst_QWidget::taskQTBUG_7532_tabOrderWithFocusProxy() void tst_QWidget::movedAndResizedAttributes() { -#if defined (Q_OS_OSX) - QEXPECT_FAIL("", "FixMe, QTBUG-8941 and QTBUG-8977", Abort); - QVERIFY(false); -#else // Use Qt::Tool as fully decorated windows have a minimum width of 160 on QWidget w(0, Qt::Tool); w.show(); @@ -9504,7 +9500,6 @@ void tst_QWidget::movedAndResizedAttributes() w.resize(100, 100); QVERIFY(w.testAttribute(Qt::WA_Moved)); QVERIFY(w.testAttribute(Qt::WA_Resized)); -#endif } void tst_QWidget::childAt() -- cgit v1.2.3 From 4e0b76d810fe370f6a5c6e0242c487f026e809d3 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Fri, 6 May 2016 13:49:01 +0200 Subject: Cocoa integration - avoid dangling menuitem pointer Since QCocoaMenu can live longer than its m_attachedItem pointer, this pointer is becoming invalid after QCocoaMenuItem deleted (and its 'm_native' was released). Task-number: QTBUG-53251 Change-Id: I6d97b75b2c09e2443cd21415c5db94206d5d89ce Reviewed-by: Frederik Gladhorn Reviewed-by: Gabriel de Dietrich --- src/plugins/platforms/cocoa/qcocoamenuitem.mm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/platforms/cocoa/qcocoamenuitem.mm b/src/plugins/platforms/cocoa/qcocoamenuitem.mm index 0f422843e0..49f3da48c2 100644 --- a/src/plugins/platforms/cocoa/qcocoamenuitem.mm +++ b/src/plugins/platforms/cocoa/qcocoamenuitem.mm @@ -110,6 +110,8 @@ QCocoaMenuItem::~QCocoaMenuItem() if (m_merged) { [m_native setHidden:YES]; } else { + if (m_menu && m_menu->attachedItem() == m_native) + m_menu->setAttachedItem(nil); [m_native release]; } -- cgit v1.2.3 From 33c5df2887dc738f5c126e2fc406f7aecf63de5f Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 3 May 2016 18:38:16 +0200 Subject: decruft project files the "generated by qt creator" header is not supposed to be checked in. Change-Id: I7626c0bd16f83d81b3facd216a04e7d505942256 Reviewed-by: Joerg Bornemann --- tests/baselineserver/src/baselineserver.pro | 6 ------ tests/manual/qcursor/allcursors/allcursors.pro | 6 ------ tests/manual/qcursor/grab_override/grab_override.pro | 6 ------ tests/manual/qtbug-8933/qtbug-8933.pro | 6 ------ 4 files changed, 24 deletions(-) diff --git a/tests/baselineserver/src/baselineserver.pro b/tests/baselineserver/src/baselineserver.pro index 519cacea9c..a77014c1e6 100644 --- a/tests/baselineserver/src/baselineserver.pro +++ b/tests/baselineserver/src/baselineserver.pro @@ -1,9 +1,3 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2010-08-11T11:51:09 -# -#------------------------------------------------- - QT += core network # gui needed for QImage diff --git a/tests/manual/qcursor/allcursors/allcursors.pro b/tests/manual/qcursor/allcursors/allcursors.pro index c85ef861c2..72bec66940 100644 --- a/tests/manual/qcursor/allcursors/allcursors.pro +++ b/tests/manual/qcursor/allcursors/allcursors.pro @@ -1,9 +1,3 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2009-08-05T17:13:23 -# -#------------------------------------------------- - TARGET = tst_allcursors TEMPLATE = app QT = core gui widgets diff --git a/tests/manual/qcursor/grab_override/grab_override.pro b/tests/manual/qcursor/grab_override/grab_override.pro index d163a726c3..f105fa11e0 100644 --- a/tests/manual/qcursor/grab_override/grab_override.pro +++ b/tests/manual/qcursor/grab_override/grab_override.pro @@ -1,9 +1,3 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2009-08-05T17:13:23 -# -#------------------------------------------------- - TARGET = t_cursors TEMPLATE = app QT = core gui widgets diff --git a/tests/manual/qtbug-8933/qtbug-8933.pro b/tests/manual/qtbug-8933/qtbug-8933.pro index 0d8bfcc797..d92aa3ab66 100644 --- a/tests/manual/qtbug-8933/qtbug-8933.pro +++ b/tests/manual/qtbug-8933/qtbug-8933.pro @@ -1,9 +1,3 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2010-03-16T14:40:16 -# -#------------------------------------------------- - TARGET = qtbug-8933 TEMPLATE = app QT += widgets -- cgit v1.2.3 From 5dc421ec87eca15a72c82203319a9be7655cd56a Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Fri, 8 Apr 2016 09:10:08 +0200 Subject: Restore the missing -P option for lex handling We don't know why it works, but we've been told that it fixes some builds and we have no reason to think it will break others. Task-number: QTBUG-52998 Change-Id: Iacaa1fb3c49e4d7aafd4167e591ff3724489872e Reviewed-by: Oswald Buddenhagen --- mkspecs/features/lex.prf | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mkspecs/features/lex.prf b/mkspecs/features/lex.prf index 1ca9ae8afa..16d3a6aa94 100644 --- a/mkspecs/features/lex.prf +++ b/mkspecs/features/lex.prf @@ -11,9 +11,13 @@ lex.variable_out = GENERATED_SOURCES } + isEmpty(QMAKE_LEXFLAGS_MANGLE):QMAKE_LEXFLAGS_MANGLE = -P${QMAKE_FILE_BASE} + QMAKE_LEXEXTRAFLAGS = $$QMAKE_LEXFLAGS + !yacc_no_name_mangle:QMAKE_LEXEXTRAFLAGS += $$QMAKE_LEXFLAGS_MANGLE + contains(QMAKE_LEX, .*flex) { # GNU flex, we can use -o outfile - lex.commands = $$QMAKE_LEX $$QMAKE_LEXFLAGS --nounistd -o ${QMAKE_FILE_OUT} ${QMAKE_FILE_IN} + lex.commands = $$QMAKE_LEX $$QMAKE_LEXEXTRAFLAGS --nounistd -o ${QMAKE_FILE_OUT} ${QMAKE_FILE_IN} } else { # stupid POSIX lex, it only generates a file called lex.yy.c # or lex.prefix.c if the -P option is active -- cgit v1.2.3 From dbd81a0b9f884feae797c2a27a59cc9011fb32ff Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Tue, 3 May 2016 10:35:03 +0200 Subject: winrt: Fix potential startup crash Depending on the windowstate passed to QWinRTWindow constructor we might act on the uiElement which has not been created yet. This happened especially in release mode, probably due to timing. Hence delay uiElement changes until we created it in the constructor and can ensure it is valid. Change-Id: I00daa9fcf8542a0535bbcb663a76d85c36e510e2 Reviewed-by: Andrew Knight Reviewed-by: Oliver Wolff --- src/plugins/platforms/winrt/qwinrtwindow.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/plugins/platforms/winrt/qwinrtwindow.cpp b/src/plugins/platforms/winrt/qwinrtwindow.cpp index f5407f8779..75b43205b7 100644 --- a/src/plugins/platforms/winrt/qwinrtwindow.cpp +++ b/src/plugins/platforms/winrt/qwinrtwindow.cpp @@ -108,9 +108,6 @@ QWinRTWindow::QWinRTWindow(QWindow *window) d->surface = EGL_NO_SURFACE; d->display = EGL_NO_DISPLAY; d->screen = static_cast(screen()); - setWindowFlags(window->flags()); - setWindowState(window->windowState()); - setWindowTitle(window->title()); handleContentOrientationChange(window->contentOrientation()); d->surfaceFormat.setAlphaBufferSize(0); @@ -158,6 +155,10 @@ QWinRTWindow::QWinRTWindow(QWindow *window) }); Q_ASSERT_SUCCEEDED(hr); + setWindowFlags(window->flags()); + setWindowState(window->windowState()); + setWindowTitle(window->title()); + setGeometry(window->geometry()); } -- cgit v1.2.3 From 6a84a51611f69f3641ae47bbd7b6bd5266ae88ef Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Wed, 6 Apr 2016 10:51:55 -0700 Subject: QWidgetWindow: Guard reference to own widget ~QWidgetPrivate() may end up calling QWidgetPrivate:: deleteTLSysExtra() which, in turn, calls QWindow::destroy(). This sends an event to the window itself. This reaches QWidgetWindow::event() which will forward the event to the widget. However, the widget has just been deleted since the sequence was initiated by ~QObject(). Task-number: QTBUG-53103 Change-Id: Ib511714a76bbc1e734d6f2800a983eb1459bbf0b Reviewed-by: Marc Mutz Reviewed-by: Friedemann Kleint --- src/widgets/kernel/qwidgetwindow.cpp | 7 +++++-- src/widgets/kernel/qwidgetwindow_p.h | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp index b638c6c377..ec2618e501 100644 --- a/src/widgets/kernel/qwidgetwindow.cpp +++ b/src/widgets/kernel/qwidgetwindow.cpp @@ -123,7 +123,7 @@ QWidgetWindow::QWidgetWindow(QWidget *widget) && !QApplication::testAttribute(Qt::AA_ForceRasterWidgets)) { setSurfaceType(QSurface::RasterGLSurface); } - connect(m_widget, &QObject::objectNameChanged, this, &QWidgetWindow::updateObjectName); + connect(widget, &QObject::objectNameChanged, this, &QWidgetWindow::updateObjectName); connect(this, SIGNAL(screenChanged(QScreen*)), this, SLOT(handleScreenChange())); } @@ -174,6 +174,9 @@ static inline bool shouldBePropagatedToWidget(QEvent *event) bool QWidgetWindow::event(QEvent *event) { + if (!m_widget) + return QWindow::event(event); + if (m_widget->testAttribute(Qt::WA_DontShowOnScreen)) { // \a event is uninteresting for QWidgetWindow, the event was probably // generated before WA_DontShowOnScreen was set @@ -375,7 +378,7 @@ void QWidgetWindow::handleEnterLeaveEvent(QEvent *event) } else { const QEnterEvent *ee = static_cast(event); QWidget *child = m_widget->childAt(ee->pos()); - QWidget *receiver = child ? child : m_widget; + QWidget *receiver = child ? child : m_widget.data(); QApplicationPrivate::dispatchEnterLeave(receiver, 0, ee->screenPos()); qt_last_mouse_receiver = receiver; } diff --git a/src/widgets/kernel/qwidgetwindow_p.h b/src/widgets/kernel/qwidgetwindow_p.h index ca4bac8d86..7fafb01b3d 100644 --- a/src/widgets/kernel/qwidgetwindow_p.h +++ b/src/widgets/kernel/qwidgetwindow_p.h @@ -119,7 +119,7 @@ private: }; QWidget *getFocusWidget(FocusWidgets fw); - QWidget *m_widget; + QPointer m_widget; QPointer m_implicit_mouse_grabber; #ifndef QT_NO_DRAGANDDROP QPointer m_dragTarget; -- cgit v1.2.3 From ce37467acf34edf1380f896a0942b616dc4cbead Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Fri, 29 Apr 2016 16:32:42 -0700 Subject: Acknowledge QWidgetWindow::widget() may be null We guard QWidgetWindow's widget with a QPointer to avoid sending it events during destruction (which may result in undefined behavior, since this originates from ~QObject and we expect the object to behave as a QWidget). Therefore, we need to harden all access to that widget since it can now be null, specially during destruction. As an example, QGestureManager may crash when we delete a top-level widget. The crash stack trace is: 1 QScopedPointer>::data() const 2 QScopedPointer>::pointer qGetPtrHelper>>(QScopedPointer> const&) 3 QWidget::d_func() 4 QGestureManager::filterEvent(QWidget *, QEvent *) <-- the widget ptr is null 5 QGestureManager::filterEvent(QObject *, QEvent *) 6 QApplication::notify(QObject *, QEvent *) 7 QCoreApplication::notifyInternal2(QObject *, QEvent *) 8 QCoreApplication::sendEvent(QObject *, QEvent *) 9 QWindow::destroy() 10 QWidgetPrivate::deleteTLSysExtra() 11 QWidgetPrivate::deleteExtra() 12 QWidgetPrivate::~QWidgetPrivate() 13 QWidgetPrivate::~QWidgetPrivate() 14 QWidgetPrivate::~QWidgetPrivate() 15 QScopedPointerDeleter::cleanup(QObjectData *) 16 QScopedPointer>::~QScopedPointer() 17 QScopedPointer>::~QScopedPointer() 18 QObject::~QObject() 19 QWidget::~QWidget() Task-number: QTBUG-53103 Change-Id: I1bb32648270c4f7791f668b8f0b639ddb4235703 Reviewed-by: Shawn Rutledge Reviewed-by: Marc Mutz --- src/widgets/kernel/qapplication.cpp | 8 ++++---- src/widgets/kernel/qgesturemanager.cpp | 2 +- src/widgets/kernel/qwidgetwindow.cpp | 20 +++++++++++--------- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index a459a57482..fcc195f601 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -2249,10 +2249,10 @@ void QApplicationPrivate::notifyActiveWindowChange(QWindow *previous) QApplication::setActiveWindow(tlw); // QTBUG-37126, Active X controls may set the focus on native child widgets. if (wnd && tlw && wnd != tlw->windowHandle()) { - if (QWidgetWindow *widgetWindow = qobject_cast(wnd)) { - if (widgetWindow->widget()->inherits("QAxHostWidget")) - widgetWindow->widget()->setFocus(Qt::ActiveWindowFocusReason); - } + if (QWidgetWindow *widgetWindow = qobject_cast(wnd)) + if (QWidget *widget = widgetWindow->widget()) + if (widget->inherits("QAxHostWidget")) + widget->setFocus(Qt::ActiveWindowFocusReason); } } diff --git a/src/widgets/kernel/qgesturemanager.cpp b/src/widgets/kernel/qgesturemanager.cpp index 967ef6b40c..89ed6922b5 100644 --- a/src/widgets/kernel/qgesturemanager.cpp +++ b/src/widgets/kernel/qgesturemanager.cpp @@ -545,7 +545,7 @@ bool QGestureManager::filterEvent(QObject *receiver, QEvent *event) // filter method. QWidgetWindow *widgetWindow = qobject_cast(receiver); - if (widgetWindow) + if (widgetWindow && widgetWindow->widget()) return filterEvent(widgetWindow->widget(), event); QGesture *state = qobject_cast(receiver); diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp index ec2618e501..5290d79d9e 100644 --- a/src/widgets/kernel/qwidgetwindow.cpp +++ b/src/widgets/kernel/qwidgetwindow.cpp @@ -87,7 +87,7 @@ QRectF QWidgetWindowPrivate::closestAcceptableGeometry(const QRectF &rect) const { Q_Q(const QWidgetWindow); const QWidget *widget = q->widget(); - if (!widget->isWindow() || !widget->hasHeightForWidth()) + if (!widget || !widget->isWindow() || !widget->hasHeightForWidth()) return QRect(); const QSize oldSize = rect.size().toSize(); const QSize newSize = QLayout::closestAcceptableSize(widget, oldSize); @@ -142,16 +142,18 @@ QAccessibleInterface *QWidgetWindow::accessibleRoot() const QObject *QWidgetWindow::focusObject() const { - QWidget *widget = m_widget->focusWidget(); + QWidget *windowWidget = m_widget; + if (!windowWidget) + return Q_NULLPTR; + + QWidget *widget = windowWidget->focusWidget(); if (!widget) - widget = m_widget; + widget = windowWidget; - if (widget) { - QObject *focusObj = QWidgetPrivate::get(widget)->focusObject(); - if (focusObj) - return focusObj; - } + QObject *focusObj = QWidgetPrivate::get(widget)->focusObject(); + if (focusObj) + return focusObj; return widget; } @@ -204,7 +206,7 @@ bool QWidgetWindow::event(QEvent *event) #ifndef QT_NO_ACCESSIBILITY QAccessible::State state; state.active = true; - QAccessibleStateChangeEvent ev(widget(), state); + QAccessibleStateChangeEvent ev(m_widget, state); QAccessible::updateAccessibility(&ev); #endif return false; } -- cgit v1.2.3 From ab3a8443faa36799ab8142e48d25d8ff10f9d0bf Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Fri, 29 Apr 2016 18:07:36 +0200 Subject: QCocoaWindow - do not call resignKeyWindow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QCocoaWindow::setMouseGrabEnabled/setKeyboardGrabEnabled calls resignKeyWindow. According to Apple's docs, we should _never_ call this function (it's done by Cocoa automatically). Calling this function leaves a window in weird state where it can not become key again until you explicitly make another window key first. Task-number: QTBUG-53050 Change-Id: I7a887659df8df11880328ffa2adc07c4a3af63e6 Reviewed-by: Gabriel de Dietrich Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoawindow.mm | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index dd67946a27..c5519995b6 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -1135,8 +1135,7 @@ bool QCocoaWindow::setKeyboardGrabEnabled(bool grab) if (grab && ![m_nsWindow isKeyWindow]) [m_nsWindow makeKeyWindow]; - else if (!grab && [m_nsWindow isKeyWindow]) - [m_nsWindow resignKeyWindow]; + return true; } @@ -1147,8 +1146,7 @@ bool QCocoaWindow::setMouseGrabEnabled(bool grab) if (grab && ![m_nsWindow isKeyWindow]) [m_nsWindow makeKeyWindow]; - else if (!grab && [m_nsWindow isKeyWindow]) - [m_nsWindow resignKeyWindow]; + return true; } -- cgit v1.2.3 From acf43c17b647cdbfc3186bb8bf7e183df67a090b Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Tue, 1 Mar 2016 15:44:06 +0300 Subject: QFileSystemModel: create nodes with correct QFileInfos Create parent nodes with the corresponding paths, not with the absolute path of the child node. Otherwise we will get incorrect QFileInfo at least in the following case: QFileSystemModel model; model.setRootPath("/usr/bin"); QModelIndex idx = model.setRootPath("/usr"); qDebug() << model.fileInfo(idx).absoluteFilePath(); Without the fix it prints "/usr/bin". It's a regression triggered by 61cefb2f7a7cb16dfa2732e26d2319017039ef62 (De-inline QFileSystemModel::fileInfo() and implement it efficiently). Change-Id: I3b4e5f5b256711e27ad50824eaa8492dbc096808 Task-number: QTBUG-51586 Reviewed-by: Lars Knoll --- src/widgets/dialogs/qfilesystemmodel.cpp | 21 +++++++++++++++------ .../widgets/dialogs/qfiledialog/tst_qfiledialog.cpp | 16 ++++++++++++++++ .../qfilesystemmodel/tst_qfilesystemmodel.cpp | 21 +++++++++++++++++++++ 3 files changed, 52 insertions(+), 6 deletions(-) diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp index 9bf5a502c3..0e2eee3b47 100644 --- a/src/widgets/dialogs/qfilesystemmodel.cpp +++ b/src/widgets/dialogs/qfilesystemmodel.cpp @@ -351,6 +351,9 @@ QFileSystemModelPrivate::QFileSystemNode *QFileSystemModelPrivate::node(const QS ) return const_cast(&root); QModelIndex index = QModelIndex(); // start with "My Computer" + QString elementPath; + QChar separator = QLatin1Char('/'); + QString trailingSeparator; #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) if (absolutePath.startsWith(QLatin1String("//"))) { // UNC path QString host = QLatin1String("\\\\") + pathElements.first(); @@ -358,6 +361,8 @@ QFileSystemModelPrivate::QFileSystemNode *QFileSystemModelPrivate::node(const QS absolutePath.append(QLatin1Char('/')); if (longPath.endsWith(QLatin1Char('/')) && !absolutePath.endsWith(QLatin1Char('/'))) absolutePath.append(QLatin1Char('/')); + if (absolutePath.endsWith(QLatin1Char('/'))) + trailingSeparator = QLatin1String("\\"); int r = 0; QFileSystemModelPrivate::QFileSystemNode *rootNode = const_cast(&root); if (!root.children.contains(host.toLower())) { @@ -374,11 +379,10 @@ QFileSystemModelPrivate::QFileSystemNode *QFileSystemModelPrivate::node(const QS r = translateVisibleLocation(rootNode, r); index = q->index(r, 0, QModelIndex()); pathElements.pop_front(); - } else -#endif - -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) - { + separator = QLatin1Char('\\'); + elementPath = host; + elementPath.append(separator); + } else { if (!pathElements.at(0).contains(QLatin1Char(':'))) { QString rootPath = QDir(longPath).rootPath(); pathElements.prepend(rootPath); @@ -396,6 +400,11 @@ QFileSystemModelPrivate::QFileSystemNode *QFileSystemModelPrivate::node(const QS for (int i = 0; i < pathElements.count(); ++i) { QString element = pathElements.at(i); + if (i != 0) + elementPath.append(separator); + elementPath.append(element); + if (i == pathElements.count() - 1) + elementPath.append(trailingSeparator); #ifdef Q_OS_WIN // On Windows, "filename " and "filename" are equivalent and // "filename . " and "filename" are equivalent @@ -427,7 +436,7 @@ QFileSystemModelPrivate::QFileSystemNode *QFileSystemModelPrivate::node(const QS if (!alreadyExisted) { // Someone might call ::index("file://cookie/monster/doesn't/like/veggies"), // a path that doesn't exists, I.E. don't blindly create directories. - QFileInfo info(absolutePath); + QFileInfo info(elementPath); if (!info.exists()) return const_cast(&root); QFileSystemModelPrivate *p = const_cast(this); diff --git a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp index 42e2bd09a5..05f42cf685 100644 --- a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp +++ b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp @@ -569,6 +569,22 @@ void tst_QFiledialog::completer() if (expectedFile.startsWith(input, caseSensitivity)) ++expected; } + // The temporary dir may create a node in QFileSystemModel + // which will bypass filters. If the path to the temporary + // dir contains an element which should be a subdirectory + // of x dir, but which is not listed, then take it into + // accont. + if (!tempDir.isNull()) { + QString xPath = x.absolutePath(); + if (!xPath.endsWith(QLatin1Char('/'))) + xPath.append(QLatin1Char('/')); + QString tmpPath = tempDir->path(); + if (tmpPath.startsWith(xPath)) { + QString bypassedDirName = tmpPath.mid(xPath.size()).section(QLatin1Char('/'), 0, 0); + if (!expectedFiles.contains(bypassedDirName)) + ++expected; + } + } } QTRY_COMPARE(cModel->rowCount(), expected); diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp index 19b1d0e7c8..b27943f071 100644 --- a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp +++ b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp @@ -126,6 +126,8 @@ private slots: void doNotUnwatchOnFailedRmdir(); void specialFiles(); + void fileInfo(); + protected: bool createFiles(const QString &test_path, const QStringList &initial_files, int existingFileCount = 0, const QStringList &intial_dirs = QStringList()); @@ -1146,6 +1148,25 @@ void tst_QFileSystemModel::specialFiles() QTRY_VERIFY(!fileListUnderIndex(&model, rootIndex).contains(testFileName)); } +void tst_QFileSystemModel::fileInfo() +{ + QFileSystemModel model; + QModelIndex idx; + + QVERIFY(model.fileInfo(idx).filePath().isEmpty()); + + const QString dirPath = flatDirTestPath; + QDir dir(dirPath); + const QString subdir = QStringLiteral("subdir"); + QVERIFY(dir.mkdir(subdir)); + const QString subdirPath = dir.absoluteFilePath(subdir); + + idx = model.setRootPath(subdirPath); + QCOMPARE(model.fileInfo(idx), QFileInfo(subdirPath)); + idx = model.setRootPath(dirPath); + QCOMPARE(model.fileInfo(idx), QFileInfo(dirPath)); +} + QTEST_MAIN(tst_QFileSystemModel) #include "tst_qfilesystemmodel.moc" -- cgit v1.2.3 From 40a9216e068b804cb9f048ad639a3bb85b185341 Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Fri, 29 Apr 2016 11:16:31 +0200 Subject: Avoid asserting when painting certain degenerate bezier paths It could happen that the stroker would attempt to join empty subpaths, resulting in an invalid path structure that would cause assert later. Task-number: QTBUG-43474 Change-Id: Ia369a31e60c40cdae3900d96f15f3e83c9e78b97 Reviewed-by: Lars Knoll --- src/gui/painting/qstroker.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/painting/qstroker.cpp b/src/gui/painting/qstroker.cpp index fc344dc3ac..f6c899a815 100644 --- a/src/gui/painting/qstroker.cpp +++ b/src/gui/painting/qstroker.cpp @@ -422,7 +422,7 @@ void QStroker::processCurrentSubpath() bool fwclosed = qt_stroke_side(&fwit, this, false, &fwStartTangent); bool bwclosed = qt_stroke_side(&bwit, this, !fwclosed, &bwStartTangent); - if (!bwclosed) + if (!bwclosed && !fwStartTangent.isNull()) joinPoints(m_elements.at(0).x, m_elements.at(0).y, fwStartTangent, m_capStyle); } -- cgit v1.2.3 From edc4f024104b914c00f7c9354a7805243ce04572 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 11 May 2016 12:40:14 +0200 Subject: make -R and -D not affect qmake this was meant to be part of d8be8110a, as qmake is obviously also a bootstrapped tool. -I/-L/-F/-l/-fw already had no effect on qmake. Change-Id: I5095742ef5401558cc4432e7a774d0851d417bb0 Reviewed-by: Lars Knoll --- configure | 9 --------- 1 file changed, 9 deletions(-) diff --git a/configure b/configure index 5d02827890..f4555a746b 100755 --- a/configure +++ b/configure @@ -4051,12 +4051,6 @@ if true; then ###[ '!' -f "$outpath/bin/qmake" ]; EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS \$(QMAKE_CXXFLAGS_DEBUG)" fi - if [ -n "$RPATH_FLAGS" ] && [ -n "`getQMakeConf 'QMAKE_(LFLAGS_)?RPATH'`" ]; then - setBootstrapVariable "QMAKE_(LFLAGS_)?RPATH" QMAKE_LFLAGS_RPATH - for rpath in $RPATH_FLAGS; do - EXTRA_LFLAGS="\$(QMAKE_LFLAGS_RPATH)\"$rpath\" $EXTRA_LFLAGS" - done - fi if [ "$BUILD_ON_MSYS" = "yes" ]; then EXTRA_CFLAGS="$EXTRA_CFLAGS -DUNICODE" EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS -DUNICODE" @@ -4104,9 +4098,6 @@ if true; then ###[ '!' -f "$outpath/bin/qmake" ]; \"\$(SOURCE_PATH)/src/corelib/kernel/qcore_mac.cpp\" \ \"\$(SOURCE_PATH)/src/corelib/kernel/qcore_mac_objc.mm\"" fi - if [ '!' -z "$D_FLAGS" ]; then - EXTRA_CFLAGS="$EXTRA_CFLAGS $D_FLAGS" - fi echo >>"$mkfile" adjrelpath=`echo "$relpath" | sed 's/ /\\\\\\\\ /g'` adjoutpath=`echo "$outpath" | sed 's/ /\\\\\\\\ /g'` -- cgit v1.2.3 From c46f74d325892b0f3b3068241535c32ffe6e3a98 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Fri, 22 Apr 2016 16:38:32 +0200 Subject: eglfs: Support dynamic mouse cursor show/hide with DRM HW cursor Task-number: QTBUG-52743 Change-Id: I0bea1451dfe7b049c129b11716d593115e3d8374 Reviewed-by: Louai Al-Khanji --- .../eglfs_kms/qeglfskmscursor.cpp | 59 +++++++++++++++++++--- .../deviceintegration/eglfs_kms/qeglfskmscursor.h | 30 ++++++++++- 2 files changed, 81 insertions(+), 8 deletions(-) diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmscursor.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmscursor.cpp index 97ea3f1eca..830e270eeb 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmscursor.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmscursor.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2015 Pier Luigi Fiorini -** Copyright (C) 2015 The Qt Company Ltd. +** Copyright (C) 2016 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the plugins of the Qt Toolkit. @@ -41,6 +41,7 @@ #include #include #include +#include #include #include @@ -62,13 +63,13 @@ QEglFSKmsCursor::QEglFSKmsCursor(QEglFSKmsScreen *screen) , m_cursorSize(64, 64) // 64x64 is the old standard size, we now try to query the real size below , m_bo(Q_NULLPTR) , m_cursorImage(0, 0, 0, 0, 0, 0) - , m_visible(true) + , m_state(CursorPendingVisible) { QByteArray hideCursorVal = qgetenv("QT_QPA_EGLFS_HIDECURSOR"); - if (!hideCursorVal.isEmpty()) - m_visible = hideCursorVal.toInt() == 0; - if (!m_visible) + if (!hideCursorVal.isEmpty() && hideCursorVal.toInt()) { + m_state = CursorDisabled; return; + } uint64_t width, height; if ((drmGetCap(m_screen->device()->fd(), DRM_CAP_CURSOR_WIDTH, &width) == 0) @@ -85,6 +86,12 @@ QEglFSKmsCursor::QEglFSKmsCursor(QEglFSKmsScreen *screen) initCursorAtlas(); } + m_deviceListener = new QEglFSKmsCursorDeviceListener(this); + connect(QGuiApplicationPrivate::inputDeviceManager(), &QInputDeviceManager::deviceListChanged, + m_deviceListener, &QEglFSKmsCursorDeviceListener::onDeviceListChanged); + if (!m_deviceListener->hasMouse()) + m_state = CursorPendingHidden; + #ifndef QT_NO_CURSOR QCursor cursor(Qt::ArrowCursor); changeCursor(&cursor, 0); @@ -94,6 +101,8 @@ QEglFSKmsCursor::QEglFSKmsCursor(QEglFSKmsScreen *screen) QEglFSKmsCursor::~QEglFSKmsCursor() { + delete m_deviceListener; + Q_FOREACH (QPlatformScreen *screen, m_screen->virtualSiblings()) { QEglFSKmsScreen *kmsScreen = static_cast(screen); drmModeSetCursor(kmsScreen->device()->fd(), kmsScreen->output().crtc_id, 0, 0, 0); @@ -106,6 +115,31 @@ QEglFSKmsCursor::~QEglFSKmsCursor() } } +void QEglFSKmsCursor::updateMouseStatus() +{ + const bool wasVisible = m_state == CursorVisible; + const bool visible = m_deviceListener->hasMouse(); + if (visible == wasVisible) + return; + + m_state = visible ? CursorPendingVisible : CursorPendingHidden; + +#ifndef QT_NO_CURSOR + changeCursor(nullptr, m_screen->topLevelAt(pos())); +#endif +} + +bool QEglFSKmsCursorDeviceListener::hasMouse() const +{ + return QGuiApplicationPrivate::inputDeviceManager()->deviceCount(QInputDeviceManager::DeviceTypePointer) > 0; +} + +void QEglFSKmsCursorDeviceListener::onDeviceListChanged(QInputDeviceManager::DeviceType type) +{ + if (type == QInputDeviceManager::DeviceTypePointer) + m_cursor->updateMouseStatus(); +} + void QEglFSKmsCursor::pointerEvent(const QMouseEvent &event) { setPos(event.screenPos().toPoint()); @@ -119,7 +153,15 @@ void QEglFSKmsCursor::changeCursor(QCursor *windowCursor, QWindow *window) if (!m_bo) return; - if (!m_visible) + if (m_state == CursorPendingHidden) { + m_state = CursorHidden; + Q_FOREACH (QPlatformScreen *screen, m_screen->virtualSiblings()) { + QEglFSKmsScreen *kmsScreen = static_cast(screen); + drmModeSetCursor(kmsScreen->device()->fd(), kmsScreen->output().crtc_id, 0, 0, 0); + } + } + + if (m_state == CursorHidden || m_state == CursorDisabled) return; const Qt::CursorShape newShape = windowCursor ? windowCursor->shape() : Qt::ArrowCursor; @@ -159,6 +201,9 @@ void QEglFSKmsCursor::changeCursor(QCursor *windowCursor, QWindow *window) uint32_t handle = gbm_bo_get_handle(m_bo).u32; + if (m_state == CursorPendingVisible) + m_state = CursorVisible; + Q_FOREACH (QPlatformScreen *screen, m_screen->virtualSiblings()) { QEglFSKmsScreen *kmsScreen = static_cast(screen); @@ -206,7 +251,7 @@ void QEglFSKmsCursor::initCursorAtlas() drmModeSetCursor(kmsScreen->device()->fd(), kmsScreen->output().crtc_id, 0, 0, 0); drmModeMoveCursor(kmsScreen->device()->fd(), kmsScreen->output().crtc_id, 0, 0); } - m_visible = false; + m_state = CursorDisabled; return; } diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmscursor.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmscursor.h index 68bc72a03f..f26df91be5 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmscursor.h +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmscursor.h @@ -37,12 +37,29 @@ #include #include #include +#include #include QT_BEGIN_NAMESPACE class QEglFSKmsScreen; +class QEglFSKmsCursor; + +class QEglFSKmsCursorDeviceListener : public QObject +{ + Q_OBJECT + +public: + QEglFSKmsCursorDeviceListener(QEglFSKmsCursor *cursor) : m_cursor(cursor) { } + bool hasMouse() const; + +public slots: + void onDeviceListChanged(QInputDeviceManager::DeviceType type); + +private: + QEglFSKmsCursor *m_cursor; +}; class QEglFSKmsCursor : public QPlatformCursor { @@ -60,15 +77,26 @@ public: QPoint pos() const Q_DECL_OVERRIDE; void setPos(const QPoint &pos) Q_DECL_OVERRIDE; + void updateMouseStatus(); + private: void initCursorAtlas(); + enum CursorState { + CursorDisabled, + CursorPendingHidden, + CursorHidden, + CursorPendingVisible, + CursorVisible + }; + QEglFSKmsScreen *m_screen; QSize m_cursorSize; gbm_bo *m_bo; QPoint m_pos; QPlatformCursorImage m_cursorImage; - bool m_visible; + CursorState m_state; + QEglFSKmsCursorDeviceListener *m_deviceListener; // cursor atlas information struct CursorAtlas { -- cgit v1.2.3 From 81793b8b58cde01e52675093dc378147dc2102e3 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 10 May 2016 10:49:11 +0200 Subject: Add QT_NO_FOREACH to disable foreach and Q_FOREACH It has been known for a long time that Q_FOREACH produces inferior code to other looping constructs, and the use of it in Qt library code was informally frowned upon since forever (pun intended). Yet, to this day, several thousand foreach/Q_FOREACH loops have been added to Qt libraries, and while many were ported to range-for in Qt 5.7, there are still new ones added every day, which is a nuisance, to say the least. This patch introduces a technical way to prevent new foreach use to creep into Qt libraries after they have been cleaned, by simply not defining either Q_FOREACH or foreach when the QT_NO_FOREACH macro is defined. This way, one library at a time can be ported away, and, once ported, is guaranteed to actually stay ported. Change-Id: Ie042e84d6c7d766bd16095f9bc1118a8e0ce0c7a Reviewed-by: Thiago Macieira --- src/corelib/global/qglobal.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index a72bdb4d59..e35ee0987f 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -932,6 +932,8 @@ QT_WARNING_DISABLE_MSVC(4530) /* C++ exception handler used, but unwind semantic # endif #endif +#ifndef QT_NO_FOREACH + template class QForeachContainer { QForeachContainer &operator=(const QForeachContainer &) Q_DECL_EQ_DELETE; @@ -957,11 +959,15 @@ for (QForeachContainer ++_container_.i, _container_.control ^= 1) \ for (variable = *_container_.i; _container_.control; _container_.control = 0) +#endif // QT_NO_FOREACH + #define Q_FOREVER for(;;) #ifndef QT_NO_KEYWORDS +# ifndef QT_NO_FOREACH # ifndef foreach # define foreach Q_FOREACH # endif +# endif // QT_NO_FOREACH # ifndef forever # define forever Q_FOREVER # endif -- cgit v1.2.3 From f0d7080e9e640fdc7b540aba69bfbc14fc96ce39 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 11 May 2016 11:53:02 +0200 Subject: qmake/tools: port the last remaining Q_FOREACH loops and add QT_NO_FOREACH Port the last four remaining Q_FOREACH users in qmake and uic to C++11 range-for and mark all qtbase tools (incl. qmake) as Q_FOREACH-free, using QT_NO_FOREACH. Change-Id: Ief4e5877269e7a853e4cf05e58861a448e822d3d Reviewed-by: Oswald Buddenhagen Reviewed-by: Lars Knoll --- qmake/Makefile.unix | 1 + qmake/Makefile.win32 | 1 + qmake/generators/win32/msvc_vcproj.cpp | 2 +- qmake/qmake.pro | 1 + src/tools/bootstrap-dbus/bootstrap-dbus.pro | 1 + src/tools/bootstrap/bootstrap.pro | 1 + src/tools/moc/moc.pro | 7 ++++++- src/tools/qdbuscpp2xml/qdbuscpp2xml.pro | 2 +- src/tools/qdbusxml2cpp/qdbusxml2cpp.pro | 2 +- src/tools/qlalr/qlalr.pro | 3 +++ src/tools/rcc/rcc.pro | 2 +- src/tools/uic/cpp/cppwriteinitialization.cpp | 10 +++++----- src/tools/uic/uic.pro | 2 +- 13 files changed, 24 insertions(+), 11 deletions(-) diff --git a/qmake/Makefile.unix b/qmake/Makefile.unix index 405bbf9212..9d3ddab6f9 100644 --- a/qmake/Makefile.unix +++ b/qmake/Makefile.unix @@ -106,6 +106,7 @@ CPPFLAGS = -g $(EXTRA_CPPFLAGS) \ -DQT_BUILD_QMAKE -DQT_BOOTSTRAPPED -DPROEVALUATOR_FULL \ -DQT_NO_TEXTCODEC -DQT_NO_UNICODETABLES -DQT_NO_COMPONENT -DQT_NO_COMPRESS \ -DQT_NO_THREAD -DQT_NO_QOBJECT -DQT_NO_GEOM_VARIANT -DQT_NO_DATASTREAM \ + -DQT_NO_FOREACH \ -DQT_CRYPTOGRAPHICHASH_ONLY_SHA1 -DQT_JSON_READONLY -DQT_NO_STANDARDPATHS CXXFLAGS = $(EXTRA_CXXFLAGS) $(CPPFLAGS) diff --git a/qmake/Makefile.win32 b/qmake/Makefile.win32 index 1d50f872d9..834065ee61 100644 --- a/qmake/Makefile.win32 +++ b/qmake/Makefile.win32 @@ -49,6 +49,7 @@ CFLAGS_BARE = -c -Fo./ -Fdqmake.pdb \ -DQT_BUILD_QMAKE -DQT_BOOTSTRAPPED -DPROEVALUATOR_FULL \ -DQT_NO_TEXTCODEC -DQT_NO_UNICODETABLES -DQT_NO_COMPONENT -DQT_NO_COMPRESS \ -DQT_NO_THREAD -DQT_NO_QOBJECT -DQT_NO_GEOM_VARIANT -DQT_NO_DATASTREAM \ + -DQT_NO_FOREACH \ -DUNICODE -DQT_CRYPTOGRAPHICHASH_ONLY_SHA1 -DQT_JSON_READONLY -DQT_NO_STANDARDPATHS CFLAGS = $(CFLAGS_PCH) $(CFLAGS_BARE) $(CFLAGS) diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp index a972316972..9486cf8b6f 100644 --- a/qmake/generators/win32/msvc_vcproj.cpp +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -1316,7 +1316,7 @@ void VcprojGenerator::initDeploymentTool() if (foundGuid || dllName.contains(QLatin1String("Gui"))) { QFileInfo info2; - foreach (const ProString &dllPath, dllPaths) { + for (const ProString &dllPath : dllPaths) { QString absoluteDllFilePath = dllPath.toQString(); if (!absoluteDllFilePath.endsWith(QLatin1Char('/'))) absoluteDllFilePath += QLatin1Char('/'); diff --git a/qmake/qmake.pro b/qmake/qmake.pro index 89d6ea5fc1..74cefb07aa 100644 --- a/qmake/qmake.pro +++ b/qmake/qmake.pro @@ -7,6 +7,7 @@ CONFIG += console bootstrap CONFIG -= qt DEFINES += \ QT_BUILD_QMAKE \ + QT_NO_FOREACH \ PROEVALUATOR_FULL VPATH += \ diff --git a/src/tools/bootstrap-dbus/bootstrap-dbus.pro b/src/tools/bootstrap-dbus/bootstrap-dbus.pro index 3b28c23311..c3ed27d979 100644 --- a/src/tools/bootstrap-dbus/bootstrap-dbus.pro +++ b/src/tools/bootstrap-dbus/bootstrap-dbus.pro @@ -5,6 +5,7 @@ TARGET = QtBootstrapDBus CONFIG += minimal_syncqt internal_module force_bootstrap DEFINES += \ + QT_NO_FOREACH \ QT_NO_CAST_FROM_ASCII MODULE_INCNAME = QtDBus diff --git a/src/tools/bootstrap/bootstrap.pro b/src/tools/bootstrap/bootstrap.pro index 3cfdbf3429..5fbabe8fe4 100644 --- a/src/tools/bootstrap/bootstrap.pro +++ b/src/tools/bootstrap/bootstrap.pro @@ -23,6 +23,7 @@ MODULE_DEFINES = \ DEFINES += \ $$MODULE_DEFINES \ QT_CRYPTOGRAPHICHASH_ONLY_SHA1 \ + QT_NO_FOREACH \ QT_NO_CAST_FROM_ASCII DEFINES -= QT_EVAL diff --git a/src/tools/moc/moc.pro b/src/tools/moc/moc.pro index d39749a318..ccd29341d0 100644 --- a/src/tools/moc/moc.pro +++ b/src/tools/moc/moc.pro @@ -1,7 +1,12 @@ option(host_build) CONFIG += force_bootstrap -DEFINES += QT_MOC QT_NO_CAST_FROM_ASCII QT_NO_CAST_FROM_BYTEARRAY QT_NO_COMPRESS +DEFINES += \ + QT_MOC \ + QT_NO_CAST_FROM_ASCII \ + QT_NO_CAST_FROM_BYTEARRAY \ + QT_NO_COMPRESS \ + QT_NO_FOREACH include(moc.pri) HEADERS += qdatetime_p.h diff --git a/src/tools/qdbuscpp2xml/qdbuscpp2xml.pro b/src/tools/qdbuscpp2xml/qdbuscpp2xml.pro index d65b5ce6ef..5ac3159797 100644 --- a/src/tools/qdbuscpp2xml/qdbuscpp2xml.pro +++ b/src/tools/qdbuscpp2xml/qdbuscpp2xml.pro @@ -2,7 +2,7 @@ option(host_build) QT = core-private force_bootstrap: QT += bootstrap_dbus-private else: QT += dbus-private -DEFINES += QT_NO_CAST_FROM_ASCII +DEFINES += QT_NO_CAST_FROM_ASCII QT_NO_FOREACH QMAKE_CXXFLAGS += $$QT_HOST_CFLAGS_DBUS include(../moc/moc.pri) diff --git a/src/tools/qdbusxml2cpp/qdbusxml2cpp.pro b/src/tools/qdbusxml2cpp/qdbusxml2cpp.pro index 6efcf323b8..cb14db5fef 100644 --- a/src/tools/qdbusxml2cpp/qdbusxml2cpp.pro +++ b/src/tools/qdbusxml2cpp/qdbusxml2cpp.pro @@ -2,7 +2,7 @@ option(host_build) QT = core-private force_bootstrap: QT += bootstrap_dbus-private else: QT += dbus-private -DEFINES += QT_NO_CAST_FROM_ASCII +DEFINES += QT_NO_CAST_FROM_ASCII QT_NO_FOREACH QMAKE_CXXFLAGS += $$QT_HOST_CFLAGS_DBUS SOURCES = qdbusxml2cpp.cpp diff --git a/src/tools/qlalr/qlalr.pro b/src/tools/qlalr/qlalr.pro index 08cf6a1591..bd5f337c64 100644 --- a/src/tools/qlalr/qlalr.pro +++ b/src/tools/qlalr/qlalr.pro @@ -22,4 +22,7 @@ HEADERS += \ OTHER_FILES += \ lalr.g +DEFINES += \ + QT_NO_FOREACH + load(qt_tool) diff --git a/src/tools/rcc/rcc.pro b/src/tools/rcc/rcc.pro index de3cc90e1b..701f15ff22 100644 --- a/src/tools/rcc/rcc.pro +++ b/src/tools/rcc/rcc.pro @@ -1,7 +1,7 @@ option(host_build) CONFIG += force_bootstrap -DEFINES += QT_RCC QT_NO_CAST_FROM_ASCII +DEFINES += QT_RCC QT_NO_CAST_FROM_ASCII QT_NO_FOREACH include(rcc.pri) SOURCES += main.cpp diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp index 026d099dc0..7466da47f3 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.cpp +++ b/src/tools/uic/cpp/cppwriteinitialization.cpp @@ -770,7 +770,7 @@ void WriteInitialization::acceptWidget(DomWidget *node) // // Special handling for qtableview/qtreeview fake header attributes // - static QStringList realPropertyNames = + static const QStringList realPropertyNames = (QStringList() << QLatin1String("visible") << QLatin1String("cascadingSectionResizes") << QLatin1String("defaultSectionSize") @@ -782,7 +782,7 @@ void WriteInitialization::acceptWidget(DomWidget *node) if (m_uic->customWidgetsInfo()->extends(className, QLatin1String("QTreeView")) || m_uic->customWidgetsInfo()->extends(className, QLatin1String("QTreeWidget"))) { DomPropertyList headerProperties; - foreach (const QString &realPropertyName, realPropertyNames) { + for (const QString &realPropertyName : realPropertyNames) { const QString upperPropertyName = realPropertyName.at(0).toUpper() + realPropertyName.mid(1); const QString fakePropertyName = QLatin1String("header") + upperPropertyName; @@ -797,13 +797,13 @@ void WriteInitialization::acceptWidget(DomWidget *node) } else if (m_uic->customWidgetsInfo()->extends(className, QLatin1String("QTableView")) || m_uic->customWidgetsInfo()->extends(className, QLatin1String("QTableWidget"))) { - static QStringList headerPrefixes = + static const QStringList headerPrefixes = (QStringList() << QLatin1String("horizontalHeader") << QLatin1String("verticalHeader")); - foreach (const QString &headerPrefix, headerPrefixes) { + for (const QString &headerPrefix : headerPrefixes) { DomPropertyList headerProperties; - foreach (const QString &realPropertyName, realPropertyNames) { + for (const QString &realPropertyName : realPropertyNames) { const QString upperPropertyName = realPropertyName.at(0).toUpper() + realPropertyName.mid(1); const QString fakePropertyName = headerPrefix + upperPropertyName; diff --git a/src/tools/uic/uic.pro b/src/tools/uic/uic.pro index a625bdef9a..8008dde07a 100644 --- a/src/tools/uic/uic.pro +++ b/src/tools/uic/uic.pro @@ -1,6 +1,6 @@ option(host_build) -DEFINES += QT_UIC QT_NO_CAST_FROM_ASCII +DEFINES += QT_UIC QT_NO_CAST_FROM_ASCII QT_NO_FOREACH include(uic.pri) include(cpp/cpp.pri) -- cgit v1.2.3 From e2e0dfee7c675c91132197b4a01a394a5da9a36f Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 11 May 2016 11:53:02 +0200 Subject: QtCore/QtDBus/QtSql: port the last remaining Q_FOREACH loop and add QT_NO_FOREACH Port the last remaining Q_FOREACH user in QtCore to C++11 range-for and mark QtCore, QtSql and QtDBus as Q_FOREACH-free, using QT_NO_FOREACH. Change-Id: Ia6f99139cb1ca4a8bbe9e445421592242e048b0a Reviewed-by: Thiago Macieira --- src/corelib/corelib.pro | 2 +- src/corelib/statemachine/qstatemachine.cpp | 6 +++++- src/dbus/dbus.pro | 2 ++ src/sql/sql.pro | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/corelib/corelib.pro b/src/corelib/corelib.pro index 362ac37a59..42fd5d1a61 100644 --- a/src/corelib/corelib.pro +++ b/src/corelib/corelib.pro @@ -8,7 +8,7 @@ MODULE_CONFIG = moc resources CONFIG += $$MODULE_CONFIG DEFINES += $$MODULE_DEFINES -DEFINES += QT_NO_USING_NAMESPACE +DEFINES += QT_NO_USING_NAMESPACE QT_NO_FOREACH win32-msvc*|win32-icc:QMAKE_LFLAGS += /BASE:0x67000000 irix-cc*:QMAKE_CXXFLAGS += -no_prelink -ptused diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp index d5b01f3c8a..e3cfd7b988 100644 --- a/src/corelib/statemachine/qstatemachine.cpp +++ b/src/corelib/statemachine/qstatemachine.cpp @@ -1778,7 +1778,11 @@ void QStateMachinePrivate::_q_start() { Q_Q(QStateMachine); Q_ASSERT(state == Starting); - foreach (QAbstractState *state, configuration) { + // iterate over a copy, since we emit signals which may cause + // 'configuration' to change, resulting in undefined behavior when + // iterating at the same time: + const auto config = configuration; + for (QAbstractState *state : config) { QAbstractStatePrivate *abstractStatePrivate = QAbstractStatePrivate::get(state); abstractStatePrivate->active = false; emit state->activeChanged(false); diff --git a/src/dbus/dbus.pro b/src/dbus/dbus.pro index 4c1aec7bb3..fa67fc17ef 100644 --- a/src/dbus/dbus.pro +++ b/src/dbus/dbus.pro @@ -23,6 +23,8 @@ win32 { -luser32 } +DEFINES += QT_NO_FOREACH + QMAKE_DOCS = $$PWD/doc/qtdbus.qdocconf PUB_HEADERS = qdbusargument.h \ diff --git a/src/sql/sql.pro b/src/sql/sql.pro index 218671d7e7..8846f03d78 100644 --- a/src/sql/sql.pro +++ b/src/sql/sql.pro @@ -6,7 +6,7 @@ win32-msvc*|win32-icc:QMAKE_LFLAGS += /BASE:0x62000000 QMAKE_DOCS = $$PWD/doc/qtsql.qdocconf -DEFINES += QT_NO_CAST_FROM_ASCII +DEFINES += QT_NO_CAST_FROM_ASCII QT_NO_FOREACH PRECOMPILED_HEADER = ../corelib/global/qt_pch.h SQL_P = sql -- cgit v1.2.3 From 36578d41f3fe43a3cd3c37d8bdaaf3f9a50eca92 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 10 May 2016 17:01:47 -0700 Subject: Remove wrong doc note for QPlatformBackingStore::flush() This is no longer true on at least Cocoa, Windows and xcb. Change-Id: I214caae46a8707ab7c89138646219140079e919a Reviewed-by: Jake Petroules --- src/gui/painting/qplatformbackingstore.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/painting/qplatformbackingstore.cpp b/src/gui/painting/qplatformbackingstore.cpp index 33d5e76e52..defdcfb4ad 100644 --- a/src/gui/painting/qplatformbackingstore.cpp +++ b/src/gui/painting/qplatformbackingstore.cpp @@ -226,7 +226,8 @@ void QPlatformTextureList::clear() Flushes the given \a region from the specified \a window onto the screen. - Note that the \a offset parameter is currently unused. + The \a offset parameter is relative to the origin of the backing + store image. */ #ifndef QT_NO_OPENGL -- cgit v1.2.3 From 37a983cd98afb3ae1e7295a5e2fd0929542865f9 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 10 May 2016 16:24:08 +0200 Subject: Dirview example: Add option for DontUseCustomDirectoryIcons. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This enables people to toy around with the option and check what impact it has. Change-Id: I8b49c31211cc48721b3326eea48b4e74967b1a92 Reviewed-by: Sérgio Martins --- examples/widgets/itemviews/dirview/main.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/examples/widgets/itemviews/dirview/main.cpp b/examples/widgets/itemviews/dirview/main.cpp index abca413325..2f030643ca 100644 --- a/examples/widgets/itemviews/dirview/main.cpp +++ b/examples/widgets/itemviews/dirview/main.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -54,6 +55,8 @@ int main(int argc, char *argv[]) parser.setApplicationDescription("Qt Dir View Example"); parser.addHelpOption(); parser.addVersionOption(); + QCommandLineOption dontUseCustomDirectoryIconsOption("c", "Set QFileIconProvider::DontUseCustomDirectoryIcons"); + parser.addOption(dontUseCustomDirectoryIconsOption); parser.addPositionalArgument("directory", "The directory to start in."); parser.process(app); const QString rootPath = parser.positionalArguments().isEmpty() @@ -61,6 +64,8 @@ int main(int argc, char *argv[]) QFileSystemModel model; model.setRootPath(""); + if (parser.isSet(dontUseCustomDirectoryIconsOption)) + model.iconProvider()->setOptions(QFileIconProvider::DontUseCustomDirectoryIcons); QTreeView tree; tree.setModel(&model); if (!rootPath.isEmpty()) { -- cgit v1.2.3 From 6bcd27b957a5ffcfe7665b0979679510e3b2ae3d Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Tue, 10 May 2016 14:35:20 +0200 Subject: Document how to save an application using QUndoStack MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ic61374d5b6ce395dfe8d0b30813ea437b5e16e9d Task-number: QTBUG-52497 Reviewed-by: Topi Reiniö --- src/widgets/util/qundostack.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/widgets/util/qundostack.cpp b/src/widgets/util/qundostack.cpp index 5bcfa57b37..bd41fb60c1 100644 --- a/src/widgets/util/qundostack.cpp +++ b/src/widgets/util/qundostack.cpp @@ -623,6 +623,8 @@ void QUndoStack::push(QUndoCommand *cmd) Marks the stack as clean and emits cleanChanged() if the stack was not already clean. + This is typically called when a document is saved, for example. + Whenever the stack returns to this state through the use of undo/redo commands, it emits the signal cleanChanged(). This signal is also emitted when the stack leaves the clean state. -- cgit v1.2.3 From 9ef59b586d6c65404835c5003a0f486ef9e162c3 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 29 Apr 2016 21:39:44 -0700 Subject: QMutex: make FUTEX_PRIVATE_FLAG a mandatory feature The flag was introduced in kernel 2.6.22, but we're already depending on features added on 2.6.23 in qcore_unix_p.h (pipe2, dup3, O_CLOEXEC) and 2.6.27 in qnet_unix_p.h (accept4 and SOCK_CLOEXEC). Change-Id: Id5480807d25e49e78b79ffff144a093c9e30cd96 Reviewed-by: Olivier Goffart (Woboq GmbH) Reviewed-by: Thiago Macieira --- src/corelib/thread/qmutex_linux.cpp | 41 ++++++------------------------------- 1 file changed, 6 insertions(+), 35 deletions(-) diff --git a/src/corelib/thread/qmutex_linux.cpp b/src/corelib/thread/qmutex_linux.cpp index 89eb3da203..25444ffff6 100644 --- a/src/corelib/thread/qmutex_linux.cpp +++ b/src/corelib/thread/qmutex_linux.cpp @@ -56,6 +56,11 @@ # error "Qt build is broken: qmutex_linux.cpp is being built but futex support is not wanted" #endif +#ifndef FUTEX_PRIVATE_FLAG +# define FUTEX_PRIVATE_FLAG 128 +#endif + + QT_BEGIN_NAMESPACE /* @@ -104,40 +109,6 @@ QT_BEGIN_NAMESPACE static QBasicAtomicInt futexFlagSupport = Q_BASIC_ATOMIC_INITIALIZER(-1); -static int checkFutexPrivateSupport() -{ - int value = 0; -#if defined(FUTEX_PRIVATE_FLAG) - // check if the kernel supports extra futex flags - // FUTEX_PRIVATE_FLAG appeared in v2.6.22 - Q_STATIC_ASSERT(FUTEX_PRIVATE_FLAG != 0x80000000); - - // try an operation that has no side-effects: wake up 42 threads - // futex will return -1 (errno==ENOSYS) if the flag isn't supported - // there should be no other error conditions - value = syscall(__NR_futex, &futexFlagSupport, - FUTEX_WAKE | FUTEX_PRIVATE_FLAG, - 42, 0, 0, 0); - if (value != -1) - value = FUTEX_PRIVATE_FLAG; - else - value = 0; - -#else - value = 0; -#endif - futexFlagSupport.store(value); - return value; -} - -static inline int futexFlags() -{ - int value = futexFlagSupport.load(); - if (Q_LIKELY(value != -1)) - return value; - return checkFutexPrivateSupport(); -} - static inline int _q_futex(void *addr, int op, int val, const struct timespec *timeout) Q_DECL_NOTHROW { volatile int *int_addr = reinterpret_cast(addr); @@ -149,7 +120,7 @@ static inline int _q_futex(void *addr, int op, int val, const struct timespec *t // we use __NR_futex because some libcs (like Android's bionic) don't // provide SYS_futex etc. - return syscall(__NR_futex, int_addr, op | futexFlags(), val, timeout, addr2, val2); + return syscall(__NR_futex, int_addr, op | FUTEX_PRIVATE_FLAG, val, timeout, addr2, val2); } static inline QMutexData *dummyFutexValue() -- cgit v1.2.3 From 46f1c4c86bbfe7b6917907700bec998626ad4a8b Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Wed, 11 May 2016 18:42:24 +0300 Subject: xcb: Properly interpret data.l[0] field of XdndStatus message The standard https://freedesktop.org/wiki/Specifications/XDND/ states: "In order for the proxy window to behave correctly, the appropriate field of the client messages, window or data.l[0], must contain the ID of the window in which the mouse is located, not the proxy window that is receiving the messages." So compare it with the current target window instead of the current proxy window. Change-Id: Ie31fd3aeadebcf5a9be7b9a9194f35a4ec7bdebb Reviewed-by: Lars Knoll --- src/plugins/platforms/xcb/qxcbdrag.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/platforms/xcb/qxcbdrag.cpp b/src/plugins/platforms/xcb/qxcbdrag.cpp index 6fa5dfa483..f93e420bcf 100644 --- a/src/plugins/platforms/xcb/qxcbdrag.cpp +++ b/src/plugins/platforms/xcb/qxcbdrag.cpp @@ -829,7 +829,7 @@ void QXcbDrag::handle_xdnd_status(const xcb_client_message_event_t *event) DEBUG("xdndHandleStatus"); waiting_for_status = false; // ignore late status messages - if (event->data.data32[0] && event->data.data32[0] != current_proxy_target) + if (event->data.data32[0] && event->data.data32[0] != current_target) return; const bool dropPossible = event->data.data32[1]; -- cgit v1.2.3 From feaef445591e9028c1ad41f33f7f2daae5f31f70 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 12 May 2016 08:46:13 +0200 Subject: Windows: Suppress error dialogs when querying logical drives. Set the error mode flag SEM_NOOPENFILEERRORBOX when calling Win32 API GetLogicalDrives() to prevent it from prompting to insert media as does QStorageInfoPrivate::mountedVolumes(). Task-number: QTBUG-18729 Task-number: QTBUG-32457 Change-Id: I5c76afbb5bf2ec5ec84194650c316fe531578d5b Reviewed-by: Oliver Wolff --- src/corelib/io/qfilesystemengine_win.cpp | 2 ++ src/corelib/io/qfsfileengine_win.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp index e55ab0b544..257bd4a50e 100644 --- a/src/corelib/io/qfilesystemengine_win.cpp +++ b/src/corelib/io/qfilesystemengine_win.cpp @@ -879,7 +879,9 @@ static bool tryDriveUNCFallback(const QFileSystemEntry &fname, QFileSystemMetaDa #if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) if (fname.isDriveRoot()) { // a valid drive ?? + const UINT oldErrorMode = ::SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX); DWORD drivesBitmask = ::GetLogicalDrives(); + ::SetErrorMode(oldErrorMode); int drivebit = 1 << (fname.filePath().at(0).toUpper().unicode() - QLatin1Char('A').unicode()); if (drivesBitmask & drivebit) { fileAttrib = FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_SYSTEM; diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index 886d526fb1..689251a6c7 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -626,7 +626,9 @@ QFileInfoList QFSFileEngine::drives() QFileInfoList ret; #if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) #if defined(Q_OS_WIN32) + const UINT oldErrorMode = ::SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX); quint32 driveBits = (quint32) GetLogicalDrives() & 0x3ffffff; + ::SetErrorMode(oldErrorMode); #endif char driveName[] = "A:/"; -- cgit v1.2.3 From 78eeb6b066113c678fe15531ca10e70964f6b9a4 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 11 May 2016 15:10:50 +0300 Subject: QFont::exactMatch() should return false for aliases This is a partial revert of 992f233c in Qt 4 repo. The rest of the change cannot be reverted, since it added public API, but that API might be useful anyway. The patch was wrong, basically. QFont::exactMatch() should not claim that you can get an exact match for a typeface alias. It also introduced some weird inconsistencies: For instance, if the first font the alias resolved to in FontConfig did not exist, then exactMatch() would return false, even if it then resolved to the next one which existed. This caused a test failure on OpenSuse, where the preferred font for "sans" is Arial, which doesn't exist, so Roboto will be used instead. [ChangeLog][QtGui][Important Behavior Changes] QFont::exactMatch() now returns false when the provided typeface is an alias. Task-number: QTBUG-46054 Change-Id: I7532d2879b492544620aa0d1d87dd493a4923af9 Reviewed-by: Simon Hausmann --- src/gui/text/qfont.cpp | 3 --- tests/auto/gui/text/qfont/tst_qfont.cpp | 11 ++++------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index 7e18250087..f92e4ab457 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -118,9 +118,6 @@ bool QFontDef::exactMatch(const QFontDef &other) const QFontDatabase::parseFontName(family, this_foundry, this_family); QFontDatabase::parseFontName(other.family, other_foundry, other_family); - this_family = QFontDatabase::resolveFontFamilyAlias(this_family); - other_family = QFontDatabase::resolveFontFamilyAlias(other_family); - return (styleHint == other.styleHint && styleStrategy == other.styleStrategy && weight == other.weight diff --git a/tests/auto/gui/text/qfont/tst_qfont.cpp b/tests/auto/gui/text/qfont/tst_qfont.cpp index 57530653c1..da1e4aa225 100644 --- a/tests/auto/gui/text/qfont/tst_qfont.cpp +++ b/tests/auto/gui/text/qfont/tst_qfont.cpp @@ -115,13 +115,10 @@ void tst_QFont::exactMatch() QSKIP("Exact matching on windows misses a lot because of the sample chars"); #endif - - if (!QGuiApplication::platformName().compare("xcb", Qt::CaseInsensitive)) { - QVERIFY(QFont("sans").exactMatch()); - QVERIFY(QFont("sans-serif").exactMatch()); - QVERIFY(QFont("serif").exactMatch()); - QVERIFY(QFont("monospace").exactMatch()); - } + QVERIFY(!QFont("sans").exactMatch()); + QVERIFY(!QFont("sans-serif").exactMatch()); + QVERIFY(!QFont("serif").exactMatch()); + QVERIFY(!QFont("monospace").exactMatch()); QSKIP("This test is bogus on Unix with support for font aliases in fontconfig"); -- cgit v1.2.3 From d70205cd2ba9242e477856df853dcd7d7770425b Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 11 May 2016 15:19:09 +0300 Subject: Remove dead code from tst_QFont::exactMatch() All this code was skipped on all platforms, so keeping it is just confusing. Change-Id: I405d2e791b22a2494fe5ccac6e3bf08905dc4e5a Reviewed-by: Simon Hausmann --- tests/auto/gui/text/qfont/tst_qfont.cpp | 145 -------------------------------- 1 file changed, 145 deletions(-) diff --git a/tests/auto/gui/text/qfont/tst_qfont.cpp b/tests/auto/gui/text/qfont/tst_qfont.cpp index da1e4aa225..d8a6afb804 100644 --- a/tests/auto/gui/text/qfont/tst_qfont.cpp +++ b/tests/auto/gui/text/qfont/tst_qfont.cpp @@ -110,155 +110,10 @@ void tst_QFont::exactMatch() // Check if a non-existing font hasn't an exact match font = QFont( "BogusFont", 33 ); QVERIFY( !font.exactMatch() ); - -#ifdef Q_OS_WIN - QSKIP("Exact matching on windows misses a lot because of the sample chars"); -#endif - QVERIFY(!QFont("sans").exactMatch()); QVERIFY(!QFont("sans-serif").exactMatch()); QVERIFY(!QFont("serif").exactMatch()); QVERIFY(!QFont("monospace").exactMatch()); - - QSKIP("This test is bogus on Unix with support for font aliases in fontconfig"); - - QFontDatabase fdb; - - QList systems = fdb.writingSystems(); - for (int system = 0; system < systems.count(); ++system) { - QStringList families = fdb.families(systems[system]); - if (families.isEmpty()) - return; - - QStringList::ConstIterator f_it, f_end = families.end(); - for (f_it = families.begin(); f_it != f_end; ++f_it) { - const QString &family = *f_it; - if (family.contains('[')) - continue; - - QStringList styles = fdb.styles(family); - QVERIFY(!styles.isEmpty()); - QStringList::ConstIterator s_it, s_end = styles.end(); - for (s_it = styles.begin(); s_it != s_end; ++s_it) { - const QString &style = *s_it; - - if (fdb.isSmoothlyScalable(family, style)) { - // smoothly scalable font... don't need to load every pointsize - font = fdb.font(family, style, 12); - QFontInfo fontinfo(font); - - if (! fontinfo.exactMatch()) { - // Unfortunately, this can fail, since - // QFontDatabase does not fill in all font - // properties. Check to make sure that the - // test didn't fail for obvious reasons - - if (fontinfo.family().isEmpty() - && fontinfo.pointSize() == 0) { - // this is a box rendering engine... this can happen from - // time to time, especially on X11 with iso10646-1 or - // unknown font encodings - continue; - } - -#ifdef Q_OS_WIN - if (font.family().startsWith("MS ") || fontinfo.family().startsWith("MS ")) { - /* qDebug("Family matching skipped for MS-Alias font: %s, fontinfo: %s", - font.family().latin1(), fontinfo.family().latin1()); - */ - } else -#endif - { - if (!(font.family() == fontinfo.family() - || fontinfo.family().contains(font.family()) - || fontinfo.family().isEmpty())) { - qDebug("Test about to fail for font: %s, fontinfo: %s", - font.family().toLatin1().constData(), - fontinfo.family().toLatin1().constData()); - } - QVERIFY(font.family() == fontinfo.family() - || fontinfo.family().contains(font.family()) - || fontinfo.family().isEmpty()); - } - if (font.pointSize() != -1) { - QCOMPARE(font.pointSize(), fontinfo.pointSize()); - } else { - QCOMPARE(font.pixelSize(), fontinfo.pixelSize()); - } - QCOMPARE(font.italic(), fontinfo.italic()); - if (font.weight() != fontinfo.weight()) { - qDebug("font is %s", font.toString().toLatin1().constData()); - } - QCOMPARE(font.weight(), fontinfo.weight()); - } else { - font.setFixedPitch(!fontinfo.fixedPitch()); - QFontInfo fontinfo1(font); - QVERIFY( !fontinfo1.exactMatch() ); - - font.setFixedPitch(fontinfo.fixedPitch()); - QFontInfo fontinfo2(font); - QVERIFY( fontinfo2.exactMatch() ); - } - } -#if 0 - // ############## can only work if we have float point sizes in QFD - else { - QList sizes = fdb.pointSizes(family, style); - QVERIFY(!sizes.isEmpty()); - QList::ConstIterator z_it, z_end = sizes.end(); - for (z_it = sizes.begin(); z_it != z_end; ++z_it) { - const int size = *z_it; - - // Initialize the font, and check if it is an exact match - font = fdb.font(family, style, size); - QFontInfo fontinfo(font, (QFont::Script) script); - - if (! fontinfo.exactMatch()) { - // Unfortunately, this can fail, since - // QFontDatabase does not fill in all font - // properties. Check to make sure that the - // test didn't fail for obvious reasons - - if (fontinfo.family().isEmpty() - && fontinfo.pointSize() == 0) { - // this is a box rendering engine... this can happen from - // time to time, especially on X11 with iso10646-1 or - // unknown font encodings - continue; - } - - // no need to skip MS-fonts here it seems - if (!(font.family() == fontinfo.family() - || fontinfo.family().contains(font.family()) - || fontinfo.family().isEmpty())) { - qDebug("Test about to fail for font: %s, fontinfo: %s", - font.family().latin1(), fontinfo.family().latin1()); - } - QVERIFY(font.family() == fontinfo.family() - || fontinfo.family().contains(font.family()) - || fontinfo.family().isEmpty()); - if (font.pointSize() != -1) { - QCOMPARE(font.pointSize(), fontinfo.pointSize()); - } else { - QCOMPARE(font.pixelSize(), fontinfo.pixelSize()); - } - QCOMPARE(font.italic(), fontinfo.italic()); - QCOMPARE(font.weight(), fontinfo.weight()); - } else { - font.setFixedPitch(!fontinfo.fixedPitch()); - QFontInfo fontinfo1(font, (QFont::Script) script); - QVERIFY( !fontinfo1.exactMatch() ); - - font.setFixedPitch(fontinfo.fixedPitch()); - QFontInfo fontinfo2(font, (QFont::Script) script); - QVERIFY( fontinfo2.exactMatch() ); - } - } - } -#endif - } - } - } } void tst_QFont::italicOblique() -- cgit v1.2.3 From 99ca47101471023361eef1764a29f085c288347c Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 11 May 2016 11:53:02 +0200 Subject: winmain: port the last remaining Q_FOREACH loop and add QT_NO_FOREACH Port the last remaining Q_FOREACH (over a QVarLengthArray, no less) in winmain to C++11 range-for and mark the library as Q_FOREACH-free, using QT_NO_FOREACH. Change-Id: Ic561080f7dd61d1d853ceb9e211c9b8a23bf05a5 Reviewed-by: Friedemann Kleint Reviewed-by: Maurice Kalinowski --- src/winmain/qtmain_winrt.cpp | 2 +- src/winmain/winmain.pro | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/winmain/qtmain_winrt.cpp b/src/winmain/qtmain_winrt.cpp index e2046b1106..1ac0a98cb1 100644 --- a/src/winmain/qtmain_winrt.cpp +++ b/src/winmain/qtmain_winrt.cpp @@ -298,7 +298,7 @@ private: bool develMode = false; bool debugWait = false; - foreach (const char *arg, args) { + for (const char *arg : args) { if (strcmp(arg, "-qdevel") == 0) develMode = true; if (strcmp(arg, "-qdebug") == 0) diff --git a/src/winmain/winmain.pro b/src/winmain/winmain.pro index e8c9ace03b..4dab828eae 100644 --- a/src/winmain/winmain.pro +++ b/src/winmain/winmain.pro @@ -8,6 +8,8 @@ DESTDIR = $$QT.core.libs CONFIG += static QT = core +DEFINES += QT_NO_FOREACH + contains(QT_CONFIG, build_all):CONFIG += build_all win32-msvc*:QMAKE_CFLAGS_DEBUG -= -Zi -- cgit v1.2.3 From 864380639b9cf563c2399b30f816ed1a25fa3ba6 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Tue, 10 May 2016 14:00:18 +0200 Subject: ANGLE: fall back to warp mode in case of standard VGA driver The combination of vendor and device ID being 0000 indicates, that the standard VGA driver is used, and happens when using Qt in a: - Windows 7 machine without proper GPU drivers - Windows 7 machine with disabled GPU - HyperV vm The default driver does neither support D3D9 nor D3D11 properly so that we have to fall back to warp mode for ANGLE. Change-Id: Ia766e32d680c910a50ec3d6b5002892cdb90fdbb Reviewed-by: Maurice Kalinowski Reviewed-by: Laszlo Agocs --- src/plugins/platforms/windows/openglblacklists/default.json | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/plugins/platforms/windows/openglblacklists/default.json b/src/plugins/platforms/windows/openglblacklists/default.json index f7a8844611..1e00da52eb 100644 --- a/src/plugins/platforms/windows/openglblacklists/default.json +++ b/src/plugins/platforms/windows/openglblacklists/default.json @@ -90,6 +90,18 @@ "features": [ "disable_angle" ] + }, + { + "id": 8, + "description": "Standard VGA: Insufficent support for OpenGL, D3D9 and D3D11", + "vendor_id": "0x0000", + "device_id": ["0x0000"], + "os": { + "type": "win" + }, + "features": [ + "disable_desktopgl", "disable_d3d11", "disable_d3d9" + ] } ] } -- cgit v1.2.3 From d8d4129c1b4be6a62ec17d0418ff7a37be451d4c Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Wed, 11 May 2016 13:51:54 +0200 Subject: ANGLE: Disable support for shared handles in warp mode on Windows < 8 Shared handles are not supported on Windows 7 and below. If the according flag is set CreateTexture2D will fail with E_OUTOFMEMORY. The check already happens with newer ANGLE versions, which we use in 5.7 but has to happen here as well. Otherwise Qt applications running on Windows 7 and below will crash at startup. Change-Id: I8f539f16dce298611fb1ec7b2f6804d4a04d04e0 Reviewed-by: Maurice Kalinowski --- .../src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp | 13 +++++++ ...le-support-for-shared-handles-in-warp-mod.patch | 44 ++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 src/angle/patches/0011-ANGLE-Disable-support-for-shared-handles-in-warp-mod.patch diff --git a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp index 223e2b019b..dd554f4f38 100644 --- a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp +++ b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp @@ -2370,6 +2370,19 @@ unsigned int Renderer11::getReservedFragmentUniformBuffers() const bool Renderer11::getShareHandleSupport() const { + if (mDriverType == D3D_DRIVER_TYPE_WARP) + { +#if !defined(ANGLE_ENABLE_WINDOWS_STORE) + // Warp mode does not support shared handles in Windows versions below Windows 8 + OSVERSIONINFO result = { sizeof(OSVERSIONINFO), 0, 0, 0, 0, {'\0'}}; + if (GetVersionEx(&result) && + ((result.dwMajorVersion == 6 && result.dwMinorVersion < 2) || result.dwMajorVersion < 6)) + { + // WARP on Windows 7 doesn't support shared handles + return false; + } +#endif // ANGLE_ENABLE_WINDOWS_STORE + } // We only currently support share handles with BGRA surfaces, because // chrome needs BGRA. Once chrome fixes this, we should always support them. // PIX doesn't seem to support using share handles, so disable them. diff --git a/src/angle/patches/0011-ANGLE-Disable-support-for-shared-handles-in-warp-mod.patch b/src/angle/patches/0011-ANGLE-Disable-support-for-shared-handles-in-warp-mod.patch new file mode 100644 index 0000000000..1c4ee1d513 --- /dev/null +++ b/src/angle/patches/0011-ANGLE-Disable-support-for-shared-handles-in-warp-mod.patch @@ -0,0 +1,44 @@ +From db13a9cf7e41207660f080827983655864df802d Mon Sep 17 00:00:00 2001 +From: Oliver Wolff +Date: Wed, 11 May 2016 13:51:54 +0200 +Subject: [PATCH] ANGLE: Disable support for shared handles in warp mode on + Windows < 8 + +Shared handles are not supported on Windows 7 and below. If the +according flag is set CreateTexture2D will fail with E_OUTOFMEMORY. The +check already happens with newer ANGLE versions, which we use in 5.7 +but has to happen here as well. Otherwise Qt applications running on +Windows 7 and below will crash at startup. + +Change-Id: I8f539f16dce298611fb1ec7b2f6804d4a04d04e0 +--- + .../angle/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp | 13 +++++++++++++ + 1 file changed, 13 insertions(+) + +diff --git a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp +index 223e2b0..dd554f4 100644 +--- a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp ++++ b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp +@@ -2370,6 +2370,19 @@ unsigned int Renderer11::getReservedFragmentUniformBuffers() const + + bool Renderer11::getShareHandleSupport() const + { ++ if (mDriverType == D3D_DRIVER_TYPE_WARP) ++ { ++#if !defined(ANGLE_ENABLE_WINDOWS_STORE) ++ // Warp mode does not support shared handles in Windows versions below Windows 8 ++ OSVERSIONINFO result = { sizeof(OSVERSIONINFO), 0, 0, 0, 0, {'\0'}}; ++ if (GetVersionEx(&result) && ++ ((result.dwMajorVersion == 6 && result.dwMinorVersion < 2) || result.dwMajorVersion < 6)) ++ { ++ // WARP on Windows 7 doesn't support shared handles ++ return false; ++ } ++#endif // ANGLE_ENABLE_WINDOWS_STORE ++ } + // We only currently support share handles with BGRA surfaces, because + // chrome needs BGRA. Once chrome fixes this, we should always support them. + // PIX doesn't seem to support using share handles, so disable them. +-- +2.7.0.windows.1 + -- cgit v1.2.3 From 72e3fcce387d72043dd0b9fbe06d6b720861c1e7 Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Tue, 10 May 2016 14:54:24 +0200 Subject: Doc: Remove repository name from examplesinstallpath Examples in binary packages now directly match the install path. Change-Id: Ic1487bc766cfd3b0a0a340cc4ae4ba49d953eaa6 Task-number: QTBUG-52953 Reviewed-by: Oswald Buddenhagen --- src/concurrent/doc/qtconcurrent.qdocconf | 2 +- src/corelib/doc/qtcore.qdocconf | 2 +- src/dbus/doc/qtdbus.qdocconf | 2 +- src/gui/doc/qtgui.qdocconf | 2 +- src/network/doc/qtnetwork.qdocconf | 2 +- src/opengl/doc/qtopengl.qdocconf | 2 +- src/platformheaders/doc/qtplatformheaders.qdocconf | 2 +- src/printsupport/doc/qtprintsupport.qdocconf | 2 +- src/sql/doc/qtsql.qdocconf | 2 +- src/testlib/doc/qttestlib.qdocconf | 2 +- src/widgets/doc/qtwidgets.qdocconf | 2 +- src/xml/doc/qtxml.qdocconf | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/concurrent/doc/qtconcurrent.qdocconf b/src/concurrent/doc/qtconcurrent.qdocconf index 3cd2fac075..d8ee963ef5 100644 --- a/src/concurrent/doc/qtconcurrent.qdocconf +++ b/src/concurrent/doc/qtconcurrent.qdocconf @@ -4,7 +4,7 @@ project = QtConcurrent description = Qt Concurrent Reference Documentation version = $QT_VERSION -examplesinstallpath = qtbase/qtconcurrent +examplesinstallpath = qtconcurrent qhp.projects = QtConcurrent diff --git a/src/corelib/doc/qtcore.qdocconf b/src/corelib/doc/qtcore.qdocconf index e98f06d47d..3d64708def 100644 --- a/src/corelib/doc/qtcore.qdocconf +++ b/src/corelib/doc/qtcore.qdocconf @@ -4,7 +4,7 @@ project = QtCore description = Qt Core Reference Documentation version = $QT_VERSION -examplesinstallpath = qtbase/corelib +examplesinstallpath = corelib qhp.projects = QtCore diff --git a/src/dbus/doc/qtdbus.qdocconf b/src/dbus/doc/qtdbus.qdocconf index fc8921ff35..ff46cc5961 100644 --- a/src/dbus/doc/qtdbus.qdocconf +++ b/src/dbus/doc/qtdbus.qdocconf @@ -19,7 +19,7 @@ sourcedirs += .. \ ../../../examples/dbus/doc/src excludedirs += ../../../examples/widgets/doc -examplesinstallpath = qtbase/dbus +examplesinstallpath = dbus depends += qtdoc qtcore diff --git a/src/gui/doc/qtgui.qdocconf b/src/gui/doc/qtgui.qdocconf index e34347b801..436e2e0b34 100644 --- a/src/gui/doc/qtgui.qdocconf +++ b/src/gui/doc/qtgui.qdocconf @@ -4,7 +4,7 @@ project = QtGui description = Qt GUI Reference Documentation version = $QT_VERSION -examplesinstallpath = qtbase/gui +examplesinstallpath = gui qhp.projects = QtGui diff --git a/src/network/doc/qtnetwork.qdocconf b/src/network/doc/qtnetwork.qdocconf index 87e322d6c0..2a8e577dda 100644 --- a/src/network/doc/qtnetwork.qdocconf +++ b/src/network/doc/qtnetwork.qdocconf @@ -4,7 +4,7 @@ project = QtNetwork description = Qt Network Reference Documentation version = $QT_VERSION -examplesinstallpath = qtbase/network +examplesinstallpath = network qhp.projects = QtNetwork diff --git a/src/opengl/doc/qtopengl.qdocconf b/src/opengl/doc/qtopengl.qdocconf index 3c5fc280bd..6ff6cae2cb 100644 --- a/src/opengl/doc/qtopengl.qdocconf +++ b/src/opengl/doc/qtopengl.qdocconf @@ -21,7 +21,7 @@ imagedirs += images \ depends += qtdoc qtcore qtgui qtwidgets qmake -examplesinstallpath = qtbase/opengl +examplesinstallpath = opengl # The following parameters are for creating a qhp file, the qhelpgenerator # program can convert the qhp file into a qch file which can be opened in diff --git a/src/platformheaders/doc/qtplatformheaders.qdocconf b/src/platformheaders/doc/qtplatformheaders.qdocconf index fc8a9d8731..1c09971e23 100644 --- a/src/platformheaders/doc/qtplatformheaders.qdocconf +++ b/src/platformheaders/doc/qtplatformheaders.qdocconf @@ -4,7 +4,7 @@ project = QtPlatformHeaders description = Qt Platform Headers Reference Documentation version = $QT_VERSION -examplesinstallpath = qtbase/qtplatformheaders +examplesinstallpath = qtplatformheaders qhp.projects = QtPlatformHeaders diff --git a/src/printsupport/doc/qtprintsupport.qdocconf b/src/printsupport/doc/qtprintsupport.qdocconf index d8fbc23c0a..fbb6f8d1a9 100644 --- a/src/printsupport/doc/qtprintsupport.qdocconf +++ b/src/printsupport/doc/qtprintsupport.qdocconf @@ -4,7 +4,7 @@ project = QtPrintSupport description = Qt Print Support Reference Documentation version = $QT_VERSION -examplesinstallpath = qtbase/printsupport +examplesinstallpath = printsupport qhp.projects = QtPrintSupport diff --git a/src/sql/doc/qtsql.qdocconf b/src/sql/doc/qtsql.qdocconf index ceaa75f455..5a224adeb9 100644 --- a/src/sql/doc/qtsql.qdocconf +++ b/src/sql/doc/qtsql.qdocconf @@ -4,7 +4,7 @@ project = QtSql description = Qt SQL Reference Documentation version = $QT_VERSION -examplesinstallpath = qtbase/sql +examplesinstallpath = sql qhp.projects = QtSql diff --git a/src/testlib/doc/qttestlib.qdocconf b/src/testlib/doc/qttestlib.qdocconf index 72db51b925..0fafc733b1 100644 --- a/src/testlib/doc/qttestlib.qdocconf +++ b/src/testlib/doc/qttestlib.qdocconf @@ -4,7 +4,7 @@ project = QtTestLib description = Qt Test Reference Documentation version = $QT_VERSION -examplesinstallpath = qtbase/testlib +examplesinstallpath = testlib qhp.projects = QtTestLib diff --git a/src/widgets/doc/qtwidgets.qdocconf b/src/widgets/doc/qtwidgets.qdocconf index 8160396ca2..f307e9d3e4 100644 --- a/src/widgets/doc/qtwidgets.qdocconf +++ b/src/widgets/doc/qtwidgets.qdocconf @@ -4,7 +4,7 @@ project = QtWidgets description = Qt Widgets Reference Documentation version = $QT_VERSION -examplesinstallpath = qtbase/widgets +examplesinstallpath = widgets qhp.projects = QtWidgets diff --git a/src/xml/doc/qtxml.qdocconf b/src/xml/doc/qtxml.qdocconf index b31c2a18d2..a23915487f 100644 --- a/src/xml/doc/qtxml.qdocconf +++ b/src/xml/doc/qtxml.qdocconf @@ -4,7 +4,7 @@ project = QtXml description = Qt XML Reference Documentation version = $QT_VERSION -examplesinstallpath = qtbase/xml +examplesinstallpath = xml qhp.projects = QtXml -- cgit v1.2.3 From d6fbb9070f518443f7ebeb0eae53847814e2496b Mon Sep 17 00:00:00 2001 From: Leena Miettinen Date: Mon, 9 May 2016 16:42:11 +0200 Subject: Doc: Remove references to obsolete reset() function ...from the docs of the signals it emits. Task-number: QTBUG-53228 Change-Id: Ifdd91404cae9dd6480ae29b31f2a48fa024df442 Reviewed-by: Nico Vertriest --- src/corelib/itemmodels/qabstractitemmodel.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/itemmodels/qabstractitemmodel.cpp b/src/corelib/itemmodels/qabstractitemmodel.cpp index 90297b9115..630cdcae98 100644 --- a/src/corelib/itemmodels/qabstractitemmodel.cpp +++ b/src/corelib/itemmodels/qabstractitemmodel.cpp @@ -3653,7 +3653,7 @@ bool QAbstractListModel::dropMimeData(const QMimeData *data, Qt::DropAction acti \fn QAbstractItemModel::modelAboutToBeReset() \since 4.2 - This signal is emitted when reset() is called, before the model's internal + This signal is emitted when beginResetModel() is called, before the model's internal state (e.g. persistent model indexes) has been invalidated. \sa beginResetModel(), modelReset() @@ -3663,7 +3663,7 @@ bool QAbstractListModel::dropMimeData(const QMimeData *data, Qt::DropAction acti \fn QAbstractItemModel::modelReset() \since 4.1 - This signal is emitted when reset() or endResetModel() is called, after the + This signal is emitted when endResetModel() is called, after the model's internal state (e.g. persistent model indexes) has been invalidated. Note that if a model is reset it should be considered that all information -- cgit v1.2.3 From f199bb9133fe0446c3afbecf0470a20b3f3e3d74 Mon Sep 17 00:00:00 2001 From: Dmitry Shachnev Date: Thu, 12 May 2016 11:02:29 +0300 Subject: dbustray: Use separate D-Bus connections for each tray icon This allows applications to use two or more QSystemTrayIcons. Task-number: QTBUG-53021 Change-Id: I520db99c1c3718906669d1b544d44a8d2f71e1ce Reviewed-by: Olivier Goffart (Woboq GmbH) Reviewed-by: Shawn Rutledge --- src/platformsupport/dbusmenu/qdbusmenuconnection.cpp | 5 +++-- src/platformsupport/dbusmenu/qdbusmenuconnection_p.h | 2 +- src/platformsupport/dbustray/qdbustrayicon.cpp | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/platformsupport/dbusmenu/qdbusmenuconnection.cpp b/src/platformsupport/dbusmenu/qdbusmenuconnection.cpp index 66a74e7a9a..2a0bb8878e 100644 --- a/src/platformsupport/dbusmenu/qdbusmenuconnection.cpp +++ b/src/platformsupport/dbusmenu/qdbusmenuconnection.cpp @@ -59,9 +59,10 @@ const QString MenuBarPath = QLatin1String("/MenuBar"); A D-Bus connection which is used for both menu and tray icon services. Connects to the session bus and registers with the respective watcher services. */ -QDBusMenuConnection::QDBusMenuConnection(QObject *parent) +QDBusMenuConnection::QDBusMenuConnection(QObject *parent, const QString &serviceName) : QObject(parent) - , m_connection(QDBusConnection::sessionBus()) + , m_connection(serviceName.isNull() ? QDBusConnection::sessionBus() + : QDBusConnection::connectToBus(QDBusConnection::SessionBus, serviceName)) , m_dbusWatcher(new QDBusServiceWatcher(StatusNotifierWatcherService, m_connection, QDBusServiceWatcher::WatchForRegistration, this)) , m_statusNotifierHostRegistered(false) { diff --git a/src/platformsupport/dbusmenu/qdbusmenuconnection_p.h b/src/platformsupport/dbusmenu/qdbusmenuconnection_p.h index 9208d38c9b..e168d73791 100644 --- a/src/platformsupport/dbusmenu/qdbusmenuconnection_p.h +++ b/src/platformsupport/dbusmenu/qdbusmenuconnection_p.h @@ -61,7 +61,7 @@ class QDBusMenuConnection : public QObject Q_OBJECT public: - QDBusMenuConnection(QObject *parent = 0); + QDBusMenuConnection(QObject *parent = 0, const QString &serviceName = QString()); QDBusConnection connection() const { return m_connection; } bool isStatusNotifierHostRegistered() const { return m_statusNotifierHostRegistered; } #ifndef QT_NO_SYSTEMTRAYICON diff --git a/src/platformsupport/dbustray/qdbustrayicon.cpp b/src/platformsupport/dbustray/qdbustrayicon.cpp index 7dbdb3a35b..4d6e70720d 100644 --- a/src/platformsupport/dbustray/qdbustrayicon.cpp +++ b/src/platformsupport/dbustray/qdbustrayicon.cpp @@ -165,7 +165,7 @@ QTemporaryFile *QDBusTrayIcon::tempIcon(const QIcon &icon) QDBusMenuConnection * QDBusTrayIcon::dBusConnection() { if (!m_dbusConnection) { - m_dbusConnection = new QDBusMenuConnection(this); + m_dbusConnection = new QDBusMenuConnection(this, m_instanceId); m_notifier = new QXdgNotificationInterface(XdgNotificationService, XdgNotificationPath, m_dbusConnection->connection(), this); connect(m_notifier, SIGNAL(NotificationClosed(uint,uint)), this, SLOT(notificationClosed(uint,uint))); -- cgit v1.2.3 From 4dc29bc9de1da1d373962dbd4b1d232f38ffeee0 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Thu, 12 May 2016 12:33:04 +0200 Subject: QSharedPointer: move QDebug stream operators into qdebug.h In order to avoid pulling in QDebug when including QSharedPointer. Change-Id: I14b86d1f100ed44a68258c91bbda394b655bac83 Reviewed-by: Friedemann Kleint Reviewed-by: Thiago Macieira --- src/corelib/io/qdebug.cpp | 11 +++++++++++ src/corelib/io/qdebug.h | 9 +++++++++ src/corelib/tools/qsharedpointer.cpp | 11 ----------- src/corelib/tools/qsharedpointer.h | 2 -- src/corelib/tools/qsharedpointer_impl.h | 11 ----------- 5 files changed, 20 insertions(+), 24 deletions(-) diff --git a/src/corelib/io/qdebug.cpp b/src/corelib/io/qdebug.cpp index ffa7867d18..0d9fdb3453 100644 --- a/src/corelib/io/qdebug.cpp +++ b/src/corelib/io/qdebug.cpp @@ -793,6 +793,17 @@ QDebug &QDebug::resetFormat() Writes \a flag to \a stream. */ +/*! + \fn QDebug operator<<(QDebug debug, const QSharedPointer &ptr) + \relates QSharedPointer + \since 5.7 + + Writes the pointer tracked by \a ptr into the debug object \a debug for + debugging purposes. + + \sa {Debugging Techniques} +*/ + /*! \class QDebugStateSaver \inmodule QtCore diff --git a/src/corelib/io/qdebug.h b/src/corelib/io/qdebug.h index 5087e3b532..8021f29e16 100644 --- a/src/corelib/io/qdebug.h +++ b/src/corelib/io/qdebug.h @@ -51,6 +51,7 @@ #include #include #include +#include // all these have already been included by various headers above, but don't rely on indirect includes: #include @@ -330,6 +331,14 @@ inline QDebug operator<<(QDebug debug, const QContiguousCache &cache) return debug.maybeSpace(); } +template +inline QDebug operator<<(QDebug debug, const QSharedPointer &ptr) +{ + QDebugStateSaver saver(debug); + debug.nospace() << "QSharedPointer(" << ptr.data() << ")"; + return debug; +} + Q_CORE_EXPORT void qt_QMetaEnum_flagDebugOperator(QDebug &debug, size_t sizeofT, int value); template diff --git a/src/corelib/tools/qsharedpointer.cpp b/src/corelib/tools/qsharedpointer.cpp index d03e3129aa..84afb0c5db 100644 --- a/src/corelib/tools/qsharedpointer.cpp +++ b/src/corelib/tools/qsharedpointer.cpp @@ -1299,17 +1299,6 @@ compile. Use qSharedPointerConstCast to cast away the constness. */ -/*! - \fn QDebug operator<<(QDebug debug, const QSharedPointer &ptr) - \relates QSharedPointer - \since 5.7 - - Writes the pointer tracked by \a ptr into the debug object \a debug for - debugging purposes. - - \sa {Debugging Techniques} -*/ - #include #include diff --git a/src/corelib/tools/qsharedpointer.h b/src/corelib/tools/qsharedpointer.h index 901862e7a2..72976637d5 100644 --- a/src/corelib/tools/qsharedpointer.h +++ b/src/corelib/tools/qsharedpointer.h @@ -159,8 +159,6 @@ template QSharedPointer qSharedPointerObjectCast(const QWe template QWeakPointer qWeakPointerCast(const QWeakPointer &src); -template QDebug operator<<(QDebug debug, const QSharedPointer &ptr); - QT_END_NAMESPACE #endif // Q_QDOC diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h index 6a5c8f4fe5..e9a5443121 100644 --- a/src/corelib/tools/qsharedpointer_impl.h +++ b/src/corelib/tools/qsharedpointer_impl.h @@ -62,7 +62,6 @@ QT_END_NAMESPACE #include #include #include // for qobject_cast -#include #if QT_DEPRECATED_SINCE(5, 6) #include #endif @@ -877,16 +876,6 @@ inline void qSwap(QSharedPointer &p1, QSharedPointer &p2) p1.swap(p2); } -#ifndef QT_NO_DEBUG_STREAM -template -Q_INLINE_TEMPLATE QDebug operator<<(QDebug debug, const QSharedPointer &ptr) -{ - QDebugStateSaver saver(debug); - debug.nospace() << "QSharedPointer(" << ptr.data() << ")"; - return debug; -} -#endif - QT_END_NAMESPACE namespace std { template -- cgit v1.2.3 From ac2ccb1559c726f3b42473e915ef146714885213 Mon Sep 17 00:00:00 2001 From: Alex Trotsenko Date: Wed, 11 May 2016 13:33:05 +0300 Subject: QHttpSocketEngine: set error on unsupported operations Force overloads which relate to UDP or listening to fail with a 'UnsupportedSocketOperationError' error code. Change-Id: I057c47864ee1d9c95b413edfda977dd0607844cb Reviewed-by: Timur Pocheptsov --- src/network/socket/qhttpsocketengine.cpp | 34 +++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/src/network/socket/qhttpsocketengine.cpp b/src/network/socket/qhttpsocketengine.cpp index 73b42ba432..f9ff958525 100644 --- a/src/network/socket/qhttpsocketengine.cpp +++ b/src/network/socket/qhttpsocketengine.cpp @@ -188,17 +188,26 @@ bool QHttpSocketEngine::connectToHostByName(const QString &hostname, quint16 por bool QHttpSocketEngine::bind(const QHostAddress &, quint16) { + qWarning("Operation is not supported"); + setError(QAbstractSocket::UnsupportedSocketOperationError, + QLatin1String("Unsupported socket operation")); return false; } bool QHttpSocketEngine::listen() { + qWarning("Operation is not supported"); + setError(QAbstractSocket::UnsupportedSocketOperationError, + QLatin1String("Unsupported socket operation")); return false; } int QHttpSocketEngine::accept() { - return 0; + qWarning("Operation is not supported"); + setError(QAbstractSocket::UnsupportedSocketOperationError, + QLatin1String("Unsupported socket operation")); + return -1; } void QHttpSocketEngine::close() @@ -251,16 +260,18 @@ qint64 QHttpSocketEngine::write(const char *data, qint64 len) bool QHttpSocketEngine::joinMulticastGroup(const QHostAddress &, const QNetworkInterface &) { + qWarning("Operation is not supported"); setError(QAbstractSocket::UnsupportedSocketOperationError, - QLatin1String("Operation on socket is not supported")); + QLatin1String("Unsupported socket operation")); return false; } bool QHttpSocketEngine::leaveMulticastGroup(const QHostAddress &, const QNetworkInterface &) { + qWarning("Operation is not supported"); setError(QAbstractSocket::UnsupportedSocketOperationError, - QLatin1String("Operation on socket is not supported")); + QLatin1String("Unsupported socket operation")); return false; } @@ -271,30 +282,39 @@ QNetworkInterface QHttpSocketEngine::multicastInterface() const bool QHttpSocketEngine::setMulticastInterface(const QNetworkInterface &) { + qWarning("Operation is not supported"); setError(QAbstractSocket::UnsupportedSocketOperationError, - QLatin1String("Operation on socket is not supported")); + QLatin1String("Unsupported socket operation")); return false; } #endif // QT_NO_NETWORKINTERFACE qint64 QHttpSocketEngine::readDatagram(char *, qint64, QIpPacketHeader *, PacketHeaderOptions) { - return 0; + qWarning("Operation is not supported"); + setError(QAbstractSocket::UnsupportedSocketOperationError, + QLatin1String("Unsupported socket operation")); + return -1; } qint64 QHttpSocketEngine::writeDatagram(const char *, qint64, const QIpPacketHeader &) { - return 0; + qWarning("Operation is not supported"); + setError(QAbstractSocket::UnsupportedSocketOperationError, + QLatin1String("Unsupported socket operation")); + return -1; } bool QHttpSocketEngine::hasPendingDatagrams() const { + qWarning("Operation is not supported"); return false; } qint64 QHttpSocketEngine::pendingDatagramSize() const { - return 0; + qWarning("Operation is not supported"); + return -1; } #endif // QT_NO_UDPSOCKET -- cgit v1.2.3 From e9d1d659a34386950c6740f5fb3b9c222b25a65d Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 11 May 2016 16:59:20 -0700 Subject: src.pro: include the build of bootstrap-dbus in developer builds This is just a compile test for the the bootstrapped version of QtDBus (no QObject). Nothing depends on it in regular, non-cross-compilation builds. Change-Id: Id69569111e7d4e619e22ffff144da8e646d037d9 Reviewed-by: Oswald Buddenhagen --- src/src.pro | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/src.pro b/src/src.pro index 167133859b..d68384d4a2 100644 --- a/src/src.pro +++ b/src/src.pro @@ -140,7 +140,8 @@ TOOLS = src_tools_moc src_tools_rcc src_tools_qlalr win32:SUBDIRS += src_winmain SUBDIRS += src_network src_sql src_xml src_testlib contains(QT_CONFIG, dbus) { - force_bootstrap: SUBDIRS += src_tools_bootstrap_dbus + force_bootstrap|contains(QT_CONFIG, private_tests): \ + SUBDIRS += src_tools_bootstrap_dbus SUBDIRS += src_dbus src_tools_qdbusxml2cpp src_tools_qdbuscpp2xml TOOLS += src_tools_qdbusxml2cpp src_tools_qdbuscpp2xml contains(QT_CONFIG, accessibility-atspi-bridge): \ -- cgit v1.2.3 From 29ac941c1e13d067000fe57a441ff55604d46848 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 28 Apr 2016 18:48:11 -0700 Subject: Bearer: replace the use of QMutexPool in the Windows plugin Use a simple Q_GLOBAL_STATIC Change-Id: Ifea6e497f11a461db432ffff1449b14b63628c12 Reviewed-by: Friedemann Kleint --- src/plugins/bearer/nativewifi/main.cpp | 59 ++++++++++++++-------------------- 1 file changed, 24 insertions(+), 35 deletions(-) diff --git a/src/plugins/bearer/nativewifi/main.cpp b/src/plugins/bearer/nativewifi/main.cpp index 48d79d37ee..62245a118b 100644 --- a/src/plugins/bearer/nativewifi/main.cpp +++ b/src/plugins/bearer/nativewifi/main.cpp @@ -35,7 +35,6 @@ #include "platformdefs.h" #include -#include #include #include @@ -46,42 +45,32 @@ QT_BEGIN_NAMESPACE -static void resolveLibrary() +static bool resolveLibraryInternal() { - static QBasicAtomicInt triedResolve = Q_BASIC_ATOMIC_INITIALIZER(false); - - if (!triedResolve.loadAcquire()) { -#ifndef QT_NO_THREAD - QMutexLocker locker(QMutexPool::globalInstanceGet(&local_WlanOpenHandle)); -#endif - - if (!triedResolve.load()) { - QLibrary wlanapiLib(QLatin1String("wlanapi")); - local_WlanOpenHandle = (WlanOpenHandleProto) - wlanapiLib.resolve("WlanOpenHandle"); - local_WlanRegisterNotification = (WlanRegisterNotificationProto) - wlanapiLib.resolve("WlanRegisterNotification"); - local_WlanEnumInterfaces = (WlanEnumInterfacesProto) - wlanapiLib.resolve("WlanEnumInterfaces"); - local_WlanGetAvailableNetworkList = (WlanGetAvailableNetworkListProto) - wlanapiLib.resolve("WlanGetAvailableNetworkList"); - local_WlanQueryInterface = (WlanQueryInterfaceProto) - wlanapiLib.resolve("WlanQueryInterface"); - local_WlanConnect = (WlanConnectProto) - wlanapiLib.resolve("WlanConnect"); - local_WlanDisconnect = (WlanDisconnectProto) - wlanapiLib.resolve("WlanDisconnect"); - local_WlanScan = (WlanScanProto) - wlanapiLib.resolve("WlanScan"); - local_WlanFreeMemory = (WlanFreeMemoryProto) - wlanapiLib.resolve("WlanFreeMemory"); - local_WlanCloseHandle = (WlanCloseHandleProto) - wlanapiLib.resolve("WlanCloseHandle"); - - triedResolve.storeRelease(true); - } - } + QLibrary wlanapiLib(QLatin1String("wlanapi")); + local_WlanOpenHandle = (WlanOpenHandleProto) + wlanapiLib.resolve("WlanOpenHandle"); + local_WlanRegisterNotification = (WlanRegisterNotificationProto) + wlanapiLib.resolve("WlanRegisterNotification"); + local_WlanEnumInterfaces = (WlanEnumInterfacesProto) + wlanapiLib.resolve("WlanEnumInterfaces"); + local_WlanGetAvailableNetworkList = (WlanGetAvailableNetworkListProto) + wlanapiLib.resolve("WlanGetAvailableNetworkList"); + local_WlanQueryInterface = (WlanQueryInterfaceProto) + wlanapiLib.resolve("WlanQueryInterface"); + local_WlanConnect = (WlanConnectProto) + wlanapiLib.resolve("WlanConnect"); + local_WlanDisconnect = (WlanDisconnectProto) + wlanapiLib.resolve("WlanDisconnect"); + local_WlanScan = (WlanScanProto) + wlanapiLib.resolve("WlanScan"); + local_WlanFreeMemory = (WlanFreeMemoryProto) + wlanapiLib.resolve("WlanFreeMemory"); + local_WlanCloseHandle = (WlanCloseHandleProto) + wlanapiLib.resolve("WlanCloseHandle"); + return true; } +Q_GLOBAL_STATIC_WITH_ARGS(bool, resolveLibrary, (resolveLibraryInternal())) class QNativeWifiEnginePlugin : public QBearerEnginePlugin { -- cgit v1.2.3 From c9998b8af39bcf990f4ef9a0ff87b65574a86bfd Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 9 May 2016 11:19:27 -0700 Subject: Fix build with GCC <= 4.2 (FreeBSD 9.x) 15b42af11123f9d1eb4bbd79870185585103ea8d changed the qt_cpu_features variable to be an array and never fixed this #if branch of the code. Change-Id: Id69569111e7d4e619e22ffff144cf930f86f478e Reviewed-by: Oswald Buddenhagen Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/tools/qsimd.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/corelib/tools/qsimd.cpp b/src/corelib/tools/qsimd.cpp index 5ca2ce4c6f..a1ee5b6348 100644 --- a/src/corelib/tools/qsimd.cpp +++ b/src/corelib/tools/qsimd.cpp @@ -666,7 +666,11 @@ void qDetectCpuFeatures() // contains all the features that the code required. Qt 4 ran for years // like that, so it shouldn't be a problem. - qt_cpu_features.store(minFeature | quint32(QSimdInitialized)); + qt_cpu_features[0].store(minFeature | quint32(QSimdInitialized)); +#ifndef Q_ATOMIC_INT64_IS_SUPPORTED + qt_cpu_features[1].store(minFeature >> 32); +#endif + return; # endif #endif -- cgit v1.2.3 From 8d5b1bdca8b13972fc653638fca426a5485343b1 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 1 Aug 2015 13:31:55 -0700 Subject: configure: present some progress status for the detections The "checking for xxx... [yes|no]" is chosen so that it matches exactly what GNU Autoconf does. That way, any tools that parse the output will have less trouble. This feature is useful for us when debugging a build, as not all checks produce output in the configure summary. Change-Id: Id75834dab9ed466e94c7ffff14456edb646a1ced Reviewed-by: Oswald Buddenhagen --- config.tests/unix/compile.test | 8 +++----- configure | 1 + 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/config.tests/unix/compile.test b/config.tests/unix/compile.test index 598e2a2d4d..69d4285321 100755 --- a/config.tests/unix/compile.test +++ b/config.tests/unix/compile.test @@ -61,9 +61,6 @@ while [ "$#" -gt 0 ]; do shift done -# debuggery -[ "$VERBOSE" = "yes" ] && echo "$DESCRIPTION auto-detection... ($*)" - test -d "$OUTDIR/$TEST" || mkdir -p "$OUTDIR/$TEST" cd "$OUTDIR/$TEST" @@ -89,6 +86,7 @@ set -- \ "$SRCDIR/$TEST/$EXE.pro" \ -o "$OUTDIR/$TEST/Makefile" if [ "$VERBOSE" = "yes" ]; then + echo OUTDIR=$OUTDIR "$@" && $MAKE && SUCCESS=yes else OUTDIR=$OUTDIR "$@" >/dev/null 2>&1 && $MAKE >/dev/null 2>&1 && SUCCESS=yes @@ -96,9 +94,9 @@ fi # done if [ "$SUCCESS" != "yes" ]; then - [ "$VERBOSE" = "yes" ] && echo "$DESCRIPTION disabled." + [ "$VERBOSE" = "yes" ] && echo "$DESCRIPTION disabled." || echo " no." exit 1 else - [ "$VERBOSE" = "yes" ] && echo "$DESCRIPTION enabled." + [ "$VERBOSE" = "yes" ] && echo "$DESCRIPTION enabled." || echo " yes." exit 0 fi diff --git a/configure b/configure index f4555a746b..4c052d5a23 100755 --- a/configure +++ b/configure @@ -4280,6 +4280,7 @@ compileTest() if [ "$CFG_SHARED" = "no" ]; then test_config="$QMAKE_CONFIG static" fi + echo $ECHO_N "checking for $name... $ECHO_C" "$unixtests/compile.test" "$XQMAKESPEC" "$test_config" $OPT_VERBOSE "$relpath" "$outpath" "$path" "$name" $I_FLAGS $D_FLAGS $L_FLAGS "$@" } -- cgit v1.2.3 From d179931ada9c9055eb7c86ee264fa5f2e1ec3453 Mon Sep 17 00:00:00 2001 From: James McDonnell Date: Wed, 4 May 2016 15:18:01 -0400 Subject: Warn when -fontconfig forces -system-freetype Let the user know that configure's switch from -no-freetype/-qt-freetype to -system-freetype when -fontconfig is used is expected. Task-number: QTBUG-35886 Change-Id: I95daaeffb0878bb785149f314096405a5c0fdc7a Reviewed-by: Oswald Buddenhagen --- configure | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/configure b/configure index 4c052d5a23..ce5b9c2b27 100755 --- a/configure +++ b/configure @@ -5360,6 +5360,7 @@ if [ "$CFG_OPENGL" = "es2" ]; then fi # auto-detect FontConfig support +ORIG_CFG_FREETYPE="$CFG_FREETYPE" if [ "$CFG_FONTCONFIG" != "no" ]; then if [ -n "$PKG_CONFIG" ] && $PKG_CONFIG --exists fontconfig --exists freetype2 2>/dev/null; then QT_CFLAGS_FONTCONFIG=`$PKG_CONFIG --cflags fontconfig --cflags freetype2 2>/dev/null` @@ -7405,6 +7406,15 @@ if [ "$CFG_SHARED" = "no" ]; then echo "loaded plugins. Make sure to import all needed static plugins," echo "or compile needed modules into the library." fi +if [ "$CFG_FREETYPE" = "system" ]; then + if [ "$ORIG_CFG_FREETYPE" = "qt" ]; then + echo + echo "WARNING: Bundled FreeType can't be used. FontConfig use requires system FreeType." + elif [ "$ORIG_CFG_FREETYPE" = "no" ]; then + echo + echo "WARNING: FreeType can't be disabled. FontConfig use requires system FreeType." + fi +fi if [ "$CFG_OPENSSL" = "linked" ] && [ "$OPENSSL_LIBS" = "" ]; then echo echo "NOTE: When linking against OpenSSL, you can override the default" -- cgit v1.2.3 From 678e427948e03119e7496192d26facc7d94e9d16 Mon Sep 17 00:00:00 2001 From: James McDonnell Date: Fri, 18 Mar 2016 11:44:41 -0400 Subject: Adjust FreeType choice made by configureapp FontConfig requires FreeType, so choosing the system FontConfig (there isn't a bundled FontConfig) means that the system FreeType must be used. QNX ended up configured to include the bundled FreeType and the system FontConfig which produced a fault when bundled FreeType structures got passed through FontConfig to the system FreeType. Task-number: QTBUG-52578 Task-number: QTBUG-51417 Change-Id: I56add73d34320c1d08f63b57cb0fef1ba06264e8 Reviewed-by: Oswald Buddenhagen --- tools/configure/configureapp.cpp | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index 3be0ea2b7c..a03be4df0a 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -264,6 +264,7 @@ Configure::Configure(int& argc, char** argv) : verbose(0) dictionary[ "LIBJPEG" ] = "auto"; dictionary[ "LIBPNG" ] = "auto"; dictionary[ "FREETYPE" ] = "yes"; + dictionary[ "FREETYPE_FROM" ] = "default"; dictionary[ "HARFBUZZ" ] = "qt"; dictionary[ "ACCESSIBILITY" ] = "yes"; @@ -634,12 +635,16 @@ void Configure::parseCmdLine() } // Text Rendering -------------------------------------------- - else if (configCmdLine.at(i) == "-no-freetype") + else if (configCmdLine.at(i) == "-no-freetype") { dictionary[ "FREETYPE" ] = "no"; - else if (configCmdLine.at(i) == "-qt-freetype") + dictionary[ "FREETYPE_FROM" ] = "commandline"; + } else if (configCmdLine.at(i) == "-qt-freetype") { dictionary[ "FREETYPE" ] = "yes"; - else if (configCmdLine.at(i) == "-system-freetype") + dictionary[ "FREETYPE_FROM" ] = "commandline"; + } else if (configCmdLine.at(i) == "-system-freetype") { dictionary[ "FREETYPE" ] = "system"; + dictionary[ "FREETYPE_FROM" ] = "commandline"; + } else if (configCmdLine.at(i) == "-no-harfbuzz") dictionary[ "HARFBUZZ" ] = "no"; @@ -2588,6 +2593,9 @@ void Configure::autoDetection() if (dictionary["FONT_CONFIG"] == "auto") dictionary["FONT_CONFIG"] = checkAvailability("FONT_CONFIG") ? "yes" : "no"; + if ((dictionary["FONT_CONFIG"] == "yes") && (dictionary["FREETYPE_FROM"] == "default")) + dictionary["FREETYPE"] = "system"; + if (dictionary["DIRECTWRITE"] == "auto") dictionary["DIRECTWRITE"] = checkAvailability("DIRECTWRITE") ? "yes" : "no"; @@ -2717,6 +2725,22 @@ bool Configure::verifyConfiguration() } } + if ((dictionary["FONT_CONFIG"] == "yes") && (dictionary["FREETYPE_FROM"] == "commandline")) { + if (dictionary["FREETYPE"] == "yes") { + cout << "WARNING: Bundled FreeType can't be used." + " FontConfig use requires system FreeType." << endl; + dictionary["FREETYPE"] = "system"; + dictionary["FREETYPE_FROM"] = "override"; + prompt = true; + } else if (dictionary["FREETYPE"] == "no") { + cout << "WARNING: FreeType can't be disabled." + " FontConfig use requires system FreeType." << endl; + dictionary["FREETYPE"] = "system"; + dictionary["FREETYPE_FROM"] = "override"; + prompt = true; + } + } + if (prompt) promptKeyPress(); -- cgit v1.2.3 From 07dd6dbaee5bdcbeebc54f04dccc45ad4778eab4 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 30 Mar 2016 13:57:22 +0200 Subject: QLineEdit: Fix icons being too small on a High DPI screen without scaling. Remove the hardcoded size 16 from QLineEditIconButton. Replace QLineEditPrivate::iconSize() by QLineEditPrivate::sideWidgetParameters() returning a struct SideWidgetParameters containing icon size, widget size and margins. The 32x32 icon will then be used on a High DPI screen without scaling. Task-number: QTBUG-49374 Change-Id: I23c4a0cd078a58581c940aacfa65a3ad493c12dc Reviewed-by: Alessandro Portale --- src/widgets/widgets/qlineedit.cpp | 1 - src/widgets/widgets/qlineedit_p.cpp | 35 +++++++++++++++++++++++----------- src/widgets/widgets/qlineedit_p.h | 38 +++++++++++++++++++++++++++---------- 3 files changed, 52 insertions(+), 22 deletions(-) diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp index 6b32665065..2cad5d325c 100644 --- a/src/widgets/widgets/qlineedit.cpp +++ b/src/widgets/widgets/qlineedit.cpp @@ -2176,7 +2176,6 @@ void QLineEdit::changeEvent(QEvent *ev) d->control->setPasswordCharacter(style()->styleHint(QStyle::SH_LineEdit_PasswordCharacter, &opt, this)); d->control->setPasswordMaskDelay(style()->styleHint(QStyle::SH_LineEdit_PasswordMaskDelay, &opt, this)); } - d->m_iconSize = QSize(); update(); break; case QEvent::LayoutDirectionChange: diff --git a/src/widgets/widgets/qlineedit_p.cpp b/src/widgets/widgets/qlineedit_p.cpp index ff80c45c9a..b90ddacb7e 100644 --- a/src/widgets/widgets/qlineedit_p.cpp +++ b/src/widgets/widgets/qlineedit_p.cpp @@ -314,6 +314,12 @@ QLineEditIconButton::QLineEditIconButton(QWidget *parent) setFocusPolicy(Qt::NoFocus); } +QLineEditPrivate *QLineEditIconButton::lineEditPrivate() const +{ + QLineEdit *le = qobject_cast(parentWidget()); + return le ? static_cast(qt_widget_private(le)) : Q_NULLPTR; +} + void QLineEditIconButton::paintEvent(QPaintEvent *) { QPainter painter(this); @@ -325,7 +331,9 @@ void QLineEditIconButton::paintEvent(QPaintEvent *) QIcon::Mode state = QIcon::Disabled; if (isEnabled()) state = isDown() ? QIcon::Selected : QIcon::Normal; - const QSize iconSize(IconButtonSize, IconButtonSize); + const QLineEditPrivate *lep = lineEditPrivate(); + const int iconWidth = lep ? lep->sideWidgetParameters().iconSize : 16; + const QSize iconSize(iconWidth, iconWidth); const QPixmap iconPixmap = icon().pixmap(window, iconSize, state, QIcon::Off); QRect pixmapRect = QRect(QPoint(0, 0), iconSize); pixmapRect.moveCenter(rect().center()); @@ -340,8 +348,8 @@ void QLineEditIconButton::actionEvent(QActionEvent *e) const QAction *action = e->action(); if (isVisibleTo(parentWidget()) != action->isVisible()) { setVisible(action->isVisible()); - if (QLineEdit *le = qobject_cast(parentWidget())) - static_cast(qt_widget_private(le))->positionSideWidgets(); + if (QLineEditPrivate *lep = lineEditPrivate()) + lep->positionSideWidgets(); } } break; @@ -407,11 +415,15 @@ void QLineEditPrivate::_q_clearButtonClicked() } } -QSize QLineEditPrivate::iconSize() const +QLineEditPrivate::SideWidgetParameters QLineEditPrivate::sideWidgetParameters() const { - if (!m_iconSize.isValid()) // This might require style-specific handling (pixel metric). - m_iconSize = QSize(QLineEditIconButton::IconButtonSize + 6, QLineEditIconButton::IconButtonSize + 2); - return m_iconSize; + Q_Q(const QLineEdit); + SideWidgetParameters result; + result.iconSize = q->height() < 34 ? 16 : 32; + result.margin = result.iconSize / 4; + result.widgetWidth = result.iconSize + 6; + result.widgetHeight = result.iconSize + 2; + return result; } QIcon QLineEditPrivate::clearButtonIcon() const @@ -437,15 +449,16 @@ void QLineEditPrivate::positionSideWidgets() Q_Q(QLineEdit); if (hasSideWidgets()) { const QRect contentRect = q->rect(); - const QSize iconSize = QLineEditPrivate::iconSize(); - const int delta = QLineEditIconButton::IconMargin + iconSize.width(); - QRect widgetGeometry(QPoint(QLineEditIconButton::IconMargin, (contentRect.height() - iconSize.height()) / 2), iconSize); + const SideWidgetParameters p = sideWidgetParameters(); + const int delta = p.margin + p.widgetWidth; + QRect widgetGeometry(QPoint(p.margin, (contentRect.height() - p.widgetHeight) / 2), + QSize(p.widgetWidth, p.widgetHeight)); foreach (const SideWidgetEntry &e, leftSideWidgetList()) { e.widget->setGeometry(widgetGeometry); if (e.action->isVisible()) widgetGeometry.moveLeft(widgetGeometry.left() + delta); } - widgetGeometry.moveLeft(contentRect.width() - iconSize.width() - QLineEditIconButton::IconMargin); + widgetGeometry.moveLeft(contentRect.width() - p.widgetWidth - p.margin); foreach (const SideWidgetEntry &e, rightSideWidgetList()) { e.widget->setGeometry(widgetGeometry); if (e.action->isVisible()) diff --git a/src/widgets/widgets/qlineedit_p.h b/src/widgets/widgets/qlineedit_p.h index 60372ab393..1d81090b0f 100644 --- a/src/widgets/widgets/qlineedit_p.h +++ b/src/widgets/widgets/qlineedit_p.h @@ -65,6 +65,8 @@ QT_BEGIN_NAMESPACE +class QLineEditPrivate; + // QLineEditIconButton: This is a simple helper class that represents clickable icons that fade in with text class Q_AUTOTEST_EXPORT QLineEditIconButton : public QToolButton @@ -72,8 +74,6 @@ class Q_AUTOTEST_EXPORT QLineEditIconButton : public QToolButton Q_OBJECT Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity) public: - enum { IconMargin = 4, IconButtonSize = 16 }; - explicit QLineEditIconButton(QWidget *parent = 0); qreal opacity() const { return m_opacity; } @@ -93,6 +93,7 @@ private: #ifndef QT_NO_ANIMATION void startOpacityAnimation(qreal endValue); #endif + QLineEditPrivate *lineEditPrivate() const; qreal m_opacity; }; @@ -116,6 +117,13 @@ public: }; typedef QVector SideWidgetEntryList; + struct SideWidgetParameters { + int iconSize; + int widgetWidth; + int widgetHeight; + int margin; + }; + QLineEditPrivate() : control(0), frame(1), contextMenuEnabled(1), cursorVisible(0), dragEnabled(0), clickCausedFocus(0), hscroll(0), vscroll(0), @@ -206,7 +214,7 @@ public: QWidget *addAction(QAction *newAction, QAction *before, QLineEdit::ActionPosition, int flags = 0); void removeAction(QAction *action); - QSize iconSize() const; + SideWidgetParameters sideWidgetParameters() const; QIcon clearButtonIcon() const; void setClearButtonEnabled(bool enabled); void positionSideWidgets(); @@ -227,7 +235,6 @@ private: SideWidgetEntryList leadingSideWidgets; SideWidgetEntryList trailingSideWidgets; int lastTextSize; - mutable QSize m_iconSize; }; Q_DECLARE_TYPEINFO(QLineEditPrivate::SideWidgetEntry, Q_PRIMITIVE_TYPE); @@ -238,18 +245,29 @@ static bool isSideWidgetVisible(const QLineEditPrivate::SideWidgetEntry &e) inline int QLineEditPrivate::effectiveLeftTextMargin() const { - return leftTextMargin + (QLineEditIconButton::IconMargin + iconSize().width()) - * int(std::count_if(leftSideWidgetList().constBegin(), leftSideWidgetList().constEnd(), - isSideWidgetVisible)); + int result = leftTextMargin; + if (!leftSideWidgetList().isEmpty()) { + const SideWidgetParameters p = sideWidgetParameters(); + result += (p.margin + p.widgetWidth) + * int(std::count_if(leftSideWidgetList().constBegin(), leftSideWidgetList().constEnd(), + isSideWidgetVisible)); + } + return result; } inline int QLineEditPrivate::effectiveRightTextMargin() const { - return rightTextMargin + (QLineEditIconButton::IconMargin + iconSize().width()) - * int(std::count_if(rightSideWidgetList().constBegin(), rightSideWidgetList().constEnd(), - isSideWidgetVisible)); + int result = rightTextMargin; + if (!rightSideWidgetList().isEmpty()) { + const SideWidgetParameters p = sideWidgetParameters(); + result += (p.margin + p.widgetWidth) + * int(std::count_if(rightSideWidgetList().constBegin(), rightSideWidgetList().constEnd(), + isSideWidgetVisible)); + } + return result; } + #endif // QT_NO_LINEEDIT QT_END_NAMESPACE -- cgit v1.2.3 From 2852a8b87e3a8ed95b72d26b0e180b7fd4491cf3 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Fri, 26 Feb 2016 11:53:01 -0800 Subject: XCB: Auto-detect xcb-glx also with xcb-qt Task-number: QTBUG-43784 Change-Id: Iaa0388e34900f6241db8cd864caed4fb6fc32819 Reviewed-by: Laszlo Agocs --- configure | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/configure b/configure index ce5b9c2b27..a4819818d1 100755 --- a/configure +++ b/configure @@ -5555,6 +5555,11 @@ if [ "$CFG_XCB" != "no" ]; then if [ "$CFG_XCB" = "qt" ]; then QT_CONFIG="$QT_CONFIG xcb-qt" + + if compileTest qpa/xcb-glx "xcb-glx" $QMAKE_CFLAGS_XCB $QMAKE_LIBS_XCB; then + CFG_XCB_GLX=yes + QT_CONFIG="$QT_CONFIG xcb-glx" + fi else CFG_XCB="system" if [ -n "$PKG_CONFIG" ] && $PKG_CONFIG --exists "xcb >= 1.5" 2>/dev/null; then -- cgit v1.2.3 From 656e6ae9ea4a7981f6006fa14e30ce656cb39be5 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 11 May 2016 11:53:02 +0200 Subject: QtNetwork: port the last remaining Q_FOREACH loop and add QT_NO_FOREACH Port the last remaining Q_FOREACH user in QtNetwork to C++11 range-for and mark the library as Q_FOREACH-free, using QT_NO_FOREACH. Change-Id: I8977f151e3575422fc1154677e035274c018d66f Reviewed-by: Lars Knoll --- src/network/network.pro | 2 +- src/network/ssl/qsslcontext_openssl.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/network/network.pro b/src/network/network.pro index fed14616af..7a05f927c5 100644 --- a/src/network/network.pro +++ b/src/network/network.pro @@ -1,7 +1,7 @@ TARGET = QtNetwork QT = core-private -DEFINES += QT_NO_USING_NAMESPACE +DEFINES += QT_NO_USING_NAMESPACE QT_NO_FOREACH #DEFINES += QLOCALSERVER_DEBUG QLOCALSOCKET_DEBUG #DEFINES += QNETWORKDISKCACHE_DEBUG #DEFINES += QSSLSOCKET_DEBUG diff --git a/src/network/ssl/qsslcontext_openssl.cpp b/src/network/ssl/qsslcontext_openssl.cpp index ca296bd179..f132d0228c 100644 --- a/src/network/ssl/qsslcontext_openssl.cpp +++ b/src/network/ssl/qsslcontext_openssl.cpp @@ -207,7 +207,7 @@ init_context: QList ciphers = sslContext->sslConfiguration.ciphers(); if (ciphers.isEmpty()) ciphers = QSslSocketPrivate::defaultCiphers(); - foreach (const QSslCipher &cipher, ciphers) { + for (const QSslCipher &cipher : qAsConst(ciphers)) { if (first) first = false; else -- cgit v1.2.3 From 7248e97669373abe2950b6e36a6add45137e3ca4 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 11 May 2016 11:53:02 +0200 Subject: QtConcurrent/QtOpenGL(Extensions)/QtPrintSupport/QtTestLib/QtXml: add QT_NO_FOREACH Mark these libraries as what they are: Q_FOREACH-free, using QT_NO_FOREACH. Change-Id: I2a567d9fe67e15e9b6f0784525810b553dc50e1f Reviewed-by: Lars Knoll --- src/concurrent/concurrent.pro | 3 ++- src/opengl/opengl.pro | 3 ++- src/openglextensions/openglextensions.pro | 3 ++- src/printsupport/printsupport.pro | 2 +- src/testlib/testlib.pro | 1 + src/xml/xml.pro | 3 ++- 6 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/concurrent/concurrent.pro b/src/concurrent/concurrent.pro index 2a519314f3..fd15a3c758 100644 --- a/src/concurrent/concurrent.pro +++ b/src/concurrent/concurrent.pro @@ -2,7 +2,8 @@ TARGET = QtConcurrent QT = core-private CONFIG += exceptions -DEFINES += QT_NO_USING_NAMESPACE +DEFINES += QT_NO_USING_NAMESPACE QT_NO_FOREACH + win32-msvc*|win32-icc:QMAKE_LFLAGS += /BASE:0x66000000 QMAKE_DOCS = $$PWD/doc/qtconcurrent.qdocconf diff --git a/src/opengl/opengl.pro b/src/opengl/opengl.pro index 007f73c45f..2386ef5d19 100644 --- a/src/opengl/opengl.pro +++ b/src/opengl/opengl.pro @@ -1,7 +1,8 @@ TARGET = QtOpenGL QT = core-private gui-private widgets-private -DEFINES += QT_NO_USING_NAMESPACE +DEFINES += QT_NO_USING_NAMESPACE QT_NO_FOREACH + win32-msvc*|win32-icc:QMAKE_LFLAGS += /BASE:0x63000000 solaris-cc*:QMAKE_CXXFLAGS_RELEASE -= -O2 irix-cc*:QMAKE_CXXFLAGS += -no_prelink -ptused diff --git a/src/openglextensions/openglextensions.pro b/src/openglextensions/openglextensions.pro index 18eec27e1c..04a871114b 100644 --- a/src/openglextensions/openglextensions.pro +++ b/src/openglextensions/openglextensions.pro @@ -4,7 +4,8 @@ CONFIG += static contains(QT_CONFIG, opengl):CONFIG += opengl contains(QT_CONFIG, opengles2):CONFIG += opengles2 -DEFINES += QT_NO_CAST_FROM_ASCII +DEFINES += QT_NO_CAST_FROM_ASCII QT_NO_FOREACH + PRECOMPILED_HEADER = HEADERS = qopenglextensions.h diff --git a/src/printsupport/printsupport.pro b/src/printsupport/printsupport.pro index 52eab672d3..52e99803c3 100644 --- a/src/printsupport/printsupport.pro +++ b/src/printsupport/printsupport.pro @@ -1,7 +1,7 @@ TARGET = QtPrintSupport QT = core-private gui-private widgets-private -DEFINES += QT_NO_USING_NAMESPACE +DEFINES += QT_NO_USING_NAMESPACE QT_NO_FOREACH QMAKE_DOCS = $$PWD/doc/qtprintsupport.qdocconf diff --git a/src/testlib/testlib.pro b/src/testlib/testlib.pro index 85fb0cd2fe..372a69c3ed 100644 --- a/src/testlib/testlib.pro +++ b/src/testlib/testlib.pro @@ -64,6 +64,7 @@ SOURCES = qtestcase.cpp \ DEFINES *= QT_NO_CAST_TO_ASCII \ QT_NO_CAST_FROM_ASCII \ + QT_NO_FOREACH \ QT_NO_DATASTREAM embedded:QMAKE_CXXFLAGS += -fno-rtti wince: LIBS += \ diff --git a/src/xml/xml.pro b/src/xml/xml.pro index f281e35444..cf9feda9bc 100644 --- a/src/xml/xml.pro +++ b/src/xml/xml.pro @@ -1,7 +1,8 @@ TARGET = QtXml QT = core-private -DEFINES += QT_NO_USING_NAMESPACE +DEFINES += QT_NO_USING_NAMESPACE QT_NO_FOREACH + win32-msvc*|win32-icc:QMAKE_LFLAGS += /BASE:0x61000000 QMAKE_DOCS = $$PWD/doc/qtxml.qdocconf -- cgit v1.2.3 From 2ac3fab45f1388591b3d1b73b8419ba45d63f064 Mon Sep 17 00:00:00 2001 From: Jesus Fernandez Date: Thu, 12 May 2016 16:20:47 +0200 Subject: Fixed crash in QAuthenticator::operator== [ChangeLog][QtNetwork][QAuthenticator] Fixed crash when comparing a initialized QAuthenticator with an uninitialized QAuthenticator. Task-number: QTBUG-53338 Change-Id: Ib8b732b9c65c02ee542885e5d6fe9bd1589a6b1a Reviewed-by: Timur Pocheptsov --- src/network/kernel/qauthenticator.cpp | 2 ++ .../network/kernel/qauthenticator/tst_qauthenticator.cpp | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/network/kernel/qauthenticator.cpp b/src/network/kernel/qauthenticator.cpp index 95994653e6..92d8779cab 100644 --- a/src/network/kernel/qauthenticator.cpp +++ b/src/network/kernel/qauthenticator.cpp @@ -193,6 +193,8 @@ bool QAuthenticator::operator==(const QAuthenticator &other) const { if (d == other.d) return true; + if (!d || !other.d) + return false; return d->user == other.d->user && d->password == other.d->password && d->realm == other.d->realm diff --git a/tests/auto/network/kernel/qauthenticator/tst_qauthenticator.cpp b/tests/auto/network/kernel/qauthenticator/tst_qauthenticator.cpp index 026a2a2722..90a6aa5811 100644 --- a/tests/auto/network/kernel/qauthenticator/tst_qauthenticator.cpp +++ b/tests/auto/network/kernel/qauthenticator/tst_qauthenticator.cpp @@ -52,6 +52,8 @@ private Q_SLOTS: void ntlmAuth_data(); void ntlmAuth(); + + void equalityOperators(); }; tst_QAuthenticator::tst_QAuthenticator() @@ -152,6 +154,20 @@ void tst_QAuthenticator::ntlmAuth() QVERIFY(priv->calculateResponse("GET", "/").startsWith("NTLM ")); } +void tst_QAuthenticator::equalityOperators() +{ + QAuthenticator s1, s2; + QVERIFY(s2 == s1); + QVERIFY(s1 == s2); + QVERIFY(!(s1 != s2)); + QVERIFY(!(s2 != s1)); + s1.setUser("User"); + QVERIFY(!(s2 == s1)); + QVERIFY(!(s1 == s2)); + QVERIFY(s1 != s2); + QVERIFY(s2 != s1); +} + QTEST_MAIN(tst_QAuthenticator); #include "tst_qauthenticator.moc" -- cgit v1.2.3 From ad54ac5a840c4a31e117fdedd6932ec450441ccc Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 12 May 2016 11:09:03 +0200 Subject: Fix building with -qreal float Min and max expressions need matching types, which means we have to take care both values are qreal. Task-number: QTCREATORBUG-15851 Change-Id: I5f123e979fa896006ff6eafaac1f65b667db975d Reviewed-by: Marc Mutz --- src/gui/painting/qpainter.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 62254213f3..1acd84754a 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -6268,7 +6268,7 @@ static void drawTextItemDecoration(QPainter *painter, const QPointF &pos, const pen.setColor(uc); // Adapt wave to underlineOffset or pen width, whatever is larger, to make it work on all platforms - const QPixmap wave = generateWavyPixmap(qMin(qMax(underlineOffset, pen.widthF()), maxHeight / 2.), pen); + const QPixmap wave = generateWavyPixmap(qMin(qMax(underlineOffset, pen.widthF()), maxHeight / qreal(2.)), pen); const int descent = qFloor(maxHeight); painter->setBrushOrigin(painter->brushOrigin().x(), 0); @@ -6279,7 +6279,7 @@ static void drawTextItemDecoration(QPainter *painter, const QPointF &pos, const // the text above it, but limit it to stay within descent. qreal adjustedUnderlineOffset = std::ceil(underlineOffset) + 0.5; if (underlineOffset <= fe->descent().toReal()) - adjustedUnderlineOffset = qMin(adjustedUnderlineOffset, fe->descent().toReal() - 0.5); + adjustedUnderlineOffset = qMin(adjustedUnderlineOffset, fe->descent().toReal() - qreal(0.5)); const qreal underlinePos = pos.y() + adjustedUnderlineOffset; QColor uc = charFormat.underlineColor(); if (uc.isValid()) -- cgit v1.2.3 From 5316befba2b2f63a4c4a4185a09bc6b149d3f842 Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Tue, 10 May 2016 16:21:08 +0200 Subject: ICO image format: fix regression in writing when size >= 256 In commit c6c9304, the earlier size limit of 128 was raised to the format's defined maximum of 256. But the required special storage of this size in the image structures was not implemented. Hence, attempting to store such big icons would result in invalid image files. Fix the size storing details, and add some autotests of ico format writing since that was practically uncovered. Task-number: QTBUG-53259 Change-Id: I00e17a04e90c32dcf1124ba5adaf53728fb74dc7 Reviewed-by: Friedemann Kleint --- src/plugins/imageformats/ico/qicohandler.cpp | 10 ++--- .../image/qicoimageformat/tst_qicoimageformat.cpp | 47 +++++++++++++++++++++ tests/auto/gui/image/qimagewriter/images/App.ico | Bin 0 -> 318 bytes .../gui/image/qimagewriter/tst_qimagewriter.cpp | 3 +- 4 files changed, 54 insertions(+), 6 deletions(-) create mode 100644 tests/auto/gui/image/qimagewriter/images/App.ico diff --git a/src/plugins/imageformats/ico/qicohandler.cpp b/src/plugins/imageformats/ico/qicohandler.cpp index 19525397fa..d4dcabeee6 100644 --- a/src/plugins/imageformats/ico/qicohandler.cpp +++ b/src/plugins/imageformats/ico/qicohandler.cpp @@ -54,7 +54,7 @@ QT_BEGIN_NAMESPACE typedef struct { quint8 bWidth; // Width of the image - quint8 bHeight; // Height of the image (times 2) + quint8 bHeight; // Height of the image (actual height, not times 2) quint8 bColorCount; // Number of colors in image (0 if >=8bpp) [ not ture ] quint8 bReserved; // Reserved quint16 wPlanes; // Color Planes @@ -681,8 +681,8 @@ bool ICOReader::write(QIODevice *device, const QVector &images) entries[i].bColorCount = 0; entries[i].bReserved = 0; entries[i].wBitCount = nbits; - entries[i].bHeight = image.height(); - entries[i].bWidth = image.width(); + entries[i].bHeight = image.height() < 256 ? image.height() : 0; // 0 means 256 + entries[i].bWidth = image.width() < 256 ? image.width() : 0; // 0 means 256 entries[i].dwBytesInRes = BMP_INFOHDR_SIZE + (bpl_bmp * image.height()) + (maskImage.bytesPerLine() * maskImage.height()); entries[i].wPlanes = 1; @@ -696,11 +696,11 @@ bool ICOReader::write(QIODevice *device, const QVector &images) bmpHeaders[i].biClrImportant = 0; bmpHeaders[i].biClrUsed = entries[i].bColorCount; bmpHeaders[i].biCompression = 0; - bmpHeaders[i].biHeight = entries[i].bHeight * 2; // 2 is for the mask + bmpHeaders[i].biHeight = entries[i].bHeight ? entries[i].bHeight * 2 : 256 * 2; // 2 is for the mask bmpHeaders[i].biPlanes = entries[i].wPlanes; bmpHeaders[i].biSize = BMP_INFOHDR_SIZE; bmpHeaders[i].biSizeImage = entries[i].dwBytesInRes - BMP_INFOHDR_SIZE; - bmpHeaders[i].biWidth = entries[i].bWidth; + bmpHeaders[i].biWidth = entries[i].bWidth ? entries[i].bWidth : 256; bmpHeaders[i].biXPelsPerMeter = 0; bmpHeaders[i].biYPelsPerMeter = 0; diff --git a/tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp b/tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp index bff762fd04..6d2ed6d304 100644 --- a/tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp +++ b/tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp @@ -64,6 +64,8 @@ private slots: void nextImageDelay(); void pngCompression_data(); void pngCompression(); + void write_data(); + void write(); private: QString m_IconPath; @@ -335,6 +337,51 @@ void tst_QIcoImageFormat::pngCompression() QCOMPARE(image.height(), height); } +void tst_QIcoImageFormat::write_data() +{ + QTest::addColumn("inSize"); + QTest::addColumn("outSize"); + + QTest::newRow("64x64") << QSize(64, 64) << QSize(64, 64); + QTest::newRow("128x200") << QSize(128, 200) << QSize(128, 200); + QTest::newRow("256x256") << QSize(256, 256) << QSize(256, 256); + QTest::newRow("400x400") << QSize(400, 400) << QSize(256, 256); +} + +void tst_QIcoImageFormat::write() +{ + QFETCH(QSize, inSize); + QFETCH(QSize, outSize); + + QImage inImg; + { + QImageReader reader(m_IconPath + "/valid/Qt.ico"); + reader.jumpToImage(4); + reader.setScaledSize(inSize); + inImg = reader.read(); + QVERIFY(!inImg.isNull()); + QCOMPARE(inImg.size(), inSize); + } + + QBuffer buf; + { + buf.open(QIODevice::WriteOnly); + QImageWriter writer(&buf, "ico"); + QVERIFY(writer.write(inImg)); + buf.close(); + } + { + buf.open(QIODevice::ReadOnly); + QImageReader reader(&buf); + QVERIFY(reader.canRead()); + QCOMPARE(reader.format(), QByteArray("ico")); + QImage outImg = reader.read(); + QVERIFY(!outImg.isNull()); + QCOMPARE(outImg.size(), outSize); + buf.close(); + } +} + QTEST_MAIN(tst_QIcoImageFormat) #include "tst_qicoimageformat.moc" diff --git a/tests/auto/gui/image/qimagewriter/images/App.ico b/tests/auto/gui/image/qimagewriter/images/App.ico new file mode 100644 index 0000000000..03b80a68f8 Binary files /dev/null and b/tests/auto/gui/image/qimagewriter/images/App.ico differ diff --git a/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp b/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp index b3fdd00eb6..0347ef8810 100644 --- a/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp +++ b/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp @@ -199,6 +199,7 @@ void tst_QImageWriter::writeImage_data() QTest::newRow("PBM: ship63") << QString("ship63.pbm") << true << QByteArray("pbm"); QTest::newRow("XBM: gnus") << QString("gnus.xbm") << false << QByteArray("xbm"); QTest::newRow("JPEG: beavis") << QString("beavis.jpg") << true << QByteArray("jpeg"); + QTest::newRow("ICO: App") << QString("App.ico") << true << QByteArray("ico"); } void tst_QImageWriter::writeImage() @@ -260,7 +261,7 @@ void tst_QImageWriter::writeImage2_data() QTest::addColumn("image"); const QStringList formats = QStringList() << "bmp" << "xpm" << "png" - << "ppm"; //<< "jpeg"; + << "ppm" << "ico"; //<< "jpeg"; QImage image0(70, 70, QImage::Format_ARGB32); image0.fill(QColor(Qt::red).rgb()); -- cgit v1.2.3 From 1af3a21c63d6867a08a912053031f2a92df61f04 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 11 May 2016 19:27:54 +0200 Subject: actually build an optimized qmake in release builds release_tools is not set in pure release builds - in fact, we complain if it is. Change-Id: Ifac73c0ef6f8967155b63f7fc9c9ce9de1acf337 Reviewed-by: Lars Knoll --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index f4555a746b..4ce83be84c 100755 --- a/configure +++ b/configure @@ -4039,7 +4039,7 @@ if true; then ###[ '!' -f "$outpath/bin/qmake" ]; setBootstrapVariable QMAKE_LFLAGS setBootstrapVariable QMAKE_LFLAGS_GCSECTIONS - if [ "$CFG_RELEASE_TOOLS" = "yes" ]; then + if [ "$CFG_DEBUG" = "no" ] || [ "$CFG_RELEASE_TOOLS" = "yes" ]; then setBootstrapVariable QMAKE_CFLAGS_RELEASE setBootstrapVariable QMAKE_CXXFLAGS_RELEASE EXTRA_CFLAGS="$EXTRA_CFLAGS \$(QMAKE_CFLAGS_RELEASE)" -- cgit v1.2.3 From 432d3b696296db9131bfa3daa67285f0eaedec41 Mon Sep 17 00:00:00 2001 From: Anton Kudryavtsev Date: Fri, 29 Apr 2016 14:52:28 +0300 Subject: QDateTimeParser: use QStringRef more Avoid unnecessary allocations. Change-Id: I217ba3fe20293f5cdeeaac2dfae15f837cda51e0 Reviewed-by: Thiago Macieira --- src/corelib/tools/qdatetimeparser.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/corelib/tools/qdatetimeparser.cpp b/src/corelib/tools/qdatetimeparser.cpp index 8ddf1d9e41..cc8c08d5b1 100644 --- a/src/corelib/tools/qdatetimeparser.cpp +++ b/src/corelib/tools/qdatetimeparser.cpp @@ -713,7 +713,7 @@ int QDateTimeParser::parseSection(const QDateTime ¤tValue, int sectionInde QDTPDEBUG << "sectionValue for" << sn.name() << "with text" << text << "and st" << sectiontext - << text.mid(index, sectionmaxsize) + << text.midRef(index, sectionmaxsize) << index; int used = 0; @@ -743,9 +743,8 @@ int QDateTimeParser::parseSection(const QDateTime ¤tValue, int sectionInde QDTPDEBUGN("This should never happen (findAmPm returned %d)", ampm); break; } - if (state != Invalid) { - text.replace(index, used, sectiontext.left(used)); - } + if (state != Invalid) + text.replace(index, used, sectiontext.constData(), used); break; } case MonthSection: case DayOfWeekSectionShort: @@ -764,7 +763,7 @@ int QDateTimeParser::parseSection(const QDateTime ¤tValue, int sectionInde if (num != -1) { state = (used == sectiontext.size() ? Acceptable : Intermediate); - text.replace(index, used, sectiontext.left(used)); + text.replace(index, used, sectiontext.constData(), used); } else { state = Intermediate; } @@ -810,7 +809,7 @@ int QDateTimeParser::parseSection(const QDateTime ¤tValue, int sectionInde } } if (ok && tmp <= absMax) { - QDTPDEBUG << sectiontext.left(digits) << tmp << digits; + QDTPDEBUG << sectiontext.leftRef(digits) << tmp << digits; last = tmp; used = digits; break; @@ -911,7 +910,7 @@ QDateTimeParser::StateNode QDateTimeParser::parse(QString &input, int &cursorPos for (int index=0; state != Invalid && index5.7 merge, I have to revert it until the problem investigated/fixed on OS X. Alas :( Change-Id: I52f6512d88c25d2e3071cb845e91faefbd455e27 Reviewed-by: Friedemann Kleint --- tests/auto/network/socket/qudpsocket/BLACKLIST | 12 ------------ tests/auto/network/socket/qudpsocket/test/test.pro | 2 ++ 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/tests/auto/network/socket/qudpsocket/BLACKLIST b/tests/auto/network/socket/qudpsocket/BLACKLIST index fb8455e6d3..3e936aebf6 100644 --- a/tests/auto/network/socket/qudpsocket/BLACKLIST +++ b/tests/auto/network/socket/qudpsocket/BLACKLIST @@ -6,15 +6,3 @@ osx osx [multicast:same bind, group ipv4 address] osx -[writeDatagramToNonExistingPeer] -windows -[asyncReadDatagram] -windows -[multicastLeaveAfterClose] -osx -[readyRead] -osx -[readyReadForEmptyDatagram] -osx -[asyncReadDatagram] -osx diff --git a/tests/auto/network/socket/qudpsocket/test/test.pro b/tests/auto/network/socket/qudpsocket/test/test.pro index e4812416dc..8ad16c652d 100644 --- a/tests/auto/network/socket/qudpsocket/test/test.pro +++ b/tests/auto/network/socket/qudpsocket/test/test.pro @@ -22,3 +22,5 @@ wince* { } TARGET = tst_qudpsocket + +CONFIG+=insignificant_test # QTBUG-25367, QTBUG-25368 -- cgit v1.2.3 From 9e4639060e56022e88c1c6b65df418cc25ce1759 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 3 May 2016 14:59:33 +0200 Subject: Move q{Set,}GlobalQHashSeed() to the correct header file The only contains the container these days, while contains the qHash() function overloads and related functions. This is where these two functions belong, too. This change is BC and SC, since qhash.h includes qhashfunctions.h. Change-Id: I2e7febb0ffca209af67fb9f2cd363596867a44e1 Reviewed-by: Olivier Goffart (Woboq GmbH) Reviewed-by: Thiago Macieira --- src/corelib/tools/qhash.h | 3 --- src/corelib/tools/qhashfunctions.h | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h index a5bde40fb8..adb7782efc 100644 --- a/src/corelib/tools/qhash.h +++ b/src/corelib/tools/qhash.h @@ -1040,9 +1040,6 @@ Q_INLINE_TEMPLATE int QMultiHash::count(const Key &key, const T &value) return n; } -Q_CORE_EXPORT int qGlobalQHashSeed(); -Q_CORE_EXPORT void qSetGlobalQHashSeed(int newSeed); - Q_DECLARE_ASSOCIATIVE_ITERATOR(Hash) Q_DECLARE_MUTABLE_ASSOCIATIVE_ITERATOR(Hash) diff --git a/src/corelib/tools/qhashfunctions.h b/src/corelib/tools/qhashfunctions.h index e15fbb07ac..704d45cb6c 100644 --- a/src/corelib/tools/qhashfunctions.h +++ b/src/corelib/tools/qhashfunctions.h @@ -58,6 +58,9 @@ class QString; class QStringRef; class QLatin1String; +Q_CORE_EXPORT int qGlobalQHashSeed(); +Q_CORE_EXPORT void qSetGlobalQHashSeed(int newSeed); + Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qHashBits(const void *p, size_t size, uint seed = 0) Q_DECL_NOTHROW; Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(char key, uint seed = 0) Q_DECL_NOTHROW { return uint(key) ^ seed; } -- cgit v1.2.3 From ed38750c035adbaa035257cd222193a5fdf7a254 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 30 Jun 2015 22:01:17 +0200 Subject: Add -Wzero-as-null-pointer-constant to headerclean check Requested by user(s). Change-Id: Id2c7d67a8cd50f4f83f141cff41ba01e21c3a603 Task-number: QTBUG-45291 Reviewed-by: Lars Knoll Reviewed-by: Thiago Macieira --- mkspecs/features/qt_module_headers.prf | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mkspecs/features/qt_module_headers.prf b/mkspecs/features/qt_module_headers.prf index 094c854ef0..66f7470a19 100644 --- a/mkspecs/features/qt_module_headers.prf +++ b/mkspecs/features/qt_module_headers.prf @@ -187,6 +187,16 @@ headersclean:!internal_module { !contains(QT_ARCH, arm):!contains(QT_ARCH, mips): \ hcleanFLAGS += -Wcast-align + + !clang { + # options accepted only by GCC + + c++11 { + # only enabled for actual c++11 builds due to + # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52806 + hcleanFLAGS += -Wzero-as-null-pointer-constant + } + } } # Use strict mode C++11 or C++98, with no GNU extensions (see -pedantic-errors above). -- cgit v1.2.3 From aebb54b24b38ce2fc182ccbce80f750a6d53d952 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Klitzing?= Date: Thu, 28 Apr 2016 17:34:16 +0200 Subject: Add ephemeralServerKey to isNull() and operator== MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Iacd0f55886847630b84a8037d8d26504c558c90e Reviewed-by: Sebastian Lösch Reviewed-by: Markus Goetz (Woboq GmbH) --- src/network/ssl/qsslconfiguration.cpp | 2 ++ src/network/ssl/qsslconfiguration_p.h | 1 + 2 files changed, 3 insertions(+) diff --git a/src/network/ssl/qsslconfiguration.cpp b/src/network/ssl/qsslconfiguration.cpp index f9bb28e033..c8040dec7f 100644 --- a/src/network/ssl/qsslconfiguration.cpp +++ b/src/network/ssl/qsslconfiguration.cpp @@ -211,6 +211,7 @@ bool QSslConfiguration::operator==(const QSslConfiguration &other) const d->sessionProtocol == other.d->sessionProtocol && d->ciphers == other.d->ciphers && d->ellipticCurves == other.d->ellipticCurves && + d->ephemeralServerKey == other.d->ephemeralServerKey && d->caCertificates == other.d->caCertificates && d->protocol == other.d->protocol && d->peerVerifyMode == other.d->peerVerifyMode && @@ -252,6 +253,7 @@ bool QSslConfiguration::isNull() const d->caCertificates.count() == 0 && d->ciphers.count() == 0 && d->ellipticCurves.isEmpty() && + d->ephemeralServerKey.isNull() && d->localCertificateChain.isEmpty() && d->privateKey.isNull() && d->peerCertificate.isNull() && diff --git a/src/network/ssl/qsslconfiguration_p.h b/src/network/ssl/qsslconfiguration_p.h index 093c9d6598..364bba92ec 100644 --- a/src/network/ssl/qsslconfiguration_p.h +++ b/src/network/ssl/qsslconfiguration_p.h @@ -88,6 +88,7 @@ public: peerSessionShared(false), sslOptions(QSslConfigurationPrivate::defaultSslOptions), sslSessionTicketLifeTimeHint(-1), + ephemeralServerKey(), nextProtocolNegotiationStatus(QSslConfiguration::NextProtocolNegotiationNone) { } -- cgit v1.2.3 From 186d391f256705f58b421e0cf20260e352e79603 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 11 May 2016 13:43:16 +0300 Subject: Work around QFont bug in QFontDialog test The QFontDialog test will currently fail for some PCF bitmap fonts because the list of smooth sizes it uses to populate its size list contains unsupported sizes. We work around this by adding QEXPECT_FAIL when we detect that the failure is going to happen. Task-number: QTBUG-46056 Task-number: QTBUG-53299 Change-Id: Ia665cca220f3622405d1a2336e8d587545cccbc6 Reviewed-by: Simon Hausmann --- tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp b/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp index 796b4b9fdb..9aacd3105e 100644 --- a/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp +++ b/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp @@ -193,11 +193,14 @@ void tst_QFontDialog::task256466_wrongStyle() for (int i = 0; i < familyList->model()->rowCount(); ++i) { QModelIndex currentFamily = familyList->model()->index(i, 0); familyList->setCurrentIndex(currentFamily); + int expectedSize = sizeList->currentIndex().data().toInt(); const QFont current = dialog.currentFont(), expected = fdb.font(currentFamily.data().toString(), - styleList->currentIndex().data().toString(), sizeList->currentIndex().data().toInt()); + styleList->currentIndex().data().toString(), expectedSize); QCOMPARE(current.family(), expected.family()); QCOMPARE(current.style(), expected.style()); + if (expectedSize == 0 && !QFontDatabase().isScalable(current.family(), current.styleName())) + QEXPECT_FAIL("", "QTBUG-53299: Smooth sizes for unscalable font contains unsupported size", Continue); QCOMPARE(current.pointSizeF(), expected.pointSizeF()); } } -- cgit v1.2.3 From dc40abe925db4a6d4f4236f61bb0c55b585c75da Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sun, 17 Aug 2014 13:05:59 -0700 Subject: Move out the code to extract the backtrace to another function This will make it easier to use create backtraces in other contexts. Change-Id: I56b838ab04d9810108fcdb7f8c2fd91255864850 Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/global/qlogging.cpp | 140 ++++++++++++++++++++++++---------------- 1 file changed, 85 insertions(+), 55 deletions(-) diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index 4851d1ce6f..f2e293c45b 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -54,6 +54,7 @@ #include "qthread.h" #include "private/qloggingregistry_p.h" #include "private/qcoreapplication_p.h" +#include "private/qsimd_p.h" #endif #ifdef Q_OS_WIN #include @@ -1193,6 +1194,89 @@ void QMessagePattern::setPattern(const QString &pattern) memcpy(literals, literalsVar.constData(), literalsVar.size() * sizeof(const char*)); } +#if defined(QLOGGING_HAVE_BACKTRACE) && !defined(QT_BOOTSTRAPPED) +// make sure the function has "Message" in the name so the function is removed + +#if (defined(Q_CC_GNU) && defined(QT_COMPILER_SUPPORTS_SIMD_ALWAYS)) || QT_HAS_ATTRIBUTE(optimize) +// force skipping the frame pointer, to save the backtrace() function some work +__attribute__((optimize("omit-frame-pointer"))) +#endif +static QStringList backtraceFramesForLogMessage(int frameCount) +{ + QStringList result; + if (frameCount == 0) + return result; + + // The results of backtrace_symbols looks like this: + // /lib/libc.so.6(__libc_start_main+0xf3) [0x4a937413] + // The offset and function name are optional. + // This regexp tries to extract the library name (without the path) and the function name. + // This code is protected by QMessagePattern::mutex so it is thread safe on all compilers + static QRegularExpression rx(QStringLiteral("^(?:[^(]*/)?([^(/]+)\\(([^+]*)(?:[\\+[a-f0-9x]*)?\\) \\[[a-f0-9x]*\\]$"), + QRegularExpression::OptimizeOnFirstUsageOption); + + QVarLengthArray buffer(7 + frameCount); + int n = backtrace(buffer.data(), buffer.size()); + if (n > 0) { + int numberPrinted = 0; + for (int i = 0; i < n && numberPrinted < frameCount; ++i) { + QScopedPointer strings(backtrace_symbols(buffer.data() + i, 1)); + QString trace = QString::fromLatin1(strings.data()[0]); + QRegularExpressionMatch m = rx.match(trace); + if (m.hasMatch()) { + QString library = m.captured(1); + QString function = m.captured(2); + + // skip the trace from QtCore that are because of the qDebug itself + if (!numberPrinted && library.contains(QLatin1String("Qt5Core")) + && (function.isEmpty() || function.contains(QLatin1String("Message"), Qt::CaseInsensitive) + || function.contains(QLatin1String("QDebug")))) { + continue; + } + + if (function.startsWith(QLatin1String("_Z"))) { + QScopedPointer demangled( + abi::__cxa_demangle(function.toUtf8(), 0, 0, 0)); + if (demangled) + function = QString::fromUtf8(qCleanupFuncinfo(demangled.data())); + } + + if (function.isEmpty()) { + result.append(QLatin1Char('?') + library + QLatin1Char('?')); + } else { + result.append(function); + } + } else { + if (numberPrinted == 0) { + // innermost, unknown frames are usually the logging framework itself + continue; + } + result.append(QStringLiteral("???")); + } + numberPrinted++; + } + } + return result; +} + +static QString formatBacktraceForLogMessage(const QMessagePattern::BacktraceParams backtraceParams, + const char *function) +{ + QString backtraceSeparator = backtraceParams.backtraceSeparator; + int backtraceDepth = backtraceParams.backtraceDepth; + + QStringList frames = backtraceFramesForLogMessage(backtraceDepth); + if (frames.isEmpty()) + return QString(); + + // if the first frame is unknown, replace it with the context function + if (function && frames.at(0).startsWith(QLatin1Char('?'))) + frames[0] = QString::fromUtf8(qCleanupFuncinfo(function)); + + return frames.join(backtraceSeparator); +} +#endif // QLOGGING_HAVE_BACKTRACE && !QT_BOOTSTRAPPED + #if defined(QT_USE_SLOG2) #ifndef QT_LOG_CODE #define QT_LOG_CODE 9000 @@ -1336,62 +1420,8 @@ QString qFormatLogMessage(QtMsgType type, const QMessageLogContext &context, con #ifdef QLOGGING_HAVE_BACKTRACE } else if (token == backtraceTokenC) { QMessagePattern::BacktraceParams backtraceParams = pattern->backtraceArgs.at(backtraceArgsIdx); - QString backtraceSeparator = backtraceParams.backtraceSeparator; - int backtraceDepth = backtraceParams.backtraceDepth; backtraceArgsIdx++; - QVarLengthArray buffer(7 + backtraceDepth); - int n = backtrace(buffer.data(), buffer.size()); - if (n > 0) { - int numberPrinted = 0; - for (int i = 0; i < n && numberPrinted < backtraceDepth; ++i) { - QScopedPointer strings(backtrace_symbols(buffer.data() + i, 1)); - QString trace = QString::fromLatin1(strings.data()[0]); - // The results of backtrace_symbols looks like this: - // /lib/libc.so.6(__libc_start_main+0xf3) [0x4a937413] - // The offset and function name are optional. - // This regexp tries to extract the librry name (without the path) and the function name. - // This code is protected by QMessagePattern::mutex so it is thread safe on all compilers - static QRegularExpression rx(QStringLiteral("^(?:[^(]*/)?([^(/]+)\\(([^+]*)(?:[\\+[a-f0-9x]*)?\\) \\[[a-f0-9x]*\\]$"), - QRegularExpression::OptimizeOnFirstUsageOption); - - QRegularExpressionMatch m = rx.match(trace); - if (m.hasMatch()) { - // skip the trace from QtCore that are because of the qDebug itself - QString library = m.captured(1); - QString function = m.captured(2); - if (!numberPrinted && library.contains(QLatin1String("Qt5Core")) - && (function.isEmpty() || function.contains(QLatin1String("Message"), Qt::CaseInsensitive) - || function.contains(QLatin1String("QDebug")))) { - continue; - } - - if (function.startsWith(QLatin1String("_Z"))) { - QScopedPointer demangled( - abi::__cxa_demangle(function.toUtf8(), 0, 0, 0)); - if (demangled) - function = QString::fromUtf8(qCleanupFuncinfo(demangled.data())); - } - - if (numberPrinted > 0) - message.append(backtraceSeparator); - - if (function.isEmpty()) { - if (numberPrinted == 0 && context.function) - message += QString::fromUtf8(qCleanupFuncinfo(context.function)); - else - message += QLatin1Char('?') + library + QLatin1Char('?'); - } else { - message += function; - } - - } else { - if (numberPrinted == 0) - continue; - message += backtraceSeparator + QLatin1String("???"); - } - numberPrinted++; - } - } + message.append(formatBacktraceForLogMessage(backtraceParams, context.function)); #endif } else if (token == timeTokenC) { QString timeFormat = pattern->timeArgs.at(timeArgsIdx); -- cgit v1.2.3 From 56b5706ce05895d2acab8de55abf5b7d3f69e80f Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sun, 3 Jan 2016 12:41:09 -0200 Subject: Remove dead code from QColorDialog Detected by GCC 6. Change-Id: I24a735698d3c4a719fc9ffff1425f193511406f9 Reviewed-by: Lars Knoll --- src/widgets/dialogs/qcolordialog.cpp | 35 ++++++----------------------------- 1 file changed, 6 insertions(+), 29 deletions(-) diff --git a/src/widgets/dialogs/qcolordialog.cpp b/src/widgets/dialogs/qcolordialog.cpp index 9a8bfc552d..6a1135920d 100644 --- a/src/widgets/dialogs/qcolordialog.cpp +++ b/src/widgets/dialogs/qcolordialog.cpp @@ -168,8 +168,6 @@ private: namespace { -struct QWellArrayData; - class QWellArray : public QWidget { Q_OBJECT @@ -189,8 +187,6 @@ public: QSize sizeHint() const Q_DECL_OVERRIDE; - virtual void setCellBrush(int row, int col, const QBrush &); - inline int cellWidth() const { return cellw; } @@ -257,7 +253,6 @@ private: int curCol; int selRow; int selCol; - QWellArrayData *d; }; void QWellArray::paintEvent(QPaintEvent *e) @@ -307,15 +302,10 @@ void QWellArray::paintEvent(QPaintEvent *e) } } -struct QWellArrayData { - QBrush *brush; -}; - QWellArray::QWellArray(int rows, int cols, QWidget *parent) : QWidget(parent) ,nrows(rows), ncols(cols) { - d = 0; setFocusPolicy(Qt::StrongFocus); cellw = 28; cellh = 24; @@ -364,14 +354,12 @@ void QWellArray::paintCell(QPainter* p, int row, int col, const QRect &rect) */ void QWellArray::paintCellContents(QPainter *p, int row, int col, const QRect &r) { - if (d) { - p->fillRect(r, d->brush[row*numCols()+col]); - } else { - p->fillRect(r, Qt::white); - p->setPen(Qt::black); - p->drawLine(r.topLeft(), r.bottomRight()); - p->drawLine(r.topRight(), r.bottomLeft()); - } + Q_UNUSED(row); + Q_UNUSED(col); + p->fillRect(r, Qt::white); + p->setPen(Qt::black); + p->drawLine(r.topLeft(), r.bottomRight()); + p->drawLine(r.topRight(), r.bottomLeft()); } void QWellArray::mousePressEvent(QMouseEvent *e) @@ -447,17 +435,6 @@ void QWellArray::focusInEvent(QFocusEvent*) emit currentChanged(curRow, curCol); } -void QWellArray::setCellBrush(int row, int col, const QBrush &b) -{ - if (!d) { - d = new QWellArrayData; - int i = numRows()*numCols(); - d->brush = new QBrush[i]; - } - if (row >= 0 && row < numRows() && col >= 0 && col < numCols()) - d->brush[row*numCols()+col] = b; -} - /*!\reimp */ -- cgit v1.2.3 From a26435d65ceac5d714d5cc7d5af2326e162d7a41 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 12 Apr 2016 15:58:32 -0700 Subject: Print the QStorageInfo dump on test start So we know what we're looking at if there's a test failure. This is like QNetworkInterface. Change-Id: Id75834dab9ed466e94c7ffff1444bf51f615e944 Reviewed-by: Thiago Macieira --- .../corelib/io/qstorageinfo/tst_qstorageinfo.cpp | 33 +++++++++++- tests/manual/qstorageinfo/main.cpp | 24 ++------- tests/manual/qstorageinfo/printvolumes.cpp | 58 ++++++++++++++++++++++ 3 files changed, 93 insertions(+), 22 deletions(-) create mode 100644 tests/manual/qstorageinfo/printvolumes.cpp diff --git a/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp b/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp index 1afcf05135..004ace4e2e 100644 --- a/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp +++ b/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp @@ -32,14 +32,18 @@ ****************************************************************************/ #include - #include +#include + +#include "../../../../manual/qstorageinfo/printvolumes.cpp" + class tst_QStorageInfo : public QObject { Q_OBJECT private slots: void defaultValues(); + void dump(); void operatorEqual(); #ifndef Q_OS_WINRT void operatorNotEqual(); @@ -66,6 +70,33 @@ void tst_QStorageInfo::defaultValues() QVERIFY(storage.bytesAvailable() == -1); } +static int qInfoPrinter(const char *format, ...) +{ + static char buf[1024]; + static size_t bufuse = 0; + + va_list ap; + va_start(ap, format); // use variable arg list + int n = qvsnprintf(buf + bufuse, sizeof(buf) - bufuse, format, ap); + va_end(ap); + + bufuse += n; + if (bufuse >= sizeof(buf) - 1 || format[strlen(format) - 1] == '\n') { + // flush + QtMessageHandler qt_message_print = qInstallMessageHandler(0); + qInstallMessageHandler(qt_message_print); // restore the handler + qt_message_print(QtInfoMsg, QMessageLogContext(), QString::fromLocal8Bit(buf)); + bufuse = 0; + } + + return 1; +} + +void tst_QStorageInfo::dump() +{ + printVolumes(QStorageInfo::mountedVolumes(), qInfoPrinter); +} + void tst_QStorageInfo::operatorEqual() { { diff --git a/tests/manual/qstorageinfo/main.cpp b/tests/manual/qstorageinfo/main.cpp index 5c106ff45b..61cdd55922 100644 --- a/tests/manual/qstorageinfo/main.cpp +++ b/tests/manual/qstorageinfo/main.cpp @@ -32,10 +32,11 @@ ****************************************************************************/ #include -#include #include +#include "printvolumes.cpp" + int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); @@ -57,26 +58,7 @@ int main(int argc, char *argv[]) if (volumes.isEmpty()) volumes = QStorageInfo::mountedVolumes(); - // Sample output: - // Filesystem (Type) Size Available BSize Label Mounted on - // /dev/sda2 (ext4) RO 388480 171218 1024 /boot - // /dev/mapper/system-root (btrfs) RW - // 214958080 39088272 4096 / - // /dev/disk1s2 (hfs) RW 488050672 419909696 4096 Macintosh HD2 /Volumes/Macintosh HD2 - - printf("Filesystem (Type) Size Available BSize Label Mounted on\n"); - foreach (const QStorageInfo &info, volumes) { - QByteArray fsAndType = info.device(); - if (info.fileSystemType() != fsAndType) - fsAndType += " (" + info.fileSystemType() + ')'; - - printf("%-19s R%c ", fsAndType.constData(), info.isReadOnly() ? 'O' : 'W'); - if (fsAndType.size() > 19) - printf("\n%23s", ""); - - printf("%10llu %10llu %5u ", info.bytesTotal() / 1024, info.bytesFree() / 1024, info.blockSize()); - printf("%-16s %s\n", qPrintable(info.name()), qPrintable(info.rootPath())); - } + printVolumes(volumes, printf); return 0; } diff --git a/tests/manual/qstorageinfo/printvolumes.cpp b/tests/manual/qstorageinfo/printvolumes.cpp new file mode 100644 index 0000000000..1b1660b433 --- /dev/null +++ b/tests/manual/qstorageinfo/printvolumes.cpp @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Intel Corporation +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +void printVolumes(const QList &volumes, int (*printer)(const char *, ...)) +{ + // Sample output: + // Filesystem (Type) Size Available BSize Label Mounted on + // /dev/sda2 (ext4) RO 388480 171218 1024 /boot + // /dev/mapper/system-root (btrfs) RW + // 214958080 39088272 4096 / + // /dev/disk1s2 (hfs) RW 488050672 419909696 4096 Macintosh HD2 /Volumes/Macintosh HD2 + + printf("Filesystem (Type) Size Available BSize Label Mounted on\n"); + foreach (const QStorageInfo &info, volumes) { + QByteArray fsAndType = info.device(); + if (info.fileSystemType() != fsAndType) + fsAndType += " (" + info.fileSystemType() + ')'; + + printf("%-19s R%c ", fsAndType.constData(), info.isReadOnly() ? 'O' : 'W'); + if (fsAndType.size() > 19) + printf("\n%23s", ""); + + printf("%10llu %10llu %5u ", info.bytesTotal() / 1024, info.bytesFree() / 1024, info.blockSize()); + printf("%-16s %s\n", qPrintable(info.name()), qPrintable(info.rootPath())); + } +} -- cgit v1.2.3 From 474af0a61d6154006966a775d186687aa8881708 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 21 Jan 2016 08:15:18 +0100 Subject: QWidget::mapTo/FromGlobal(): Rewrite using a QTransform. Introduce a function going up the widget hierarchy determining a QTransform for mapping the coordinates applying the transformations of any QGraphicsView instances found. In mapFromGlobal(), use the inverse of it. This fixes the case of widget hierarchies embedded into QGraphicsView with transformations. Increase fuzz in the tests due to float rounding errors. Task-number: QTBUG-41135 Task-number: QTBUG-50030 Task-number: QTBUG-50136 Task-number: QTBUG-52507 Change-Id: I507e0bccd546250fe9c2d1b74ef38657d61490b4 Reviewed-by: Marc Mutz --- src/widgets/kernel/qwidget.cpp | 99 ++++++++++++---------- .../tst_qgraphicsproxywidget.cpp | 17 ++-- 2 files changed, 62 insertions(+), 54 deletions(-) diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 48334cd169..0376ab88ac 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -12346,6 +12346,53 @@ static inline bool canMapPosition(QWindow *window) return window->handle() && !qt_window_private(window)->resizeEventPending; } +#ifndef QT_NO_GRAPHICSVIEW +static inline QGraphicsProxyWidget *graphicsProxyWidget(const QWidget *w) +{ + QGraphicsProxyWidget *result = Q_NULLPTR; + const QWidgetPrivate *d = qt_widget_private(const_cast(w)); + if (d->extra) + result = d->extra->proxyWidget; + return result; +} +#endif // !QT_NO_GRAPHICSVIEW + +struct MapToGlobalTransformResult { + QTransform transform; + QWindow *window; +}; + +static MapToGlobalTransformResult mapToGlobalTransform(const QWidget *w) +{ + MapToGlobalTransformResult result; + result.window = Q_NULLPTR; + for ( ; w ; w = w->parentWidget()) { +#ifndef QT_NO_GRAPHICSVIEW + if (QGraphicsProxyWidget *qgpw = graphicsProxyWidget(w)) { + if (const QGraphicsScene *scene = qgpw->scene()) { + const QList views = scene->views(); + if (!views.isEmpty()) { + result.transform *= qgpw->sceneTransform(); + result.transform *= views.first()->viewportTransform(); + w = views.first()->viewport(); + } + } + } +#endif // !QT_NO_GRAPHICSVIEW + QWindow *window = w->windowHandle(); + if (window && canMapPosition(window)) { + result.window = window; + break; + } + + const QPoint topLeft = w->geometry().topLeft(); + result.transform.translate(topLeft.x(), topLeft.y()); + if (w->isWindow()) + break; + } + return result; +} + /*! \fn QPoint QWidget::mapToGlobal(const QPoint &pos) const @@ -12357,29 +12404,9 @@ static inline bool canMapPosition(QWindow *window) */ QPoint QWidget::mapToGlobal(const QPoint &pos) const { -#ifndef QT_NO_GRAPHICSVIEW - Q_D(const QWidget); - if (d->extra && d->extra->proxyWidget && d->extra->proxyWidget->scene()) { - const QList views = d->extra->proxyWidget->scene()->views(); - if (!views.isEmpty()) { - const QPointF scenePos = d->extra->proxyWidget->mapToScene(pos); - const QPoint viewPortPos = views.first()->mapFromScene(scenePos); - return views.first()->viewport()->mapToGlobal(viewPortPos); - } - } -#endif // !QT_NO_GRAPHICSVIEW - int x = pos.x(), y = pos.y(); - const QWidget *w = this; - while (w) { - QWindow *window = w->windowHandle(); - if (window && canMapPosition(window)) - return window->mapToGlobal(QPoint(x, y)); - - x += w->data->crect.x(); - y += w->data->crect.y(); - w = w->isWindow() ? 0 : w->parentWidget(); - } - return QPoint(x, y); + const MapToGlobalTransformResult t = mapToGlobalTransform(this); + const QPoint g = t.transform.map(pos); + return t.window ? t.window->mapToGlobal(g) : g; } /*! @@ -12392,29 +12419,9 @@ QPoint QWidget::mapToGlobal(const QPoint &pos) const */ QPoint QWidget::mapFromGlobal(const QPoint &pos) const { -#ifndef QT_NO_GRAPHICSVIEW - Q_D(const QWidget); - if (d->extra && d->extra->proxyWidget && d->extra->proxyWidget->scene()) { - const QList views = d->extra->proxyWidget->scene()->views(); - if (!views.isEmpty()) { - const QPoint viewPortPos = views.first()->viewport()->mapFromGlobal(pos); - const QPointF scenePos = views.first()->mapToScene(viewPortPos); - return d->extra->proxyWidget->mapFromScene(scenePos).toPoint(); - } - } -#endif // !QT_NO_GRAPHICSVIEW - int x = pos.x(), y = pos.y(); - const QWidget *w = this; - while (w) { - QWindow *window = w->windowHandle(); - if (window && canMapPosition(window)) - return window->mapFromGlobal(QPoint(x, y)); - - x -= w->data->crect.x(); - y -= w->data->crect.y(); - w = w->isWindow() ? 0 : w->parentWidget(); - } - return QPoint(x, y); + const MapToGlobalTransformResult t = mapToGlobalTransform(this); + const QPoint windowLocal = t.window ? t.window->mapFromGlobal(pos) : pos; + return t.transform.inverted().map(windowLocal); } QWidget *qt_pressGrab = 0; diff --git a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp index d8a8ed6b4b..ea2599fcf9 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp @@ -3682,16 +3682,19 @@ static QByteArray msgPointMismatch(const QPoint &actual, const QPoint &expected) void tst_QGraphicsProxyWidget::mapToGlobal() // QTBUG-41135 { const QRect availableGeometry = QGuiApplication::primaryScreen()->availableGeometry(); - const QSize size = availableGeometry.size() / 5; + const QSize size = availableGeometry.size() / 4; QGraphicsScene scene; QGraphicsView view(&scene); + view.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + view.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); view.setTransform(QTransform::fromScale(2, 2)); // QTBUG-50136, use transform. view.setWindowTitle(QTest::currentTestFunction()); view.resize(size); view.move(availableGeometry.bottomRight() - QPoint(size.width(), size.height()) - QPoint(100, 100)); - QWidget *embeddedWidget = new QWidget; - embeddedWidget->setFixedSize(size / 2); - QWidget *childWidget = new QWidget(embeddedWidget); + QWidget *embeddedWidget = new QGroupBox(QLatin1String("Embedded")); + embeddedWidget->setStyleSheet(QLatin1String("background-color: \"yellow\"; ")); + embeddedWidget->setFixedSize((size - QSize(10, 10)) / 2); + QWidget *childWidget = new QGroupBox(QLatin1String("Child"), embeddedWidget); childWidget->setStyleSheet(QLatin1String("background-color: \"red\"; ")); childWidget->resize(embeddedWidget->size() / 2); childWidget->move(embeddedWidget->width() / 4, embeddedWidget->height() / 4); // center in embeddedWidget @@ -3705,18 +3708,16 @@ void tst_QGraphicsProxyWidget::mapToGlobal() // QTBUG-41135 // This should be equivalent to the view center give or take rounding // errors due to odd window margins const QPoint viewCenter = view.geometry().center(); - QVERIFY2((viewCenter - embeddedCenterGlobal).manhattanLength() <= 2, + QVERIFY2((viewCenter - embeddedCenterGlobal).manhattanLength() <= 3, msgPointMismatch(embeddedCenterGlobal, viewCenter).constData()); - // Same test with child centered on embeddedWidget. The correct - // mapping is not implemented yet, but at least make sure + // Same test with child centered on embeddedWidget. Also make sure // the roundtrip maptoGlobal()/mapFromGlobal() returns the same // point since that is important for mouse event handling (QTBUG-50030, // QTBUG-50136). const QPoint childCenter = childWidget->rect().center(); const QPoint childCenterGlobal = childWidget->mapToGlobal(childCenter); QCOMPARE(childWidget->mapFromGlobal(childCenterGlobal), childCenter); - QEXPECT_FAIL("", "Not implemented for child widgets of embedded widgets", Continue); QVERIFY2((viewCenter - childCenterGlobal).manhattanLength() <= 4, msgPointMismatch(childCenterGlobal, viewCenter).constData()); } -- cgit v1.2.3 From 28fab275033a6b4f8d6e78da0f729837144b0420 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Fri, 22 Apr 2016 15:30:26 +0200 Subject: add AA_CompressHighFrequencyEvents to control compression on xcb 7edd10e6c added this compression feature, but some applications may need to disable it. [ChangeLog][X11] It's now possible to unset AA_CompressHighFrequencyEvents to disable the new X event compression feature that was added in 5.6.0. This is a replacement for the WA_NoX11EventCompression flag in Qt 4. Task-number: QTBUG-44964 Change-Id: I37a9c8a4831f1c02eda0f03b54125f3255d25500 Reviewed-by: Gatis Paeglis --- src/corelib/global/qnamespace.h | 1 + src/corelib/global/qnamespace.qdoc | 11 +++++++++++ src/plugins/platforms/xcb/qxcbconnection.cpp | 3 ++- src/plugins/platforms/xcb/qxcbintegration.cpp | 1 + 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index c73ceb9503..2a0b8461cd 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -508,6 +508,7 @@ public: AA_UseStyleSheetPropagationInWidgetStyles = 22, // ### Qt 6: remove me AA_DontUseNativeDialogs = 23, AA_SynthesizeMouseForUnhandledTabletEvents = 24, + AA_CompressHighFrequencyEvents = 25, // Add new attributes before this line AA_AttributeCount diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index 60ce1fc916..3c53a23896 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -239,6 +239,17 @@ to mouse events instead. This attribute is enabled by default. This value has been added in Qt 5.7. + \value AA_CompressHighFrequencyEvents Enables compression of certain frequent events. + On the X11 windowing system, the default value is true, which means that + QEvent::MouseMove, QEvent::TouchUpdate, and changes in window size and + position will be combined whenever they occur more frequently than the + application handles them, so that they don't accumulate and overwhelm the + application later. On other platforms, the default is false. + (In the future, the compression feature may be implemented across platforms.) + You can test the attribute to see whether compression is enabled. + If your application needs to handle all events with no compression, + you can unset this attribute. This value has been added in Qt 5.7. + The following values are obsolete: \value AA_ImmediateWidgetCreation This attribute is no longer fully diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index 87b4c7b91f..4b0e94eda0 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -1713,7 +1713,8 @@ void QXcbConnection::processXcbEvents() continue; } - if (compressEvent(event, i, eventqueue)) + if (Q_LIKELY(QCoreApplication::testAttribute(Qt::AA_CompressHighFrequencyEvents)) && + compressEvent(event, i, eventqueue)) continue; bool accepted = false; diff --git a/src/plugins/platforms/xcb/qxcbintegration.cpp b/src/plugins/platforms/xcb/qxcbintegration.cpp index 703167c0cd..cdbf9b295e 100644 --- a/src/plugins/platforms/xcb/qxcbintegration.cpp +++ b/src/plugins/platforms/xcb/qxcbintegration.cpp @@ -125,6 +125,7 @@ QXcbIntegration::QXcbIntegration(const QStringList ¶meters, int &argc, char , m_defaultVisualId(UINT_MAX) { m_instance = this; + qApp->setAttribute(Qt::AA_CompressHighFrequencyEvents, true); qRegisterMetaType(); #ifdef XCB_USE_XLIB -- cgit v1.2.3 From c5c7997fc22cf914f72179d813ad6a41506e0293 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 10 May 2016 12:00:39 +0200 Subject: eglfs-viv: Fix config test fbGetDisplay() expects a context pointer, but the config test was calling this function without any arguments, causing the test to fail even when the Vivante EGLFS device integration is actually supported. This got broken in 5.7 by the INTEGRITY changes in 9b35b0e8dc6069aed563d0aca61c973eb307d772. Task-number: QTBUG-53282 Change-Id: I233d93618b1c8a31d12b31139d3bfbd3d6429839 Done-with: Carlos Rafael Giani Reviewed-by: Andy Nichols --- config.tests/qpa/eglfs-viv/eglfs-viv.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/config.tests/qpa/eglfs-viv/eglfs-viv.cpp b/config.tests/qpa/eglfs-viv/eglfs-viv.cpp index a41c482b67..96935a2aa0 100644 --- a/config.tests/qpa/eglfs-viv/eglfs-viv.cpp +++ b/config.tests/qpa/eglfs-viv/eglfs-viv.cpp @@ -43,6 +43,8 @@ int main(int, char **) { - fbGetDisplay(); + // Do not rely on fbGetDisplay() since the signature has changed over time. + // Stick to fbGetDisplayByIndex(). + fbGetDisplayByIndex(0); return 0; } -- cgit v1.2.3 From 45eba73492c89157b8c353548a948d538748cd43 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 16 May 2016 14:22:03 +0200 Subject: Fix QVariant conversion to an enum type. QVariant::canConvert was returning true for everything can can be converted to integer, but not for integer itself. That's because in QVariant::canConvert we set the targetType to Int of it's an enum, but the Int->Int case was not on the conversion matrix. So this commits adds it to the conversion matrix and now QVariant::canConvert returns consistently true for int itself. But even tough canConvert returned true, it did not actualy do any conversion to the enum type itself. Fix that by handling the case properlt in 'convert' [ChangeLog][QtCore][QVariant] Fixed QVariant::canConvert and conversion from integer types to enumeration types. Task-number: QTBUG-53384 Change-Id: I6ac066f3900e31bfcea7af77836ddfc7730bd60b Reviewed-by: Thiago Macieira --- src/corelib/kernel/qvariant.cpp | 22 +++++++++++++++++++++- .../auto/corelib/kernel/qvariant/tst_qvariant.cpp | 10 ++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index 9298093f44..7596699843 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -945,6 +945,26 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok) } } #endif + if (QMetaType::typeFlags(t) & QMetaType::IsEnumeration) { + qlonglong value = qConvertToNumber(d, ok); + if (*ok) { + switch (QMetaType::sizeOf(t)) { + case 1: + *static_cast(result) = value; + return true; + case 2: + *static_cast(result) = value; + return true; + case 4: + *static_cast(result) = value; + return true; + case 8: + *static_cast(result) = value; + return true; + } + } + return *ok; + } return false; } return true; @@ -2819,7 +2839,7 @@ static const quint32 qCanConvertMatrix[QVariant::LastCoreType + 1] = /*Int*/ 1 << QVariant::UInt | 1 << QVariant::String | 1 << QVariant::Double | 1 << QVariant::Bool | 1 << QVariant::LongLong | 1 << QVariant::ULongLong - | 1 << QVariant::Char | 1 << QVariant::ByteArray, + | 1 << QVariant::Char | 1 << QVariant::ByteArray | 1 << QVariant::Int, /*UInt*/ 1 << QVariant::Int | 1 << QVariant::String | 1 << QVariant::Double | 1 << QVariant::Bool | 1 << QVariant::LongLong | 1 << QVariant::ULongLong diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp index f2f3baae6b..76230ccec8 100644 --- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp +++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp @@ -4629,6 +4629,16 @@ template void testVariant(Enum value, bool *ok) QVERIFY(var2.convert(QMetaType::Int)); QCOMPARE(var2.value(), static_cast(value)); + if (static_cast(value) <= INT_MAX) { + int intValue = static_cast(value); + QVariant intVar = intValue; + QVERIFY(intVar.canConvert()); + QCOMPARE(intVar.value(), value); + } + qint64 longValue = static_cast(value); + QVERIFY(QVariant(longValue).canConvert()); + QCOMPARE(QVariant(longValue).value(), value); + *ok = true; } -- cgit v1.2.3 From 6e928460bc92d7d67a5b95790225142a65de32fa Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Fri, 13 May 2016 08:53:38 +0200 Subject: Use QPlatformTheme for the context to translate the color dialog buttons QDialogButtonBox does not have translations, it queries QPlatformTheme for button texts. So in order to ensure that the buttons added to QColorDialog natively are translated it should be set to use QPlatformTheme instead. Change-Id: I67d0e509398aa81f9de9b8785544c1e23bb596d9 Reviewed-by: Marc Mutz --- src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm b/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm index 8843e009a2..ed17ef8fe9 100644 --- a/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm +++ b/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm @@ -52,7 +52,7 @@ static NSButton *macCreateButton(const char *text, NSView *superview) [button setButtonType:NSMomentaryLightButton]; [button setBezelStyle:NSRoundedBezelStyle]; [button setTitle:(NSString*)(CFStringRef)QCFString( - qt_mac_removeMnemonics(QCoreApplication::translate("QDialogButtonBox", text)))]; + qt_mac_removeMnemonics(QCoreApplication::translate("QPlatformTheme", text)))]; [[button cell] setFont:[NSFont systemFontOfSize: [NSFont systemFontSizeForControlSize:NSRegularControlSize]]]; [superview addSubview:button]; -- cgit v1.2.3 From 3c19b8b162fa4e61a009c6bc8af72baa1ec8a529 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 28 Apr 2016 09:51:24 +0200 Subject: QOpenGL: use new QJsonObject::value(QLatin1String) Allows to get rid of some QStringLiterals, reducing QtGui text size by ~2Kib. Change-Id: Ic033fad5673aadc85930842dfccc24299df154f7 Reviewed-by: Sean Harmer --- src/gui/opengl/qopengl.cpp | 50 ++++++++++++++++------------------------------ 1 file changed, 17 insertions(+), 33 deletions(-) diff --git a/src/gui/opengl/qopengl.cpp b/src/gui/opengl/qopengl.cpp index a798db662c..1a8fc599ce 100644 --- a/src/gui/opengl/qopengl.cpp +++ b/src/gui/opengl/qopengl.cpp @@ -138,22 +138,6 @@ QDebug operator<<(QDebug d, const QOpenGLConfig::Gpu &g) enum Operator { NotEqual, LessThan, LessEqualThan, Equals, GreaterThan, GreaterEqualThan }; static const char operators[][3] = {"!=", "<", "<=", "=", ">", ">="}; -static inline QString valueKey() { return QStringLiteral("value"); } -static inline QString opKey() { return QStringLiteral("op"); } -static inline QString versionKey() { return QStringLiteral("version"); } -static inline QString releaseKey() { return QStringLiteral("release"); } -static inline QString typeKey() { return QStringLiteral("type"); } -static inline QString osKey() { return QStringLiteral("os"); } -static inline QString vendorIdKey() { return QStringLiteral("vendor_id"); } -static inline QString glVendorKey() { return QStringLiteral("gl_vendor"); } -static inline QString deviceIdKey() { return QStringLiteral("device_id"); } -static inline QString driverVersionKey() { return QStringLiteral("driver_version"); } -static inline QString driverDescriptionKey() { return QStringLiteral("driver_description"); } -static inline QString featuresKey() { return QStringLiteral("features"); } -static inline QString idKey() { return QStringLiteral("id"); } -static inline QString descriptionKey() { return QStringLiteral("description"); } -static inline QString exceptionsKey() { return QStringLiteral("exceptions"); } - typedef QJsonArray::ConstIterator JsonArrayConstIt; static inline bool contains(const QJsonArray &haystack, unsigned needle) @@ -216,8 +200,8 @@ VersionTerm VersionTerm::fromJson(const QJsonValue &v) if (!v.isObject()) return result; const QJsonObject o = v.toObject(); - result.number = QVersionNumber::fromString(o.value(valueKey()).toString()); - const QString opS = o.value(opKey()).toString(); + result.number = QVersionNumber::fromString(o.value(QLatin1String("value")).toString()); + const QString opS = o.value(QLatin1String("op")).toString(); for (size_t i = 0; i < sizeof(operators) / sizeof(operators[0]); ++i) { if (opS == QLatin1String(operators[i])) { result.op = static_cast(i); @@ -292,9 +276,9 @@ OsTypeTerm OsTypeTerm::fromJson(const QJsonValue &v) if (!v.isObject()) return result; const QJsonObject o = v.toObject(); - result.type = o.value(typeKey()).toString(); - result.versionTerm = VersionTerm::fromJson(o.value(versionKey())); - result.release = o.value(releaseKey()).toArray(); + result.type = o.value(QLatin1String("type")).toString(); + result.versionTerm = VersionTerm::fromJson(o.value(QLatin1String("version"))); + result.release = o.value(QLatin1String("release")).toArray(); return result; } @@ -318,8 +302,8 @@ QString OsTypeTerm::hostOs() static QString msgSyntaxWarning(const QJsonObject &object, const QString &what) { QString result; - QTextStream(&result) << "Id " << object.value(idKey()).toInt() - << " (\"" << object.value(descriptionKey()).toString() + QTextStream(&result) << "Id " << object.value(QLatin1String("id")).toInt() + << " (\"" << object.value(QLatin1String("description")).toString() << "\"): " << what; return result; } @@ -333,11 +317,11 @@ static bool matches(const QJsonObject &object, const QString &osRelease, const QOpenGLConfig::Gpu &gpu) { - const OsTypeTerm os = OsTypeTerm::fromJson(object.value(osKey())); + const OsTypeTerm os = OsTypeTerm::fromJson(object.value(QLatin1String("os"))); if (!os.isNull() && !os.matches(osName, kernelVersion, osRelease)) return false; - const QJsonValue exceptionsV = object.value(exceptionsKey()); + const QJsonValue exceptionsV = object.value(QLatin1String("exceptions")); if (exceptionsV.isArray()) { const QJsonArray exceptionsA = exceptionsV.toArray(); for (JsonArrayConstIt it = exceptionsA.constBegin(), cend = exceptionsA.constEnd(); it != cend; ++it) { @@ -346,20 +330,20 @@ static bool matches(const QJsonObject &object, } } - const QJsonValue vendorV = object.value(vendorIdKey()); + const QJsonValue vendorV = object.value(QLatin1String("vendor_id")); if (vendorV.isString()) { if (gpu.vendorId != vendorV.toString().toUInt(Q_NULLPTR, /* base */ 0)) return false; } else { - if (object.contains(glVendorKey())) { - const QByteArray glVendorV = object.value(glVendorKey()).toString().toUtf8(); + if (object.contains(QLatin1String("gl_vendor"))) { + const QByteArray glVendorV = object.value(QLatin1String("gl_vendor")).toString().toUtf8(); if (!gpu.glVendor.contains(glVendorV)) return false; } } if (gpu.deviceId) { - const QJsonValue deviceIdV = object.value(deviceIdKey()); + const QJsonValue deviceIdV = object.value(QLatin1String("device_id")); switch (deviceIdV.type()) { case QJsonValue::Array: if (!contains(deviceIdV.toArray(), gpu.deviceId)) @@ -375,7 +359,7 @@ static bool matches(const QJsonObject &object, } } if (!gpu.driverVersion.isNull()) { - const QJsonValue driverVersionV = object.value(driverVersionKey()); + const QJsonValue driverVersionV = object.value(QLatin1String("driver_version")); switch (driverVersionV.type()) { case QJsonValue::Object: if (!VersionTerm::fromJson(driverVersionV).matches(gpu.driverVersion)) @@ -392,7 +376,7 @@ static bool matches(const QJsonObject &object, } if (!gpu.driverDescription.isEmpty()) { - const QJsonValue driverDescriptionV = object.value(driverDescriptionKey()); + const QJsonValue driverDescriptionV = object.value(QLatin1String("driver_description")); if (driverDescriptionV.isString()) { if (!gpu.driverDescription.contains(driverDescriptionV.toString().toUtf8())) return false; @@ -412,7 +396,7 @@ static bool readGpuFeatures(const QOpenGLConfig::Gpu &gpu, { result->clear(); errorMessage->clear(); - const QJsonValue entriesV = doc.object().value(QStringLiteral("entries")); + const QJsonValue entriesV = doc.object().value(QLatin1String("entries")); if (!entriesV.isArray()) { *errorMessage = QLatin1String("No entries read."); return false; @@ -423,7 +407,7 @@ static bool readGpuFeatures(const QOpenGLConfig::Gpu &gpu, if (eit->isObject()) { const QJsonObject object = eit->toObject(); if (matches(object, osName, kernelVersion, osRelease, gpu)) { - const QJsonValue featuresListV = object.value(featuresKey()); + const QJsonValue featuresListV = object.value(QLatin1String("features")); if (featuresListV.isArray()) { const QJsonArray featuresListA = featuresListV.toArray(); for (JsonArrayConstIt fit = featuresListA.constBegin(), fcend = featuresListA.constEnd(); fit != fcend; ++fit) -- cgit v1.2.3 From 8714c99f65381af194cc4991c4258fec4b9a6307 Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Fri, 13 May 2016 08:40:39 +0200 Subject: winrt: Fix potential crash when reading closed sockets Using multiple concurrent requests can cause a delay between a socket closing and getting deleted. At that point the state was closingDown, but not wasDeleted yet. Especially on slower arm devices, callbacks are done from another thread causing synchronization issues. Hence closingDown needs to be synced and handleReadyRead needs to have more criterias to return early to avoid invalid access crashes. Easiest to reproduce is heavy scrolling on the mapviewer example when it downloads a huge amount of tiles and cancels those requests when not in view anymore. Change-Id: I442b6243bbefb3af938b6b1b3739a6a85b4887c0 Reviewed-by: Friedemann Kleint Reviewed-by: Oliver Wolff --- src/network/socket/qnativesocketengine_winrt.cpp | 30 +++++++++++++++--------- src/network/socket/qnativesocketengine_winrt_p.h | 2 +- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/network/socket/qnativesocketengine_winrt.cpp b/src/network/socket/qnativesocketengine_winrt.cpp index 599f37929c..d79dffa215 100644 --- a/src/network/socket/qnativesocketengine_winrt.cpp +++ b/src/network/socket/qnativesocketengine_winrt.cpp @@ -458,16 +458,21 @@ void QNativeSocketEngine::close() } #if _MSC_VER >= 1900 - // To close the connection properly (not with a hard reset) all pending read operation have to - // be finished or cancelled. The API isn't available on Windows 8.1 though. - ComPtr socket3; - hr = d->tcpSocket()->QueryInterface(IID_PPV_ARGS(&socket3)); - Q_ASSERT_SUCCEEDED(hr); + hr = QEventDispatcherWinRT::runOnXamlThread([d]() { + HRESULT hr; + // To close the connection properly (not with a hard reset) all pending read operation have to + // be finished or cancelled. The API isn't available on Windows 8.1 though. + ComPtr socket3; + hr = d->tcpSocket()->QueryInterface(IID_PPV_ARGS(&socket3)); + Q_ASSERT_SUCCEEDED(hr); - ComPtr action; - hr = socket3->CancelIOAsync(&action); - Q_ASSERT_SUCCEEDED(hr); - hr = QWinRTFunctions::await(action); + ComPtr action; + hr = socket3->CancelIOAsync(&action); + Q_ASSERT_SUCCEEDED(hr); + hr = QWinRTFunctions::await(action); + Q_ASSERT_SUCCEEDED(hr); + return S_OK; + }); Q_ASSERT_SUCCEEDED(hr); #endif // _MSC_VER >= 1900 @@ -1261,9 +1266,12 @@ void QNativeSocketEnginePrivate::handleConnectionEstablished(IAsyncAction *actio HRESULT QNativeSocketEnginePrivate::handleReadyRead(IAsyncBufferOperation *asyncInfo, AsyncStatus status) { - Q_Q(QNativeSocketEngine); - if (wasDeleted || isDeletingChildren) + if (closingDown || wasDeleted || isDeletingChildren + || socketState == QAbstractSocket::UnconnectedState) { return S_OK; + } + + Q_Q(QNativeSocketEngine); // A read in UnconnectedState will close the socket and return -1 and thus tell the caller, // that the connection was closed. The socket cannot be closed here, as the subsequent read diff --git a/src/network/socket/qnativesocketengine_winrt_p.h b/src/network/socket/qnativesocketengine_winrt_p.h index 4a5bc81769..2c1c42ecbc 100644 --- a/src/network/socket/qnativesocketengine_winrt_p.h +++ b/src/network/socket/qnativesocketengine_winrt_p.h @@ -148,7 +148,7 @@ public: qintptr socketDescriptor; bool notifyOnRead, notifyOnWrite, notifyOnException; - bool closingDown; + QAtomicInt closingDown; enum ErrorString { NonBlockingInitFailedErrorString, -- cgit v1.2.3 From 1675d9a1b23794592a55746dfebd6f40478fde03 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Wed, 6 Apr 2016 16:19:06 +0200 Subject: QLocalSocket/Win: use QRingBuffer::append Use QRingBuffer::append instead of an explicit reserve + memcpy. Change-Id: I237d1e43a377e156c148e89e410e15e400e1e426 Reviewed-by: Alex Trotsenko Reviewed-by: Oswald Buddenhagen --- src/network/socket/qlocalsocket_win.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/network/socket/qlocalsocket_win.cpp b/src/network/socket/qlocalsocket_win.cpp index 66b461522b..ca3b4e0d04 100644 --- a/src/network/socket/qlocalsocket_win.cpp +++ b/src/network/socket/qlocalsocket_win.cpp @@ -214,8 +214,7 @@ qint64 QLocalSocket::writeData(const char *data, qint64 len) Q_D(QLocalSocket); if (len == 0) return 0; - char *dest = d->writeBuffer.reserve(len); - memcpy(dest, data, len); + d->writeBuffer.append(data, len); if (!d->pipeWriter) { d->pipeWriter = new QWindowsPipeWriter(d->handle, this); connect(d->pipeWriter, &QWindowsPipeWriter::bytesWritten, -- cgit v1.2.3 From 082ee835b0e09f77e0e1bd061323a1b70178d202 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Wed, 6 Apr 2016 16:38:54 +0200 Subject: QLocalSocket/Win: Use QIODevice's internal write buffer Remove the extra write buffer from QLocalSocketPrivate and use QIODevice's new internal write buffer. Change-Id: I4297774ee89da2df59782adae8b804296e7f3301 Reviewed-by: Alex Trotsenko Reviewed-by: Oswald Buddenhagen --- src/network/socket/qlocalsocket_p.h | 2 -- src/network/socket/qlocalsocket_win.cpp | 3 ++- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/network/socket/qlocalsocket_p.h b/src/network/socket/qlocalsocket_p.h index cf36887e92..56f8b590f1 100644 --- a/src/network/socket/qlocalsocket_p.h +++ b/src/network/socket/qlocalsocket_p.h @@ -61,7 +61,6 @@ #if defined(QT_LOCALSOCKET_TCP) # include "qtcpsocket.h" #elif defined(Q_OS_WIN) -# include # include "private/qwindowspipereader_p.h" # include "private/qwindowspipewriter_p.h" # include @@ -134,7 +133,6 @@ public: void _q_pipeClosed(); void _q_winError(ulong windowsError, const QString &function); HANDLE handle; - QRingBuffer writeBuffer; QWindowsPipeWriter *pipeWriter; QWindowsPipeReader *pipeReader; QLocalSocket::LocalSocketError error; diff --git a/src/network/socket/qlocalsocket_win.cpp b/src/network/socket/qlocalsocket_win.cpp index ca3b4e0d04..bed4355aa9 100644 --- a/src/network/socket/qlocalsocket_win.cpp +++ b/src/network/socket/qlocalsocket_win.cpp @@ -107,6 +107,7 @@ QLocalSocketPrivate::QLocalSocketPrivate() : QIODevicePrivate(), error(QLocalSocket::UnknownSocketError), state(QLocalSocket::UnconnectedState) { + writeBufferChunkSize = QIODEVICE_BUFFERSIZE; } QLocalSocketPrivate::~QLocalSocketPrivate() @@ -232,7 +233,6 @@ void QLocalSocket::abort() if (d->pipeWriter) { delete d->pipeWriter; d->pipeWriter = 0; - d->writeBuffer.clear(); } close(); } @@ -290,6 +290,7 @@ void QLocalSocket::close() if (openMode() == NotOpen) return; + d->setWriteChannelCount(0); QIODevice::close(); d->serverName = QString(); d->fullServerName = QString(); -- cgit v1.2.3 From 74910e2192ff78941f7010b1c8f165c3013ff116 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Tue, 17 May 2016 14:07:06 +0200 Subject: Fix running of configure tests when cross compiling on Windows When compiling on Windows to for example Android, we may be using the unix generator, but the make command may be mingw32-make. Task-number: QTBUG-53038 Change-Id: If8d1e1bea733cf1b4ed837c423a34ecfb3cafd1f Reviewed-by: Oswald Buddenhagen --- mkspecs/features/configure.prf | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/mkspecs/features/configure.prf b/mkspecs/features/configure.prf index 6b37a04450..2cb2981758 100644 --- a/mkspecs/features/configure.prf +++ b/mkspecs/features/configure.prf @@ -1,9 +1,7 @@ QMAKE_MAKE = $$(MAKE) !isEmpty(QMAKE_MAKE) { # We were called recursively. Use the right make, as MAKEFLAGS may be set as well. -} else:equals(MAKEFILE_GENERATOR, UNIX) { - QMAKE_MAKE = make -} else:equals(MAKEFILE_GENERATOR, MINGW) { +} else:if(equals(MAKEFILE_GENERATOR, UNIX)|equals(MAKEFILE_GENERATOR, MINGW)) { !equals(QMAKE_HOST.os, Windows): \ QMAKE_MAKE = make else: \ -- cgit v1.2.3 From 72492735b7b7770808fcc9fe067e8f03fab827fc Mon Sep 17 00:00:00 2001 From: Ralf Nolden Date: Tue, 17 May 2016 12:57:17 +0200 Subject: Remove libudev dependency from kms.pro To compile the kms qpa plugin, only libdrm is needed. Remove the libudev dependency for the compile check to enable building of the qpa plugin on platforms where libudev is not present such as BSD systems (but where KMS works) Change-Id: Icd0be70a8949578a6158d523428706890a9674eb Reviewed-by: Laszlo Agocs Reviewed-by: Oswald Buddenhagen --- config.tests/qpa/kms/kms.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.tests/qpa/kms/kms.pro b/config.tests/qpa/kms/kms.pro index 1fb73677e7..5147bc82da 100644 --- a/config.tests/qpa/kms/kms.pro +++ b/config.tests/qpa/kms/kms.pro @@ -1,4 +1,4 @@ SOURCES = kms.cpp CONFIG += link_pkgconfig -PKGCONFIG += libdrm libudev +PKGCONFIG += libdrm CONFIG -= qt -- cgit v1.2.3 From b67a0836d970d47498ef7eb1d59841b661cfae78 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 11 May 2016 17:53:58 +0200 Subject: QT_CONFIG simplification re debug_and_release and build_all don't pretend that these two flags can be set separately - the configures set them in tandem. Change-Id: Ib0beae0152de09026d4627fd3ae0feabd9ce1b81 Reviewed-by: Joerg Bornemann --- mkspecs/features/qml_plugin.prf | 3 +-- mkspecs/features/qt_app.prf | 2 +- mkspecs/features/qt_helper_lib.prf | 3 +-- mkspecs/features/qt_module.prf | 5 ++--- mkspecs/features/qt_plugin.prf | 5 ++--- src/winmain/winmain.pro | 2 +- 6 files changed, 8 insertions(+), 12 deletions(-) diff --git a/mkspecs/features/qml_plugin.prf b/mkspecs/features/qml_plugin.prf index 20b8eb4d53..158bddf60c 100644 --- a/mkspecs/features/qml_plugin.prf +++ b/mkspecs/features/qml_plugin.prf @@ -15,8 +15,7 @@ TEMPLATE = lib CONFIG += plugin if(win32|mac):!macx-xcode { - contains(QT_CONFIG, debug_and_release):CONFIG += debug_and_release - contains(QT_CONFIG, build_all):CONFIG += build_all + contains(QT_CONFIG, debug_and_release): CONFIG += debug_and_release build_all } CONFIG += relative_qt_rpath # Qt's QML plugins should be relocatable diff --git a/mkspecs/features/qt_app.prf b/mkspecs/features/qt_app.prf index 823a4c9490..46aca50cc2 100644 --- a/mkspecs/features/qt_app.prf +++ b/mkspecs/features/qt_app.prf @@ -28,7 +28,7 @@ host_build:force_bootstrap { } target.path = $$[QT_HOST_BINS] } else { - !build_pass:contains(QT_CONFIG, debug_and_release):contains(QT_CONFIG, build_all): CONFIG += release + !build_pass:contains(QT_CONFIG, debug_and_release): CONFIG += release target.path = $$[QT_INSTALL_BINS] CONFIG += relative_qt_rpath # Qt's tools and apps should be relocatable } diff --git a/mkspecs/features/qt_helper_lib.prf b/mkspecs/features/qt_helper_lib.prf index ebc629f57f..513faa2291 100644 --- a/mkspecs/features/qt_helper_lib.prf +++ b/mkspecs/features/qt_helper_lib.prf @@ -17,8 +17,7 @@ CONFIG -= qt CONFIG -= warning_clean # Don't presume 3rd party code to be clean load(qt_common) -contains(QT_CONFIG, debug_and_release): CONFIG += debug_and_release -contains(QT_CONFIG, build_all): CONFIG += build_all +contains(QT_CONFIG, debug_and_release): CONFIG += debug_and_release build_all DESTDIR = $$MODULE_BASE_OUTDIR/lib DLLDESTDIR = $$MODULE_BASE_OUTDIR/bin diff --git a/mkspecs/features/qt_module.prf b/mkspecs/features/qt_module.prf index aefd3aee1c..5bd5101cdc 100644 --- a/mkspecs/features/qt_module.prf +++ b/mkspecs/features/qt_module.prf @@ -38,7 +38,7 @@ host_build { QT += bootstrap-private } } else { - !build_pass:contains(QT_CONFIG, build_all): CONFIG += release + !build_pass:contains(QT_CONFIG, debug_and_release): CONFIG += release } } @@ -89,8 +89,7 @@ INCLUDEPATH *= $$eval(QT.$${MODULE}.includes) $$eval(QT.$${MODULE}_private.inclu # If Qt was configured with -debug-and-release then build the module the same way # - unless this is a host library !host_build:if(win32|mac):!macx-xcode { - contains(QT_CONFIG, debug_and_release):CONFIG += debug_and_release - contains(QT_CONFIG, build_all):CONFIG += build_all + contains(QT_CONFIG, debug_and_release): CONFIG += debug_and_release build_all } QMAKE_LFLAGS += $$QMAKE_LFLAGS_NOUNDEF diff --git a/mkspecs/features/qt_plugin.prf b/mkspecs/features/qt_plugin.prf index 220f11bd75..176159eff1 100644 --- a/mkspecs/features/qt_plugin.prf +++ b/mkspecs/features/qt_plugin.prf @@ -24,10 +24,9 @@ win32:CONFIG(shared, static|shared) { } tool_plugin { - !build_pass:contains(QT_CONFIG, build_all): CONFIG += release + !build_pass:contains(QT_CONFIG, debug_and_release): CONFIG += release } else:if(win32|mac):!macx-xcode { - contains(QT_CONFIG, debug_and_release):CONFIG += debug_and_release - contains(QT_CONFIG, build_all):CONFIG += build_all + contains(QT_CONFIG, debug_and_release): CONFIG += debug_and_release build_all } CONFIG += relative_qt_rpath # Qt's plugins should be relocatable diff --git a/src/winmain/winmain.pro b/src/winmain/winmain.pro index e8c9ace03b..52728a9149 100644 --- a/src/winmain/winmain.pro +++ b/src/winmain/winmain.pro @@ -8,7 +8,7 @@ DESTDIR = $$QT.core.libs CONFIG += static QT = core -contains(QT_CONFIG, build_all):CONFIG += build_all +contains(QT_CONFIG, debug_and_release): CONFIG += build_all win32-msvc*:QMAKE_CFLAGS_DEBUG -= -Zi win32-msvc*:QMAKE_CXXFLAGS_DEBUG -= -Zi -- cgit v1.2.3 From bfa53e1c67eddb14887cda37d7c89c76f4cce378 Mon Sep 17 00:00:00 2001 From: Ralf Nolden Date: Tue, 10 May 2016 16:34:37 +0200 Subject: Compile fix: remove _POSIX_C_SOURCE usage Remove _POSIX_C_SOURCE usage as the reason why it was added is not clear anymore and it causes compile errors on BSD systems if not circumvented by adding further defines to re-enable function calls hidden by the _POSIX_C_SOURCE define. (__BSD_VISIBLE on FreeBSD/OpenBSD and _NETBSD_SOURCE on NetBSD) Change-Id: Ic6b49ddcd6c481b0f2acd598cea5470604e00507 Reviewed-by: Thiago Macieira --- src/corelib/tools/qelapsedtimer_unix.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/corelib/tools/qelapsedtimer_unix.cpp b/src/corelib/tools/qelapsedtimer_unix.cpp index c3c930b82e..27f07d094c 100644 --- a/src/corelib/tools/qelapsedtimer_unix.cpp +++ b/src/corelib/tools/qelapsedtimer_unix.cpp @@ -31,9 +31,6 @@ ** ****************************************************************************/ -// ask for the latest POSIX, just in case -#define _POSIX_C_SOURCE 200809L - #include "qelapsedtimer.h" #if defined(Q_OS_VXWORKS) #include "qfunctions_vxworks.h" -- cgit v1.2.3 From 6e401ebc4760e696443f8afa13e1cf2f08629e73 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Fri, 22 Apr 2016 17:13:38 +0200 Subject: egl: Reshuffle headers to help less fortunate systems with X11 EGL headers including X headers has traditionally been problematic due to getting macros for Status, None, etc. In most cases this is not an issue anymore because on embedded one will almost always use a driver targeting the framebuffer or DRM/KMS and therefore the EGL headers do not pull in X dependencies. Furthermore, Mesa supports MESA_EGL_NO_X11_HEADERS which we set, avoiding the problem altogether with Mesa regardless of targeting X11 or KMS. However, other drivers do not have this option. On i.MX6 for instance, targeting X11 is problematic due to not having EGL_API_FB defined, which in turn means the EGL headers pulls in X headers in order to be able to define the native display and window types as Display and Window. Try to play nice with this use case by reshuffling the includes and undefining the problematic names. This restores patch set 2 from the previously merged, and then reverted commit. This here is safe since the egl.h include and the following undefs are only done internally for eglfs and can have therefore no effect on other code. Task-number: QTBUG-52928 Change-Id: I383e783d5064dc8fb41f3ef56d2a4f4fcd31a6cf Reviewed-by: Louai Al-Khanji --- src/platformsupport/eglconvenience/qeglpbuffer_p.h | 2 +- src/plugins/platforms/eglfs/qeglfscontext.cpp | 1 + src/plugins/platforms/eglfs/qeglfscontext.h | 2 +- src/plugins/platforms/eglfs/qeglfsdeviceintegration.h | 3 +-- src/plugins/platforms/eglfs/qeglfsglobal.h | 13 +++++++++++++ src/plugins/platforms/eglfs/qeglfshooks.h | 2 +- src/plugins/platforms/eglfs/qeglfsintegration.cpp | 2 -- src/plugins/platforms/eglfs/qeglfsintegration.h | 3 +-- src/plugins/platforms/eglfs/qeglfsoffscreenwindow.h | 3 +-- src/plugins/platforms/eglfs/qeglfsscreen.h | 1 - src/plugins/platforms/eglfs/qeglfswindow.h | 3 +-- 11 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/platformsupport/eglconvenience/qeglpbuffer_p.h b/src/platformsupport/eglconvenience/qeglpbuffer_p.h index 81fdab8901..aa79a0a42c 100644 --- a/src/platformsupport/eglconvenience/qeglpbuffer_p.h +++ b/src/platformsupport/eglconvenience/qeglpbuffer_p.h @@ -45,9 +45,9 @@ // We mean it. // -#include #include #include +#include QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/eglfs/qeglfscontext.cpp b/src/plugins/platforms/eglfs/qeglfscontext.cpp index db35338423..bb638091f7 100644 --- a/src/plugins/platforms/eglfs/qeglfscontext.cpp +++ b/src/plugins/platforms/eglfs/qeglfscontext.cpp @@ -31,6 +31,7 @@ ** ****************************************************************************/ +#include "qeglfsglobal.h" #include #include #include diff --git a/src/plugins/platforms/eglfs/qeglfscontext.h b/src/plugins/platforms/eglfs/qeglfscontext.h index 906d11b3d1..8da4c731b8 100644 --- a/src/plugins/platforms/eglfs/qeglfscontext.h +++ b/src/plugins/platforms/eglfs/qeglfscontext.h @@ -34,9 +34,9 @@ #ifndef QEGLFSCONTEXT_H #define QEGLFSCONTEXT_H +#include "qeglfsglobal.h" #include #include -#include "qeglfsglobal.h" QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/eglfs/qeglfsdeviceintegration.h b/src/plugins/platforms/eglfs/qeglfsdeviceintegration.h index 5ec98b37d1..303810eb6e 100644 --- a/src/plugins/platforms/eglfs/qeglfsdeviceintegration.h +++ b/src/plugins/platforms/eglfs/qeglfsdeviceintegration.h @@ -45,13 +45,12 @@ // We mean it. // +#include "qeglfsglobal.h" #include #include #include #include #include -#include -#include "qeglfsglobal.h" QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/eglfs/qeglfsglobal.h b/src/plugins/platforms/eglfs/qeglfsglobal.h index 9109f6be38..e5804aea37 100644 --- a/src/plugins/platforms/eglfs/qeglfsglobal.h +++ b/src/plugins/platforms/eglfs/qeglfsglobal.h @@ -42,4 +42,17 @@ #define Q_EGLFS_EXPORT Q_DECL_IMPORT #endif +#include +#undef Status +#undef None +#undef Bool +#undef CursorShape +#undef KeyPress +#undef KeyRelease +#undef FocusIn +#undef FocusOut +#undef FontChange +#undef Expose +#undef Unsorted + #endif diff --git a/src/plugins/platforms/eglfs/qeglfshooks.h b/src/plugins/platforms/eglfs/qeglfshooks.h index 3e4143918e..5f19d492f8 100644 --- a/src/plugins/platforms/eglfs/qeglfshooks.h +++ b/src/plugins/platforms/eglfs/qeglfshooks.h @@ -34,8 +34,8 @@ #ifndef QEGLFSHOOKS_H #define QEGLFSHOOKS_H -#include "qeglfsdeviceintegration.h" #include "qeglfsglobal.h" +#include "qeglfsdeviceintegration.h" QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/eglfs/qeglfsintegration.cpp b/src/plugins/platforms/eglfs/qeglfsintegration.cpp index 35b27cba0b..c226c0134a 100644 --- a/src/plugins/platforms/eglfs/qeglfsintegration.cpp +++ b/src/plugins/platforms/eglfs/qeglfsintegration.cpp @@ -79,8 +79,6 @@ #include -#include - static void initResources() { #ifndef QT_NO_CURSOR diff --git a/src/plugins/platforms/eglfs/qeglfsintegration.h b/src/plugins/platforms/eglfs/qeglfsintegration.h index 98c7ee9f78..2edb287b1e 100644 --- a/src/plugins/platforms/eglfs/qeglfsintegration.h +++ b/src/plugins/platforms/eglfs/qeglfsintegration.h @@ -34,12 +34,11 @@ #ifndef QEGLFSINTEGRATION_H #define QEGLFSINTEGRATION_H +#include "qeglfsglobal.h" #include #include #include #include -#include -#include "qeglfsglobal.h" QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/eglfs/qeglfsoffscreenwindow.h b/src/plugins/platforms/eglfs/qeglfsoffscreenwindow.h index 9b8eaacd51..f20055b4e7 100644 --- a/src/plugins/platforms/eglfs/qeglfsoffscreenwindow.h +++ b/src/plugins/platforms/eglfs/qeglfsoffscreenwindow.h @@ -34,9 +34,8 @@ #ifndef QEGLFSOFFSCREENWINDOW_H #define QEGLFSOFFSCREENWINDOW_H -#include -#include #include "qeglfsglobal.h" +#include QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/eglfs/qeglfsscreen.h b/src/plugins/platforms/eglfs/qeglfsscreen.h index 8f1d87ea25..ea669bd5bc 100644 --- a/src/plugins/platforms/eglfs/qeglfsscreen.h +++ b/src/plugins/platforms/eglfs/qeglfsscreen.h @@ -36,7 +36,6 @@ #include "qeglfsglobal.h" #include -#include QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/eglfs/qeglfswindow.h b/src/plugins/platforms/eglfs/qeglfswindow.h index 806b21de0a..2c396e8ef4 100644 --- a/src/plugins/platforms/eglfs/qeglfswindow.h +++ b/src/plugins/platforms/eglfs/qeglfswindow.h @@ -34,13 +34,12 @@ #ifndef QEGLFSWINDOW_H #define QEGLFSWINDOW_H +#include "qeglfsglobal.h" #include "qeglfsintegration.h" #include "qeglfsscreen.h" -#include "qeglfsglobal.h" #include #include -#include QT_BEGIN_NAMESPACE -- cgit v1.2.3 From 4251509c2d7af3ae691350b4bae7fcbd7773d8c6 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 10 May 2016 10:52:30 +0200 Subject: Add notes and an example configure line to the imx6 makespec Other popular specs have this as well. Change-Id: I44245f37857d476b9ee53ecad021261b94214b2f Reviewed-by: Johan Helsing Reviewed-by: Louai Al-Khanji --- mkspecs/devices/linux-imx6-g++/qmake.conf | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/mkspecs/devices/linux-imx6-g++/qmake.conf b/mkspecs/devices/linux-imx6-g++/qmake.conf index 71e37845c3..46d631796d 100644 --- a/mkspecs/devices/linux-imx6-g++/qmake.conf +++ b/mkspecs/devices/linux-imx6-g++/qmake.conf @@ -1,6 +1,23 @@ # # qmake configuration for the Freescale iMX6 boards (single, dual and quad) # +# The configuration below is set up for running with EGL on the framebuffer via +# the eglfs platform plugin and its eglfs_viv backend. + +# Wayland is also fully functional out of the box. However, when writing Wayland +# *compositors* with Qt, the eglfs backend will have to be switched to +# eglfs_viv_wl by setting the QT_QPA_EGLFS_INTEGRATION environment variable. +# +# Below is an example configure line that assumes the SDK is in +# $HOME/imx6/toolchain. On device Qt is expected to be placed under +# /usr/local/qt5 whereas on the host 'make install' will copy the host tools and +# the target libraries to $HOME/imx6/qt5. +# +# ./configure -prefix /usr/local/qt5 -extprefix $HOME/imx6/qt5 -device linux-imx6-g++ \ +# -device-option CROSS_COMPILE=$HOME/imx6/toolchain/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi- \ +# -sysroot $HOME/imx6/toolchain/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi \ +# -nomake examples -nomake tests -v +# include(../common/linux_device_pre.conf) -- cgit v1.2.3 From e6cc1d788dddda2998a9f941664ede928ce1e212 Mon Sep 17 00:00:00 2001 From: Nico Vertriest Date: Tue, 10 May 2016 11:54:08 +0200 Subject: Doc: corrected issues with non-existing image files Changed gtk- into fusion- in image file names Change-Id: I8d7beeda1f705aa4bb8ce53fd7189c2fca56fa62 Reviewed-by: Venugopal Shivashankar --- src/widgets/doc/src/widgets-and-layouts/widgets.qdoc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/widgets/doc/src/widgets-and-layouts/widgets.qdoc b/src/widgets/doc/src/widgets-and-layouts/widgets.qdoc index abd6ddd5fb..1e99030e7a 100644 --- a/src/widgets/doc/src/widgets-and-layouts/widgets.qdoc +++ b/src/widgets/doc/src/widgets-and-layouts/widgets.qdoc @@ -43,11 +43,11 @@ \table \row - \li \image gtk-label.png + \li \image fusion-label.png \li \image windowsvista-pushbutton.png \li \image macintosh-progressbar.png \row - \li \image gtk-combobox.png + \li \image fusion-combobox.png \li \image windowsvista-radiobutton.png \li \image macintosh-lineedit.png \endtable @@ -69,7 +69,7 @@ \table \row \li \image windowsxp-treeview.png - \li \image gtk-calendarwidget.png + \li \image fusion-calendarwidget.png \li \image qundoview.png \endtable -- cgit v1.2.3 From 5b5b7f97b833e9f91c41285718dc7b566cc37247 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 20 Apr 2016 21:11:03 +0200 Subject: complain about examples which don't install themselves properly Change-Id: I6555d449430111639b084ddc3e4b4bc14b61bc30 Reviewed-by: Joerg Bornemann --- mkspecs/features/qt_example_installs.prf | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/mkspecs/features/qt_example_installs.prf b/mkspecs/features/qt_example_installs.prf index ebf68a8a21..4c68cfd72f 100644 --- a/mkspecs/features/qt_example_installs.prf +++ b/mkspecs/features/qt_example_installs.prf @@ -100,6 +100,20 @@ probase = $$relative_path($$_PRO_FILE_PWD_, $$dirname(_QMAKE_CONF_)/examples) !isEmpty(allfiles): warning("remaining files in $$_PRO_FILE_PWD_: $$allfiles") } + equals(TEMPLATE, app)|equals(TEMPLATE, lib) { + !contains(INSTALLS, target) { + !install_ok: \ + error("$$_PRO_FILE_ is lacking an install target.") + else: check_examples: \ + warning("$$_PRO_FILE_ is lacking an install target.") + } else: !equals(target.path, $$sources.path) { + !install_ok: \ + error("$$_PRO_FILE_ installs target to unexpected location.") + else: check_examples: \ + warning("$$_PRO_FILE_ installs target to unexpected location.") + } + } + !equals(TEMPLATE, subdirs):!compile_examples { TEMPLATE = aux CONFIG -= have_target qt staticlib dll -- cgit v1.2.3 From 5cbea54986e7090a37d563fc189c97367694ee95 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 20 Apr 2016 21:11:45 +0200 Subject: enable example installs for all modules so far, each module had to do it in its .qmake.conf. by now, all modules have been adjusted to the expected structure, so we can enable it centrally. Change-Id: I16b4e7581e51bfc54e71d2f7f852858ae0b47281 Reviewed-by: Joerg Bornemann --- .qmake.conf | 1 - mkspecs/features/qt_build_config.prf | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/.qmake.conf b/.qmake.conf index 53993bd4fe..50d27cf9ce 100644 --- a/.qmake.conf +++ b/.qmake.conf @@ -1,5 +1,4 @@ load(qt_build_config) -CONFIG += qt_example_installs CONFIG += warning_clean QT_SOURCE_TREE = $$PWD diff --git a/mkspecs/features/qt_build_config.prf b/mkspecs/features/qt_build_config.prf index 2d437e7f91..1e2d5c2423 100644 --- a/mkspecs/features/qt_build_config.prf +++ b/mkspecs/features/qt_build_config.prf @@ -71,6 +71,7 @@ CONFIG += \ create_prl link_prl \ prepare_docs qt_docs_targets \ no_private_qt_headers_warning QTDIR_build \ + qt_example_installs \ # Qt modules get compiled without exceptions enabled by default. # However, testcases should be still built with exceptions. exceptions_off testcase_exceptions -- cgit v1.2.3 From eba979f6956f8d74bf5a3cb6ed0d585396b790f1 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Wed, 18 May 2016 09:59:25 +0200 Subject: WinRT: Do not try to cancel IO for udp sockets on socket close As the functionality is not available for udp sockets trying to call it will cause a crash on socket close. Task-number: QTBUG-53424 Change-Id: Id80b36a248d12bf360135b2374c0a0efdab3a1f0 Reviewed-by: Maurice Kalinowski --- src/network/socket/qnativesocketengine_winrt.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/network/socket/qnativesocketengine_winrt.cpp b/src/network/socket/qnativesocketengine_winrt.cpp index 599f37929c..ecd364b84b 100644 --- a/src/network/socket/qnativesocketengine_winrt.cpp +++ b/src/network/socket/qnativesocketengine_winrt.cpp @@ -458,17 +458,19 @@ void QNativeSocketEngine::close() } #if _MSC_VER >= 1900 - // To close the connection properly (not with a hard reset) all pending read operation have to - // be finished or cancelled. The API isn't available on Windows 8.1 though. - ComPtr socket3; - hr = d->tcpSocket()->QueryInterface(IID_PPV_ARGS(&socket3)); - Q_ASSERT_SUCCEEDED(hr); + if (d->socketType == QAbstractSocket::TcpSocket) { + // To close the connection properly (not with a hard reset) all pending read operation have to + // be finished or cancelled. The API isn't available on Windows 8.1 though. + ComPtr socket3; + hr = d->tcpSocket()->QueryInterface(IID_PPV_ARGS(&socket3)); + Q_ASSERT_SUCCEEDED(hr); - ComPtr action; - hr = socket3->CancelIOAsync(&action); - Q_ASSERT_SUCCEEDED(hr); - hr = QWinRTFunctions::await(action); - Q_ASSERT_SUCCEEDED(hr); + ComPtr action; + hr = socket3->CancelIOAsync(&action); + Q_ASSERT_SUCCEEDED(hr); + hr = QWinRTFunctions::await(action); + Q_ASSERT_SUCCEEDED(hr); + } #endif // _MSC_VER >= 1900 if (d->readOp) { -- cgit v1.2.3 From 27425e62c071441fa8ef34775b6ad7d985e07fde Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 18 May 2016 08:50:53 +0200 Subject: Moc: fix crash when a file ends with \\\r MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit make the 'cleaned' more robust by making sure we do not read past the buffer in some cases. We must also use resize and not reserve on the outpt buffer because reseve is meant as a hint and we are not supposed to write past the size of the QByteArray even if it is reserved. [ChangeLog][moc] Fixed crash on file ending with \\\r Task-number: QTBUG-53441 Change-Id: I901e6c0ffc7f8877de3d07fd08cf26495461d294 Reviewed-by: Jędrzej Nowacki Reviewed-by: Robert Loehning --- src/tools/moc/preprocessor.cpp | 6 ++++-- tests/auto/tools/moc/backslash-newlines.h | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/tools/moc/preprocessor.cpp b/src/tools/moc/preprocessor.cpp index a2a1a958cf..bfe61d0895 100644 --- a/src/tools/moc/preprocessor.cpp +++ b/src/tools/moc/preprocessor.cpp @@ -50,7 +50,7 @@ QT_BEGIN_NAMESPACE static QByteArray cleaned(const QByteArray &input) { QByteArray result; - result.reserve(input.size()); + result.resize(input.size()); const char *data = input.constData(); const char *end = input.constData() + input.size(); char *output = result.data(); @@ -78,13 +78,15 @@ static QByteArray cleaned(const QByteArray &input) if (data != end && (*(data + 1) == '\n' || (*data) == '\r')) { ++newlines; data += 1; - if (*data != '\r') + if (data != end && *data != '\r') data += 1; continue; } } else if (*data == '\r' && *(data + 1) == '\n') { // reduce \r\n to \n ++data; } + if (data == end) + break; char ch = *data; if (ch == '\r') // os9: replace \r with \n diff --git a/tests/auto/tools/moc/backslash-newlines.h b/tests/auto/tools/moc/backslash-newlines.h index fea3045eb1..764d8f87da 100644 --- a/tests/auto/tools/moc/backslash-newlines.h +++ b/tests/auto/tools/moc/backslash-newlines.h @@ -57,3 +57,5 @@ public slots: #undef value #endif // BACKSLASH_NEWLINES_H + +// ends with \\\r should not make moc crash (QTBUG-53441) (no new lines on purpose!!) \ \ No newline at end of file -- cgit v1.2.3 From f095ff85c5c3798161146244e2d5ed8f4724145c Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Wed, 18 May 2016 14:20:23 +0200 Subject: qmake: Introduce CE_PLATFORMNAME to fix creation of vcxproj files While previous SDKs used the form "CE_SDK (CE_ARCH)" in their configuration/platform names, this is not true fo the Toradex SDK. Inside Visual Studio the platform is only called "Toradex_CE800" instead of "Toradex_CE800 (ARMV7)". In order not to break other SDKs CE_PLATFORMNAME is introduced and used in the wince80colibri-armv7-msvc2012 mkspec. If the variable is set qmake uses it as the platform name in its vcproj generator. Change-Id: Icb501bf6446a9f617745a0d2c7a80b240680b043 Reviewed-by: Joerg Bornemann Reviewed-by: Andreas Holzammer --- mkspecs/wince80colibri-armv7-msvc2012/qmake.conf | 1 + qmake/generators/win32/msvc_vcproj.cpp | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/mkspecs/wince80colibri-armv7-msvc2012/qmake.conf b/mkspecs/wince80colibri-armv7-msvc2012/qmake.conf index 3712c94778..7af1ca828e 100644 --- a/mkspecs/wince80colibri-armv7-msvc2012/qmake.conf +++ b/mkspecs/wince80colibri-armv7-msvc2012/qmake.conf @@ -7,6 +7,7 @@ include(../common/wince/qmake.conf) CE_SDK = Toradex_CE800 # replace with actual SDK name CE_ARCH = ARMV7 +CE_PLATFORMNAME = Toradex_CE800 QT_CONFIG -= accessibility DEFINES += QT_NO_CLIPBOARD QT_NO_ACCESSIBILITY QT_NO_NATIVE_GESTURES QT_NOSTANDARDSHELL_UI_MODEL _CRT_SECURE_NO_DEPRECATE _WIN32_WCE=0x800 $$CE_ARCH _AMRV7_ armv7 _ARM_ UNDER_CE WINCE ARM QT_NO_WINCE_SHELLSDK QT_NO_WINCE_NUIOUSER diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp index 1d4f722e51..d1fa6efbfb 100644 --- a/qmake/generators/win32/msvc_vcproj.cpp +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -707,6 +707,8 @@ void VcprojGenerator::writeSubDirs(QTextStream &t) QString slnConf = _slnSolutionConf; if (!project->isEmpty("VCPROJ_ARCH")) { slnConf.replace(QLatin1String("|Win32"), "|" + project->first("VCPROJ_ARCH")); + } else if (!project->isEmpty("CE_PLATFORMNAME")) { + slnConf.replace(QLatin1String("|Win32"), "|" + project->first("CE_PLATFORMNAME")); } else if (!project->isEmpty("CE_SDK") && !project->isEmpty("CE_ARCH")) { QString slnPlatform = QString("|") + project->values("CE_SDK").join(' ') + " (" + project->first("CE_ARCH") + ")"; slnConf.replace(QLatin1String("|Win32"), slnPlatform); @@ -724,6 +726,8 @@ void VcprojGenerator::writeSubDirs(QTextStream &t) QString xplatform = platform; if (!project->isEmpty("VCPROJ_ARCH")) { xplatform = project->first("VCPROJ_ARCH").toQString(); + } else if (!project->isEmpty("CE_PLATFORMNAME")) { + xplatform = project->first("CE_PLATFORMNAME").toQString(); } else if (!project->isEmpty("CE_SDK") && !project->isEmpty("CE_ARCH")) { xplatform = project->values("CE_SDK").join(' ') + " (" + project->first("CE_ARCH") + ")"; } @@ -985,6 +989,8 @@ void VcprojGenerator::initProject() vcProject.Keyword = project->first("VCPROJ_KEYWORD").toQString(); if (!project->isEmpty("VCPROJ_ARCH")) { vcProject.PlatformName = project->first("VCPROJ_ARCH").toQString(); + } else if (!project->isEmpty("CE_PLATFORMNAME")) { + vcProject.PlatformName = project->first("CE_PLATFORMNAME").toQString(); } else if (project->isHostBuild() || project->isEmpty("CE_SDK") || project->isEmpty("CE_ARCH")) { vcProject.PlatformName = (is64Bit ? "x64" : "Win32"); } else { @@ -1069,6 +1075,8 @@ void VcprojGenerator::initConfiguration() conf.ConfigurationName = conf.Name; if (!project->isEmpty("VCPROJ_ARCH")) { conf.Name += "|" + project->first("VCPROJ_ARCH"); + } else if (!project->isEmpty("CE_PLATFORMNAME")) { + conf.Name += "|" + project->first("CE_PLATFORMNAME"); } else if (project->isHostBuild() || project->isEmpty("CE_SDK") || project->isEmpty("CE_ARCH")) { conf.Name += (is64Bit ? "|x64" : "|Win32"); } else { -- cgit v1.2.3 From b627dd2c24c5962c1e8f9d72bcbe9ebdfe6dfceb Mon Sep 17 00:00:00 2001 From: Felix Bourbonnais Date: Tue, 10 May 2016 10:06:53 -0400 Subject: QMenuBar: nested parenting fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QMenuBar now receives a parent changed event for each of its parent, grand-parent, ... This fixes a crash caused by an invalid QWidget pointer and makes sure the keyboard shortcuts events are relayed to the menu bar in all parenting/re-parenting cases by installing an event filter on each parent Task-number: QTBUG-53205 Change-Id: I419e6cbc52e28a67fb08a848a7161b4cb8ae4ae5 Reviewed-by: Gabriel de Dietrich Reviewed-by: Błażej Szczygieł --- src/widgets/widgets/qmenubar.cpp | 55 +++++++++++--------- src/widgets/widgets/qmenubar_p.h | 3 +- .../auto/widgets/widgets/qmenubar/tst_qmenubar.cpp | 59 ++++++++++++++++++++++ 3 files changed, 92 insertions(+), 25 deletions(-) diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp index cca0853a8f..3f42a07f39 100644 --- a/src/widgets/widgets/qmenubar.cpp +++ b/src/widgets/widgets/qmenubar.cpp @@ -706,7 +706,6 @@ void QMenuBarPrivate::init() } #endif q->setBackgroundRole(QPalette::Button); - oldWindow = oldParent = 0; handleReparent(); q->setMouseTracking(q->style()->styleHint(QStyle::SH_MenuBar_MouseTracking, 0, q)); @@ -1330,30 +1329,41 @@ void QMenuBarPrivate::handleReparent() { Q_Q(QMenuBar); QWidget *newParent = q->parentWidget(); - //Note: if parent is reparented, then window may change even if parent doesn't - // we need to install an event filter on parent, and remove the old one - - if (oldParent != newParent) { - if (oldParent) - oldParent->removeEventFilter(q); - if (newParent) - newParent->installEventFilter(q); + //Note: if parent is reparented, then window may change even if parent doesn't. + // We need to install an avent filter on each parent up to the parent that is + // also a window (for shortcuts) + QWidget *newWindow = newParent ? newParent->window() : Q_NULLPTR; + + QVector > newParents; + // Remove event filters on ex-parents, keep them on still-parents + // The parents are always ordered in the vector + foreach (const QPointer &w, oldParents) { + if (w) { + if (newParent == w) { + newParents.append(w); + if (newParent != newWindow) //stop at the window + newParent = newParent->parentWidget(); + } else { + w->removeEventFilter(q); + } + } } - //we also need event filter on top-level (for shortcuts) - QWidget *newWindow = newParent ? newParent->window() : 0; - - if (oldWindow != newWindow) { - if (oldParent && oldParent != oldWindow) - oldWindow->removeEventFilter(q); - - if (newParent && newParent != newWindow) - newWindow->installEventFilter(q); + // At this point, newParent is the next one to be added to newParents + while (newParent && newParent != newWindow) { + //install event filters all the way up to (excluding) the window + newParents.append(newParent); + newParent->installEventFilter(q); + newParent = newParent->parentWidget(); } - oldParent = newParent; - oldWindow = newWindow; + if (newParent && newWindow) { + // Install the event filter on the window + newParents.append(newParent); + newParent->installEventFilter(q); + } + oldParents = newParents; if (platformMenuBar) { if (newWindow) { @@ -1465,10 +1475,9 @@ bool QMenuBar::event(QEvent *e) bool QMenuBar::eventFilter(QObject *object, QEvent *event) { Q_D(QMenuBar); - if (object == parent() && object) { - if (event->type() == QEvent::ParentChange) //GrandparentChange + if (object && (event->type() == QEvent::ParentChange)) //GrandparentChange d->handleReparent(); - } + if (object == d->leftWidget || object == d->rightWidget) { switch (event->type()) { case QEvent::ShowToParent: diff --git a/src/widgets/widgets/qmenubar_p.h b/src/widgets/widgets/qmenubar_p.h index ee615e71f3..7ef696f50e 100644 --- a/src/widgets/widgets/qmenubar_p.h +++ b/src/widgets/widgets/qmenubar_p.h @@ -128,8 +128,7 @@ public: // reparenting void handleReparent(); - QWidget *oldParent; - QWidget *oldWindow; + QVector > oldParents; QList hiddenActions; //default action diff --git a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp index f787d73a02..b2d15fffef 100644 --- a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp +++ b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp @@ -132,10 +132,12 @@ private slots: void closeOnSecondClickAndOpenOnThirdClick(); void cornerWidgets_data(); void cornerWidgets(); + void taskQTBUG53205_crashReparentNested(); protected slots: void onSimpleActivated( QAction*); void onComplexActionTriggered(); + void slotForTaskQTBUG53205(); private: TestMenu initSimpleMenuBar(QMenuBar *mb); @@ -148,6 +150,7 @@ private: QAction* m_lastSimpleAcceleratorId; int m_simpleActivatedCount; int m_complexTriggerCount[int('k')]; + QMenuBar* taskQTBUG53205MenuBar; }; // Testing get/set functions @@ -1438,5 +1441,61 @@ void tst_QMenuBar::cornerWidgets() delete cornerLabel; } + +void tst_QMenuBar::taskQTBUG53205_crashReparentNested() +{ + // This test was largely inspired by the test case submitted for the bug + QMainWindow mainWindow; + mainWindow.resize(300, 200); + centerOnScreen(&mainWindow); + const TestMenu testMenus = initWindowWithComplexMenuBar(mainWindow); + QApplication::setActiveWindow(&mainWindow); + + // they can't be windows + QWidget hiddenParent(&mainWindow, 0); + //this one is going to be moved around + QWidget movingParent(&hiddenParent, 0); + + //set up the container widget + QWidget containerWidget(&movingParent,0); + + //set the new parent, a window + QScopedPointer windowedParent; + windowedParent.reset(new QWidget(Q_NULLPTR, Qt::WindowFlags())); + windowedParent->setGeometry(400, 10, 300, 300); + + windowedParent->show(); + QVERIFY(QTest::qWaitForWindowExposed(windowedParent.data())); + + //set the "container", can't be a window + QWidget containedWidget(&containerWidget, 0); + + taskQTBUG53205MenuBar = new QMenuBar(&containedWidget); + + connect(testMenus.actions[0], &QAction::triggered, this, &tst_QMenuBar::slotForTaskQTBUG53205); + //now, move things around + //from : QMainWindow<-hiddenParent<-movingParent<-containerWidget<-containedWidget<-menuBar + //to windowedParent<-movingParent<-containerWidget<-containedWidget<-menuBar + movingParent.setParent(windowedParent.data(),0); + // this resets the parenting and the menu bar's window + taskQTBUG53205MenuBar->setParent(Q_NULLPTR); + taskQTBUG53205MenuBar->setParent(&containedWidget); + //from windowedParent<-movingParent<-containerWidget<-containedWidget<-menuBar + //to : QMainWindow<-hiddenParent<-movingParent<-containerWidget<-containedWidget<-menuBar + movingParent.setParent(&hiddenParent,0); + windowedParent.reset(); //make the old window invalid + // trigger the aciton, reset the menu bar's window, this used to crash here. + testMenus.actions[0]->trigger(); +} + +void tst_QMenuBar::slotForTaskQTBUG53205() +{ + QWidget *parent = taskQTBUG53205MenuBar->parentWidget(); + taskQTBUG53205MenuBar->setParent(Q_NULLPTR); + taskQTBUG53205MenuBar->setParent(parent); +} + + + QTEST_MAIN(tst_QMenuBar) #include "tst_qmenubar.moc" -- cgit v1.2.3 From 1108291e1a2e7de23440c2b36b2fd31010ae3f51 Mon Sep 17 00:00:00 2001 From: Urs Fleisch Date: Tue, 3 May 2016 20:01:01 +0200 Subject: xcb: Fix drop of text/uri-list and text/html. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When dropping URLs from Firefox or Chrome, the contents are encoded as UTF16, but not correctly decoded. Moreover, the special handling of "text/x-moz-url" drops does not work because this format is converted to "text/uri-list" before. This fixes the handling for URL list and also for UTF16 "text/html". Task-number: QTBUG-47981 Change-Id: I1153f21ede07b2bfe4d104e0fe8bc8487ec5c165 Reviewed-by: Błażej Szczygieł Reviewed-by: Shawn Rutledge --- src/plugins/platforms/xcb/qxcbmime.cpp | 42 +++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/src/plugins/platforms/xcb/qxcbmime.cpp b/src/plugins/platforms/xcb/qxcbmime.cpp index eeac561870..cef2210794 100644 --- a/src/plugins/platforms/xcb/qxcbmime.cpp +++ b/src/plugins/platforms/xcb/qxcbmime.cpp @@ -182,17 +182,37 @@ QVariant QXcbMime::mimeConvertToFormat(QXcbConnection *connection, xcb_atom_t a, a == connection->atom(QXcbAtom::TEXT)) return QString::fromLatin1(data); } - - // special case for uri types - if (format == QLatin1String("text/uri-list")) { - if (atomName == QLatin1String("text/x-moz-url")) { - // we expect this as utf16 - // the first part is a url that should only contain ascci char - // so it should be safe to check that the second char is 0 - // to verify that it is utf16 - if (data.size() > 1 && data.at(1) == 0) - return QString::fromRawData((const QChar *)data.constData(), - data.size() / 2).split(QLatin1Char('\n')).first().toLatin1(); + // If data contains UTF16 text, convert it to a string. + // Firefox uses UTF16 without BOM for text/x-moz-url, "text/html", + // Google Chrome uses UTF16 without BOM for "text/x-moz-url", + // UTF16 with BOM for "text/html". + if ((format == QLatin1String("text/html") || format == QLatin1String("text/uri-list")) + && data.size() > 1) { + const quint8 byte0 = data.at(0); + const quint8 byte1 = data.at(1); + if ((byte0 == 0xff && byte1 == 0xfe) || (byte0 == 0xfe && byte1 == 0xff) + || (byte0 != 0 && byte1 == 0) || (byte0 == 0 && byte1 != 0)) { + const QString str = QString::fromUtf16( + reinterpret_cast<const ushort *>(data.constData()), data.size() / 2); + if (!str.isNull()) { + if (format == QLatin1String("text/uri-list")) { + const QStringList urls = str.split(QLatin1Char('\n')); + QList<QVariant> list; + foreach (const QString &s, urls) { + const QUrl url(s.trimmed()); + if (url.isValid()) + list.append(url); + } + // We expect "text/x-moz-url" as <url><space><title>. + // The atomName variable is not used because mimeAtomToString() + // converts "text/x-moz-url" to "text/uri-list". + if (!list.isEmpty() && connection->atomName(a) == "text/x-moz-url") + return list.first(); + return list; + } else { + return str; + } + } } } -- cgit v1.2.3 From f162e29acca99aaab173fb323d112aad9ec6c2b5 Mon Sep 17 00:00:00 2001 From: Urs Fleisch <ufleisch@users.sourceforge.net> Date: Wed, 4 May 2016 19:47:16 +0200 Subject: xcb: Fix dropping URL on Firefox window. When a URL is dropped on a Firefox window, the "text/x-moz-url" data takes precedence over the "text/uri-list". The "text/x-moz-url" is interpreted as UTF16, however, the data from Qt 5 applications is not in the correct format. The code to create correct UTF16 data exists, but it is not called for two reasons: The atomName will never be "text/x-moz-url" because it is changed to "text/uri-list" by mimeAtomToString() and the InternalMimeData::hasFormatHelper() case is already handled above and the else part will never be considered. This patch fixes the check and brings it into the right order. Task-number: QTBUG-49947 Change-Id: I5ebd31914cc6c1417c513c1ff09e0e858a16915d Reviewed-by: Dmitry Shachnev <mitya57@gmail.com> Reviewed-by: Shawn Rutledge <shawn.rutledge@theqtcompany.com> --- src/plugins/platforms/xcb/qxcbmime.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/plugins/platforms/xcb/qxcbmime.cpp b/src/plugins/platforms/xcb/qxcbmime.cpp index cef2210794..7fea0688cc 100644 --- a/src/plugins/platforms/xcb/qxcbmime.cpp +++ b/src/plugins/platforms/xcb/qxcbmime.cpp @@ -111,17 +111,18 @@ bool QXcbMime::mimeDataForAtom(QXcbConnection *connection, xcb_atom_t a, QMimeDa QString atomName = mimeAtomToString(connection, a); if (QInternalMimeData::hasFormatHelper(atomName, mimeData)) { *data = QInternalMimeData::renderDataHelper(atomName, mimeData); - if (atomName == QLatin1String("application/x-color")) + // mimeAtomToString() converts "text/x-moz-url" to "text/uri-list", + // so QXcbConnection::atomName() has to be used. + if (atomName == QLatin1String("text/uri-list") + && connection->atomName(a) == "text/x-moz-url") { + const QByteArray uri = data->split('\n').first(); + QString mozUri = QString::fromLatin1(uri, uri.size()); + mozUri += QLatin1Char('\n'); + *data = QByteArray(reinterpret_cast<const char *>(mozUri.utf16()), + mozUri.length() * 2); + } else if (atomName == QLatin1String("application/x-color")) *dataFormat = 16; ret = true; - } else if (atomName == QLatin1String("text/x-moz-url") && - QInternalMimeData::hasFormatHelper(QLatin1String("text/uri-list"), mimeData)) { - QByteArray uri = QInternalMimeData::renderDataHelper( - QLatin1String("text/uri-list"), mimeData).split('\n').first(); - QString mozUri = QString::fromLatin1(uri, uri.size()); - mozUri += QLatin1Char('\n'); - *data = QByteArray(reinterpret_cast<const char *>(mozUri.utf16()), mozUri.length() * 2); - ret = true; } else if ((a == XCB_ATOM_PIXMAP || a == XCB_ATOM_BITMAP) && mimeData->hasImage()) { ret = true; } -- cgit v1.2.3 From d16692ed1b12b2d464afcb32799580402e82e393 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= <morten.sorvig@theqtcompany.com> Date: Wed, 11 May 2016 12:41:41 +0200 Subject: Cocoa: Allow pasting text from Qt apps to Mail MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Apple Mail will pick up and attempt to use the vCard flavor, which then fails since the data Qt placed on the clipboard is not actually a valid vCard. Place data in the vCard format on the clipboard only if the mime type is “text/vcard”. [ChangeLog][OS X] Pasting text from Qt applications to Apple Mail now works. [ChangeLog][OS X] “text/vcard” is now required as the mime type when placing vCards on the clipboard. Task-number: QTBUG-48953 Change-Id: Id029b20317f2c5ad8ae225912484de3c97498d29 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@theqtcompany.com> Reviewed-by: Jake Petroules <jake.petroules@qt.io> Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@qt.io> --- src/platformsupport/clipboard/qmacmime.mm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/platformsupport/clipboard/qmacmime.mm b/src/platformsupport/clipboard/qmacmime.mm index dbb7e6f754..317648956c 100644 --- a/src/platformsupport/clipboard/qmacmime.mm +++ b/src/platformsupport/clipboard/qmacmime.mm @@ -748,7 +748,7 @@ bool QMacPasteboardMimeVCard::canConvert(const QString &mime, QString flav) QString QMacPasteboardMimeVCard::flavorFor(const QString &mime) { - if (mime.startsWith(QLatin1String("text/plain"))) + if (mime.startsWith(QLatin1String("text/vcard"))) return QLatin1String("public.vcard"); return QString(); } @@ -756,14 +756,14 @@ QString QMacPasteboardMimeVCard::flavorFor(const QString &mime) QString QMacPasteboardMimeVCard::mimeFor(QString flav) { if (flav == QLatin1String("public.vcard")) - return QLatin1String("text/plain"); + return QLatin1String("text/vcard"); return QString(); } QVariant QMacPasteboardMimeVCard::convertToMime(const QString &mime, QList<QByteArray> data, QString) { QByteArray cards; - if (mime == QLatin1String("text/plain")) { + if (mime == QLatin1String("text/vcard")) { for (int i=0; i<data.size(); ++i) cards += data[i]; } @@ -773,7 +773,7 @@ QVariant QMacPasteboardMimeVCard::convertToMime(const QString &mime, QList<QByte QList<QByteArray> QMacPasteboardMimeVCard::convertFromMime(const QString &mime, QVariant data, QString) { QList<QByteArray> ret; - if (mime == QLatin1String("text/plain")) + if (mime == QLatin1String("text/vcard")) ret.append(data.toString().toUtf8()); return ret; } -- cgit v1.2.3 From e8bdca74b513b58d3db892d838b3a499365ca7e2 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Date: Thu, 12 May 2016 21:15:58 +0200 Subject: optimize ProString::toInt()/toShort() QStringRef has respective overloads now. Change-Id: I9b94c53092ef3fdd62a68f5d3c5bacb98a14d8ec Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> --- qmake/library/proitems.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qmake/library/proitems.h b/qmake/library/proitems.h index 721abb90d0..d22fa0f11e 100644 --- a/qmake/library/proitems.h +++ b/qmake/library/proitems.h @@ -130,8 +130,8 @@ public: bool contains(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return indexOf(s, 0, cs) >= 0; } bool contains(const char *s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return indexOf(QLatin1String(s), 0, cs) >= 0; } bool contains(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return indexOf(c, 0, cs) >= 0; } - int toInt(bool *ok = 0, int base = 10) const { return toQString().toInt(ok, base); } // XXX optimize - short toShort(bool *ok = 0, int base = 10) const { return toQString().toShort(ok, base); } // XXX optimize + int toInt(bool *ok = 0, int base = 10) const { return toQStringRef().toInt(ok, base); } + short toShort(bool *ok = 0, int base = 10) const { return toQStringRef().toShort(ok, base); } uint hash() const { return m_hash; } static uint hash(const QChar *p, int n); -- cgit v1.2.3 From a7a3cd643a554c717ad8fb2bdad3e941dfd94cec Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Date: Fri, 13 May 2016 13:44:42 +0200 Subject: remove pointless conversions to QString when converting to int this doesn't change a lot, but is cleaner. Change-Id: Ia89c399d6df7cc6264954cf309d2c971a5592d6b Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> --- qmake/library/qmakebuiltins.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/qmake/library/qmakebuiltins.cpp b/qmake/library/qmakebuiltins.cpp index 78a491b1cb..f11c55fc09 100644 --- a/qmake/library/qmakebuiltins.cpp +++ b/qmake/library/qmakebuiltins.cpp @@ -478,9 +478,9 @@ ProStringList QMakeEvaluator::evaluateBuiltinExpand( } else { var = args[0]; sep = args.at(1).toQString(); - beg = args.at(2).toQString(m_tmp2).toInt(); + beg = args.at(2).toInt(); if (args.count() == 4) - end = args.at(3).toQString(m_tmp2).toInt(); + end = args.at(3).toInt(); } } else { if (args.count() != 1) { @@ -639,7 +639,7 @@ ProStringList QMakeEvaluator::evaluateBuiltinExpand( const ProStringList &var = values(map(args.at(0))); int start = 0, end = 0; if (args.count() >= 2) { - const QString &start_str = args.at(1).toQString(m_tmp1); + const ProString &start_str = args.at(1); start = start_str.toInt(&ok); if (!ok) { if (args.count() == 2) { @@ -652,11 +652,11 @@ ProStringList QMakeEvaluator::evaluateBuiltinExpand( } if (!ok) evalError(fL1S("member() argument 2 (start) '%2' invalid.") - .arg(start_str)); + .arg(start_str.toQString(m_tmp1))); } else { end = start; if (args.count() == 3) - end = args.at(2).toQString(m_tmp1).toInt(&ok); + end = args.at(2).toInt(&ok); if (!ok) evalError(fL1S("member() argument 3 (end) '%2' invalid.") .arg(args.at(2).toQString(m_tmp1))); @@ -1292,7 +1292,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional( return ReturnFalse; } int cnt = values(map(args.at(0))).count(); - int val = args.at(1).toQString(m_tmp1).toInt(); + int val = args.at(1).toInt(); if (args.count() == 3) { const ProString &comp = args.at(2); if (comp == QLatin1String(">") || comp == QLatin1String("greaterThan")) { -- cgit v1.2.3 From 7931395d5bf30d783449e1696edf8d59b81462ed Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Date: Fri, 13 May 2016 13:45:48 +0200 Subject: remove pointless conversion to QString in isTrue() Change-Id: I7766672018dd4acf9b9fb89acfe664671de4bc3d Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> --- qmake/library/qmakebuiltins.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/qmake/library/qmakebuiltins.cpp b/qmake/library/qmakebuiltins.cpp index f11c55fc09..a77c83ea4f 100644 --- a/qmake/library/qmakebuiltins.cpp +++ b/qmake/library/qmakebuiltins.cpp @@ -192,9 +192,8 @@ void QMakeEvaluator::initFunctionStatics() statics.functions.insert(ProKey(testInits[i].name), testInits[i].func); } -static bool isTrue(const ProString &_str, QString &tmp) +static bool isTrue(const ProString &str) { - const QString &str = _str.toQString(tmp); return !str.compare(statics.strtrue, Qt::CaseInsensitive) || str.toInt(); } @@ -904,7 +903,7 @@ ProStringList QMakeEvaluator::evaluateBuiltinExpand( } else { bool recursive = false; if (args.count() == 2) - recursive = isTrue(args.at(1), m_tmp2); + recursive = isTrue(args.at(1)); QStringList dirs; QString r = m_option->expandEnvVars(args.at(0).toQString(m_tmp1)) .replace(QLatin1Char('\\'), QLatin1Char('/')); @@ -1403,7 +1402,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional( flags = LoadSilent; if (args.count() >= 2) { parseInto = args.at(1).toQString(m_tmp2); - if (args.count() >= 3 && isTrue(args.at(2), m_tmp3)) + if (args.count() >= 3 && isTrue(args.at(2))) flags = LoadSilent; } QString fn = resolvePath(m_option->expandEnvVars(args.at(0).toQString(m_tmp1))); @@ -1441,7 +1440,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional( case T_LOAD: { bool ignore_error = false; if (args.count() == 2) { - ignore_error = isTrue(args.at(1), m_tmp2); + ignore_error = isTrue(args.at(1)); } else if (args.count() != 1) { evalError(fL1S("load(feature) requires one or two arguments.")); return ReturnFalse; -- cgit v1.2.3 From e6b755e702fd6d8ebeb25ecd7a5059e62da6c971 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Date: Fri, 13 May 2016 13:42:15 +0200 Subject: add ProString::toLongLong() and make use of it this is just a bit cleaner. Change-Id: I03e628aca9e2e53c602a4db724da277a0e2c2486 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> --- qmake/library/proitems.h | 1 + qmake/library/qmakebuiltins.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/qmake/library/proitems.h b/qmake/library/proitems.h index d22fa0f11e..dcff970600 100644 --- a/qmake/library/proitems.h +++ b/qmake/library/proitems.h @@ -130,6 +130,7 @@ public: bool contains(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return indexOf(s, 0, cs) >= 0; } bool contains(const char *s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return indexOf(QLatin1String(s), 0, cs) >= 0; } bool contains(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return indexOf(c, 0, cs) >= 0; } + int toLongLong(bool *ok = 0, int base = 10) const { return toQStringRef().toLongLong(ok, base); } int toInt(bool *ok = 0, int base = 10) const { return toQStringRef().toInt(ok, base); } short toShort(bool *ok = 0, int base = 10) const { return toQStringRef().toShort(ok, base); } diff --git a/qmake/library/qmakebuiltins.cpp b/qmake/library/qmakebuiltins.cpp index a77c83ea4f..80569e503a 100644 --- a/qmake/library/qmakebuiltins.cpp +++ b/qmake/library/qmakebuiltins.cpp @@ -561,7 +561,7 @@ ProStringList QMakeEvaluator::evaluateBuiltinExpand( break; } bool ok; - qlonglong num = m_tmp3.toLongLong(&ok, ibase); + qlonglong num = args.at(0).toLongLong(&ok, ibase); if (!ok) { evalError(fL1S("format_number(): malformed number %2 for base %1.") .arg(ibase).arg(m_tmp3)); -- cgit v1.2.3 From b98f599948ddc0380e3392aab593fd426760d0f0 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Date: Thu, 19 May 2016 19:04:33 +0200 Subject: add missing install target Change-Id: I4bf0224fb58297ab6e3b8f966f3b180f91d16279 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com> --- examples/corelib/mimetypes/mimetypebrowser/mimetypebrowser.pro | 3 +++ 1 file changed, 3 insertions(+) diff --git a/examples/corelib/mimetypes/mimetypebrowser/mimetypebrowser.pro b/examples/corelib/mimetypes/mimetypebrowser/mimetypebrowser.pro index 3788632c30..806e9cbd14 100644 --- a/examples/corelib/mimetypes/mimetypebrowser/mimetypebrowser.pro +++ b/examples/corelib/mimetypes/mimetypebrowser/mimetypebrowser.pro @@ -11,3 +11,6 @@ SOURCES += \ HEADERS += \ mimetypemodel.h \ mainwindow.h + +target.path = $$[QT_INSTALL_EXAMPLES]/corelib/mimetypes/mimetypebrowser +INSTALLS += target -- cgit v1.2.3 From 20211c4213c0b2565ff9ab86b281d069325c1a33 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs <laszlo.agocs@theqtcompany.com> Date: Thu, 19 May 2016 15:56:49 +0200 Subject: Avoid failing on 64-bit ARM Affects systems like the NVIDIA DRIVE CX. This did not show up so far because there was no error when Q_PROCESSOR_ARM was not set. Task-number: QTBUG-53493 Change-Id: I107155b6dc1a881eca6f57374ad8db4458875243 Reviewed-by: Dominik Holland <dominik.holland@pelagicore.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> --- src/corelib/global/qprocessordetection.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/global/qprocessordetection.h b/src/corelib/global/qprocessordetection.h index ee94720e7a..6ecd41bc30 100644 --- a/src/corelib/global/qprocessordetection.h +++ b/src/corelib/global/qprocessordetection.h @@ -107,7 +107,7 @@ # define Q_PROCESSOR_ARM __TARGET_ARCH_ARM # elif defined(_M_ARM) && _M_ARM > 1 # define Q_PROCESSOR_ARM _M_ARM -# elif defined(__ARM64_ARCH_8__) +# elif defined(__ARM64_ARCH_8__) || defined(__aarch64__) # define Q_PROCESSOR_ARM 8 # elif defined(__ARM_ARCH_7__) \ || defined(__ARM_ARCH_7A__) \ -- cgit v1.2.3 From c276aa51303b7c6f8e4cd854aadf8344a906e50f Mon Sep 17 00:00:00 2001 From: Oliver Wolff <oliver.wolff@qt.io> Date: Thu, 19 May 2016 10:55:46 +0200 Subject: ANGLE: fixed usage of shared handles for WinRT/WinPhone applications Both checks are not relevant in Qt's context and were skipped before but they sneaked back in with the latest ANGLE update. Change-Id: Ic44de5468a3254afd76ef4804d97d245676daeb1 Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io> --- .../src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp | 3 ++ src/3rdparty/angle/src/libANGLE/validationEGL.cpp | 3 ++ ...-usage-of-shared-handles-for-WinRT-WinPho.patch | 57 ++++++++++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 src/angle/patches/0010-ANGLE-fixed-usage-of-shared-handles-for-WinRT-WinPho.patch diff --git a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp index 62badccefc..0173311bc6 100644 --- a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp +++ b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp @@ -2618,12 +2618,15 @@ bool Renderer11::getShareHandleSupport() const return false; } + // Qt: we don't care about the 9_3 limitation +#if 0 // Also disable share handles on Feature Level 9_3, since it doesn't support share handles on RGBA8 textures/swapchains. if (mRenderer11DeviceCaps.featureLevel <= D3D_FEATURE_LEVEL_9_3) { mSupportsShareHandles = false; return false; } +#endif // Find out which type of D3D11 device the Renderer11 is using d3d11::ANGLED3D11DeviceType deviceType = getDeviceType(); diff --git a/src/3rdparty/angle/src/libANGLE/validationEGL.cpp b/src/3rdparty/angle/src/libANGLE/validationEGL.cpp index 972f6a7a5a..903f51b158 100644 --- a/src/3rdparty/angle/src/libANGLE/validationEGL.cpp +++ b/src/3rdparty/angle/src/libANGLE/validationEGL.cpp @@ -642,11 +642,14 @@ Error ValidateCreatePbufferFromClientBuffer(Display *display, EGLenum buftype, E return Error(EGL_BAD_ATTRIBUTE); } +// On Windows Store, we know the originating texture came from D3D11, so bypass this check +#if !defined(ANGLE_ENABLE_WINDOWS_STORE) const Caps &caps = display->getCaps(); if (textureFormat != EGL_NO_TEXTURE && !caps.textureNPOT && (!gl::isPow2(width) || !gl::isPow2(height))) { return Error(EGL_BAD_MATCH); } +#endif } return Error(EGL_SUCCESS); diff --git a/src/angle/patches/0010-ANGLE-fixed-usage-of-shared-handles-for-WinRT-WinPho.patch b/src/angle/patches/0010-ANGLE-fixed-usage-of-shared-handles-for-WinRT-WinPho.patch new file mode 100644 index 0000000000..8f17018e6e --- /dev/null +++ b/src/angle/patches/0010-ANGLE-fixed-usage-of-shared-handles-for-WinRT-WinPho.patch @@ -0,0 +1,57 @@ +From 5cacddc702624d64a4917a7a704dbbb92aeba53c Mon Sep 17 00:00:00 2001 +From: Oliver Wolff <oliver.wolff@qt.io> +Date: Thu, 19 May 2016 10:55:46 +0200 +Subject: [PATCH] ANGLE: fixed usage of shared handles for WinRT/WinPhone + applications + +Both checks are not relevant in Qt's context and were skipped before but +they sneaked back in with the latest ANGLE update. + +Change-Id: Ic44de5468a3254afd76ef4804d97d245676daeb1 +--- + src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp | 3 +++ + src/3rdparty/angle/src/libANGLE/validationEGL.cpp | 3 +++ + 2 files changed, 6 insertions(+) + +diff --git a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp +index 62badcc..0173311 100644 +--- a/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp ++++ b/src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp +@@ -2618,12 +2618,15 @@ bool Renderer11::getShareHandleSupport() const + return false; + } + ++ // Qt: we don't care about the 9_3 limitation ++#if 0 + // Also disable share handles on Feature Level 9_3, since it doesn't support share handles on RGBA8 textures/swapchains. + if (mRenderer11DeviceCaps.featureLevel <= D3D_FEATURE_LEVEL_9_3) + { + mSupportsShareHandles = false; + return false; + } ++#endif + + // Find out which type of D3D11 device the Renderer11 is using + d3d11::ANGLED3D11DeviceType deviceType = getDeviceType(); +diff --git a/src/3rdparty/angle/src/libANGLE/validationEGL.cpp b/src/3rdparty/angle/src/libANGLE/validationEGL.cpp +index 972f6a7..903f51b 100644 +--- a/src/3rdparty/angle/src/libANGLE/validationEGL.cpp ++++ b/src/3rdparty/angle/src/libANGLE/validationEGL.cpp +@@ -642,11 +642,14 @@ Error ValidateCreatePbufferFromClientBuffer(Display *display, EGLenum buftype, E + return Error(EGL_BAD_ATTRIBUTE); + } + ++// On Windows Store, we know the originating texture came from D3D11, so bypass this check ++#if !defined(ANGLE_ENABLE_WINDOWS_STORE) + const Caps &caps = display->getCaps(); + if (textureFormat != EGL_NO_TEXTURE && !caps.textureNPOT && (!gl::isPow2(width) || !gl::isPow2(height))) + { + return Error(EGL_BAD_MATCH); + } ++#endif + } + + return Error(EGL_SUCCESS); +-- +2.7.0.windows.1 + -- cgit v1.2.3