From ce08318a46164172eaa72f4436cddf7f69ce9e1c Mon Sep 17 00:00:00 2001 From: Svenn-Arne Dragly Date: Wed, 20 Sep 2017 09:28:27 +0200 Subject: Add QThreadPool autotest to detect stale threads after tryTake This test makes sure that we do not introduce a regression where the threads exited the inner loop over the queue before the queue was empty. This was triggered by calling tryTake at least maxThreadCount times, which left the same number of null pointers in the queue and caused the inner loop to exit too soon for all the threads. Change-Id: I3a9d800149b88d09510ddc424667670b60f06a33 Reviewed-by: Lars Knoll --- .../corelib/thread/qthreadpool/tst_qthreadpool.cpp | 68 ++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp b/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp index 66853a88d8..0eaf8a4b77 100644 --- a/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp +++ b/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp @@ -94,6 +94,7 @@ private slots: void destroyingWaitsForTasksToFinish(); void stressTest(); void takeAllAndIncreaseMaxThreadCount(); + void waitForDoneAfterTake(); private: QMutex m_functionTestMutex; @@ -1263,5 +1264,72 @@ void tst_QThreadPool::takeAllAndIncreaseMaxThreadCount() { delete task3; } +void tst_QThreadPool::waitForDoneAfterTake() +{ + class Task : public QRunnable + { + public: + Task(QSemaphore *mainBarrier, QSemaphore *threadBarrier) + : m_mainBarrier(mainBarrier) + , m_threadBarrier(threadBarrier) + {} + + void run() + { + m_mainBarrier->release(); + m_threadBarrier->acquire(); + } + + private: + QSemaphore *m_mainBarrier = nullptr; + QSemaphore *m_threadBarrier = nullptr; + }; + + int threadCount = 4; + + // Blocks the main thread from releasing the threadBarrier before all run() functions have started + QSemaphore mainBarrier; + // Blocks the tasks from completing their run function + QSemaphore threadBarrier; + + QThreadPool manager; + manager.setMaxThreadCount(threadCount); + + // Fill all the threads with runnables that wait for the threadBarrier + for (int i = 0; i < threadCount; i++) { + auto *task = new Task(&mainBarrier, &threadBarrier); + manager.start(task); + } + + QVERIFY(manager.activeThreadCount() == manager.maxThreadCount()); + + // Add runnables that are immediately removed from the pool queue. + // This sets the queue elements to nullptr in QThreadPool and we want to test that + // the threads keep going through the queue after encountering a nullptr. + for (int i = 0; i < threadCount; i++) { + QRunnable *runnable = createTask(emptyFunct); + manager.start(runnable); + QVERIFY(manager.tryTake(runnable)); + } + + // Add another runnable that will not be removed + manager.start(createTask(emptyFunct)); + + // Wait for the first runnables to start + mainBarrier.acquire(threadCount); + + QVERIFY(mainBarrier.available() == 0); + QVERIFY(threadBarrier.available() == 0); + + // Release runnables that are waiting and expect all runnables to complete + threadBarrier.release(threadCount); + + // Using qFatal instead of QVERIFY to force exit if threads are still running after timeout. + // Otherwise, QCoreApplication will still wait for the stale threads and never exit the test. + if (!manager.waitForDone(5 * 60 * 1000)) + qFatal("waitForDone returned false. Aborting to stop background threads."); + +} + QTEST_MAIN(tst_QThreadPool); #include "tst_qthreadpool.moc" -- cgit v1.2.3 From 77ee9bd1d3917b2bb1e442433ef0189e9e281e51 Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Tue, 31 Oct 2017 13:46:32 +0100 Subject: QPixmap without QGuiApplication: do not crash, terminate gracefully Any attempt to create a non-null QPixmap in a QCoreApplication-based app would give a hard crash without a warning. This commit adds a check and instead calls qFatal with an explanatory message. This was originally fixed in Qt 4 (ref. QTBUG-17873) but that was lost in the migration to Qt 5. Note that this fix still allows null QPixmaps to be created under QCoreApplication, since that has worked in all Qt 5 versions. Task-number: QTBUG-53572 Task-number: QTBUG-64125 Change-Id: I60ae29b90f1bd3663aeed2ce88dc1690fe66552c Reviewed-by: Lars Knoll --- src/gui/image/qplatformpixmap.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gui/image/qplatformpixmap.cpp b/src/gui/image/qplatformpixmap.cpp index 00c21a5f54..b3b9f79fb1 100644 --- a/src/gui/image/qplatformpixmap.cpp +++ b/src/gui/image/qplatformpixmap.cpp @@ -58,6 +58,9 @@ QT_BEGIN_NAMESPACE */ QPlatformPixmap *QPlatformPixmap::create(int w, int h, PixelType type) { + if (Q_UNLIKELY(!QGuiApplicationPrivate::platformIntegration())) + qFatal("QPlatformPixmap: QGuiApplication required"); + QPlatformPixmap *data = QGuiApplicationPrivate::platformIntegration()->createPlatformPixmap(static_cast(type)); data->resize(w, h); return data; -- cgit v1.2.3 From 4532a9590b0859c7504a15f679df2bfaee726874 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 14 Nov 2017 09:28:06 -0700 Subject: QToolBar: Don't crash on macOS with 'minimal' QPA plugin 'minimal' doesn't provide any native interface. Change-Id: I116c9905977ccc6ededf0c6c41b92b6f785f2875 Reviewed-by: Jake Petroules --- src/widgets/widgets/qtoolbar.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/widgets/widgets/qtoolbar.cpp b/src/widgets/widgets/qtoolbar.cpp index 663e8214c0..243fb6d555 100644 --- a/src/widgets/widgets/qtoolbar.cpp +++ b/src/widgets/widgets/qtoolbar.cpp @@ -1120,6 +1120,8 @@ static bool waitForPopup(QToolBar *tb, QWidget *popup) static void enableMacToolBar(QToolBar *toolbar, bool enable) { QPlatformNativeInterface *nativeInterface = QApplication::platformNativeInterface(); + if (!nativeInterface) + return; QPlatformNativeInterface::NativeResourceForIntegrationFunction function = nativeInterface->nativeResourceFunctionForIntegration("setContentBorderAreaEnabled"); if (!function) -- cgit v1.2.3 From f55a40ac039ee1734ddf06c0ddb33cf760b6ebb9 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 14 Nov 2017 09:23:49 -0700 Subject: Menurama: Fix custom application class constructor signature Change-Id: I989b9205dde9280f97dedbaad47ef4a8d75004ac Reviewed-by: Jake Petroules --- tests/manual/cocoa/menurama/menuramaapplication.cpp | 2 +- tests/manual/cocoa/menurama/menuramaapplication.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/manual/cocoa/menurama/menuramaapplication.cpp b/tests/manual/cocoa/menurama/menuramaapplication.cpp index acd44565eb..4cd741000e 100644 --- a/tests/manual/cocoa/menurama/menuramaapplication.cpp +++ b/tests/manual/cocoa/menurama/menuramaapplication.cpp @@ -28,7 +28,7 @@ #include "menuramaapplication.h" -MenuramaApplication::MenuramaApplication(int argc, char **argv) +MenuramaApplication::MenuramaApplication(int &argc, char **argv) : QApplication (argc, argv) { #if 0 diff --git a/tests/manual/cocoa/menurama/menuramaapplication.h b/tests/manual/cocoa/menurama/menuramaapplication.h index 1a5a55e0ff..2d836832fa 100644 --- a/tests/manual/cocoa/menurama/menuramaapplication.h +++ b/tests/manual/cocoa/menurama/menuramaapplication.h @@ -36,7 +36,7 @@ class MenuramaApplication : public QApplication { public: - MenuramaApplication(int argc, char **argv); + MenuramaApplication(int &argc, char **argv); void addDynMenu(QLatin1String title, QMenu *parentMenu); QAction *findAction(QLatin1String title, QMenu *parentMenu); -- cgit v1.2.3 From 5c0a9fc532d70ae784cca3e16b5fe59862902815 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Wed, 15 Nov 2017 14:55:48 +0100 Subject: QTableView: do not draw grid behind last section QTableView::paintEvent() drawed the grid lines behind the last section when the region to repaint contained rects which were completely behind the last section. This also lead to unnecessary repaints for cells inside rect.top() to rect.bottom() Task-number: QTBUG-60219 Change-Id: I42bb42bea504dfd3c92352ac5c65a43c246a05af Reviewed-by: Richard Moe Gustavsen --- src/widgets/itemviews/qtableview.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/widgets/itemviews/qtableview.cpp b/src/widgets/itemviews/qtableview.cpp index 2d5813198c..8ab811e9f7 100644 --- a/src/widgets/itemviews/qtableview.cpp +++ b/src/widgets/itemviews/qtableview.cpp @@ -1397,6 +1397,9 @@ void QTableView::paintEvent(QPaintEvent *event) } else { dirtyArea.setRight(qMin(dirtyArea.right(), int(x))); } + // dirtyArea may be invalid when the horizontal header is not stretched + if (!dirtyArea.isValid()) + continue; // get the horizontal start and end visual sections int left = horizontalHeader->visualIndexAt(dirtyArea.left()); -- cgit v1.2.3 From ba2f3a156ebc9ce3e6b6e59e231a5c2847163671 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Sun, 12 Nov 2017 13:33:25 +0100 Subject: QTreeView: recalculate row heights in hide/showColumn() When calling QTreeView::hideColumn() the row heights are not recalculated. This can lead to rows which are unnecessarily high due to hidden columns may contain large (e.g. multiline) content. The same applies to showColumn() - there the row might be to small. Hiding columns directly via QTreeView::header()->hideSection() is not covered by this patch since QHeaderView has no way to inform about newly shown/hidden sections. Task-number: QTBUG-8376 Change-Id: I20b1198e56e403ab8cf649af76e5e2280821dd68 Reviewed-by: Richard Moe Gustavsen --- src/widgets/itemviews/qtreeview.cpp | 6 +++ .../widgets/itemviews/qtreeview/tst_qtreeview.cpp | 47 ++++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp index 2abb1a9c14..805b855b9d 100644 --- a/src/widgets/itemviews/qtreeview.cpp +++ b/src/widgets/itemviews/qtreeview.cpp @@ -736,7 +736,10 @@ void QTreeView::dataChanged(const QModelIndex &topLeft, const QModelIndex &botto void QTreeView::hideColumn(int column) { Q_D(QTreeView); + if (d->header->isSectionHidden(column)) + return; d->header->hideSection(column); + doItemsLayout(); } /*! @@ -747,7 +750,10 @@ void QTreeView::hideColumn(int column) void QTreeView::showColumn(int column) { Q_D(QTreeView); + if (!d->header->isSectionHidden(column)) + return; d->header->showSection(column); + doItemsLayout(); } /*! diff --git a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp index 6ee0e50cce..3260d7c968 100644 --- a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp @@ -193,6 +193,7 @@ private slots: void taskQTBUG_37813_crash(); void taskQTBUG_45697_crash(); void taskQTBUG_7232_AllowUserToControlSingleStep(); + void taskQTBUG_8376(); void testInitialFocus(); }; @@ -4399,5 +4400,51 @@ void tst_QTreeView::taskQTBUG_7232_AllowUserToControlSingleStep() QCOMPARE(hStep1, t.horizontalScrollBar()->singleStep()); } +static void fillModeltaskQTBUG_8376(QAbstractItemModel &model) +{ + model.insertRow(0); + model.insertColumn(0); + model.insertColumn(1); + QModelIndex index = model.index(0, 0); + model.setData(index, "Level0"); + { + model.insertRow(0, index); + model.insertRow(1, index); + model.insertColumn(0, index); + model.insertColumn(1, index); + + QModelIndex idx; + idx = model.index(0, 0, index); + model.setData(idx, "Level1"); + + idx = model.index(0, 1, index); + model.setData(idx, "very\nvery\nhigh\ncell"); + } +} + +void tst_QTreeView::taskQTBUG_8376() +{ + QTreeView tv; + QStandardItemModel model; + fillModeltaskQTBUG_8376(model); + tv.setModel(&model); + tv.expandAll(); // init layout + + QModelIndex idxLvl0 = model.index(0, 0); + QModelIndex idxLvl1 = model.index(0, 1, idxLvl0); + const int rowHeightLvl0 = tv.rowHeight(idxLvl0); + const int rowHeightLvl1Visible = tv.rowHeight(idxLvl1); + QVERIFY(rowHeightLvl0 < rowHeightLvl1Visible); + + tv.hideColumn(1); + const int rowHeightLvl1Hidden = tv.rowHeight(idxLvl1); + QCOMPARE(rowHeightLvl0, rowHeightLvl1Hidden); + + tv.showColumn(1); + const int rowHeightLvl1Visible2 = tv.rowHeight(idxLvl1); + QCOMPARE(rowHeightLvl1Visible, rowHeightLvl1Visible2); +} + + QTEST_MAIN(tst_QTreeView) #include "tst_qtreeview.moc" -- cgit v1.2.3 From 53f7c20cb5b5d5b25a70e072db82921ef2a449d1 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Fri, 17 Nov 2017 16:33:19 -0800 Subject: Generic Unix Theme: Don't crash if D-Bus is not running Change-Id: I215ef25fe943730ba8b1976695a04a4aa86638f1 Reviewed-by: Shawn Rutledge Reviewed-by: Dmitry Shachnev --- src/platformsupport/themes/genericunix/qgenericunixthemes.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp index 323e8fd13b..4e7421e98f 100644 --- a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp +++ b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp @@ -120,9 +120,11 @@ static bool isDBusTrayAvailable() { #ifndef QT_NO_DBUS static bool checkDBusGlobalMenuAvailable() { - QDBusConnection connection = QDBusConnection::sessionBus(); - QString registrarService = QStringLiteral("com.canonical.AppMenu.Registrar"); - return connection.interface()->isServiceRegistered(registrarService); + const QDBusConnection connection = QDBusConnection::sessionBus(); + static const QString registrarService = QStringLiteral("com.canonical.AppMenu.Registrar"); + if (const auto iface = connection.interface()) + return iface->isServiceRegistered(registrarService); + return false; } static bool isDBusGlobalMenuAvailable() -- cgit v1.2.3 From 68733e307f209487e89b9261256ec0c0bc2352e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 15 Nov 2017 15:30:55 +0100 Subject: qpa: Teach handleApplicationStateChanged about sync/async delivery MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Using QWindowSystemInterface::SynchronousDelivery reduces the chance that we are flushing other events before delivering the application state change. Those other events may conclude that the application is still active, while in reality it is not, and do bad things. Change-Id: I738c162fac22d2cd18de1e080bcd2cda78ec3f77 Reviewed-by: Tor Arne Vestbø --- src/gui/kernel/qwindowsysteminterface.cpp | 4 ++-- src/gui/kernel/qwindowsysteminterface.h | 1 + src/plugins/platforms/ios/qiosapplicationstate.mm | 6 ++++-- src/plugins/platforms/ios/qiosglobal.h | 1 + src/plugins/platforms/ios/qiosglobal.mm | 1 + 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index 34519cd91b..3f27094845 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -265,12 +265,12 @@ void QWindowSystemInterface::handleWindowScreenChanged(QWindow *window, QScreen QWindowSystemInterfacePrivate::handleWindowSystemEvent(e); } -void QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationState newState, bool forcePropagate) +QT_DEFINE_QPA_EVENT_HANDLER(void, handleApplicationStateChanged, Qt::ApplicationState newState, bool forcePropagate) { Q_ASSERT(QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::ApplicationState)); QWindowSystemInterfacePrivate::ApplicationStateChangedEvent *e = new QWindowSystemInterfacePrivate::ApplicationStateChangedEvent(newState, forcePropagate); - QWindowSystemInterfacePrivate::handleWindowSystemEvent(e); + QWindowSystemInterfacePrivate::handleWindowSystemEvent(e); } /*! diff --git a/src/gui/kernel/qwindowsysteminterface.h b/src/gui/kernel/qwindowsysteminterface.h index e582787dd9..e91c79749d 100644 --- a/src/gui/kernel/qwindowsysteminterface.h +++ b/src/gui/kernel/qwindowsysteminterface.h @@ -179,6 +179,7 @@ public: static void handleWindowStateChanged(QWindow *window, Qt::WindowState newState, int oldState = -1); static void handleWindowScreenChanged(QWindow *window, QScreen *newScreen); + template static void handleApplicationStateChanged(Qt::ApplicationState newState, bool forcePropagate = false); #ifndef QT_NO_DRAGANDDROP diff --git a/src/plugins/platforms/ios/qiosapplicationstate.mm b/src/plugins/platforms/ios/qiosapplicationstate.mm index 7b923e4692..13e7e1150f 100644 --- a/src/plugins/platforms/ios/qiosapplicationstate.mm +++ b/src/plugins/platforms/ios/qiosapplicationstate.mm @@ -39,6 +39,8 @@ #include "qiosapplicationstate.h" +#include "qiosglobal.h" + #include #include @@ -72,8 +74,8 @@ static Qt::ApplicationState qtApplicationState(UIApplicationState uiApplicationS static void handleApplicationStateChanged(UIApplicationState uiApplicationState) { Qt::ApplicationState state = qtApplicationState(uiApplicationState); - QWindowSystemInterface::handleApplicationStateChanged(state); - QWindowSystemInterface::flushWindowSystemEvents(); + qCDebug(lcQpaApplication) << "moved to" << state; + QWindowSystemInterface::handleApplicationStateChanged(state); } QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/ios/qiosglobal.h b/src/plugins/platforms/ios/qiosglobal.h index f74e3004cc..14e06aa37c 100644 --- a/src/plugins/platforms/ios/qiosglobal.h +++ b/src/plugins/platforms/ios/qiosglobal.h @@ -47,6 +47,7 @@ QT_BEGIN_NAMESPACE +Q_DECLARE_LOGGING_CATEGORY(lcQpaApplication); Q_DECLARE_LOGGING_CATEGORY(lcQpaInputMethods); #if !defined(QT_NO_DEBUG) diff --git a/src/plugins/platforms/ios/qiosglobal.mm b/src/plugins/platforms/ios/qiosglobal.mm index 1482ffc7af..8de6481444 100644 --- a/src/plugins/platforms/ios/qiosglobal.mm +++ b/src/plugins/platforms/ios/qiosglobal.mm @@ -44,6 +44,7 @@ QT_BEGIN_NAMESPACE +Q_LOGGING_CATEGORY(lcQpaApplication, "qt.qpa.application"); Q_LOGGING_CATEGORY(lcQpaInputMethods, "qt.qpa.input.methods"); bool isQtApplication() -- cgit v1.2.3 From d8288d2b65f748e986c06dfb117b04a0b73db182 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 21 Nov 2017 14:32:50 +0100 Subject: iOS: Make sure FBOs are cleaned up in the right QIOSContext 655687d84d6a591422 shuffled things around, moving the logic to connect to the window's destroyed signal from backingFramebufferObjectFor into makeCurrent. Unfortunately backingFramebufferObjectFor was the one taking care of recursing into the root context (when shared contexts were in play), so the end result was that the root context were keeping track of the FBO, but the leaf context was trying to clean up the FBO. Task-number: QTBUG-56653 Change-Id: I80ed71a3dedeb7611b2aa7548d94b9fbe0e20763 Reviewed-by: Richard Moe Gustavsen --- src/plugins/platforms/ios/qioscontext.mm | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/plugins/platforms/ios/qioscontext.mm b/src/plugins/platforms/ios/qioscontext.mm index 2d5286e971..6a6cbb4324 100644 --- a/src/plugins/platforms/ios/qioscontext.mm +++ b/src/plugins/platforms/ios/qioscontext.mm @@ -165,8 +165,6 @@ bool QIOSContext::makeCurrent(QPlatformSurface *surface) glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, framebufferObject.depthRenderbuffer); } - - connect(static_cast(surface), SIGNAL(destroyed(QObject*)), this, SLOT(windowDestroyed(QObject*))); } else { glBindFramebuffer(GL_FRAMEBUFFER, framebufferObject.handle); } @@ -249,8 +247,13 @@ QIOSContext::FramebufferObject &QIOSContext::backingFramebufferObjectFor(QPlatfo // should probably use QOpenGLMultiGroupSharedResource to track the shared default-FBOs. if (m_sharedContext) return m_sharedContext->backingFramebufferObjectFor(surface); - else - return m_framebufferObjects[surface]; + + if (!m_framebufferObjects.contains(surface)) { + // We're about to create a new FBO, make sure it's cleaned up as well + connect(static_cast(surface), SIGNAL(destroyed(QObject*)), this, SLOT(windowDestroyed(QObject*))); + } + + return m_framebufferObjects[surface]; } GLuint QIOSContext::defaultFramebufferObject(QPlatformSurface *surface) const -- cgit v1.2.3 From f92aa8e931491efb208753fa079599c4c3a4e0e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 15 Nov 2017 17:10:16 +0100 Subject: iOS: Add logging of window geometry/exposure Change-Id: I6ffc7cd1dde4fadd3e952deabe9c3a1dbce7884d Reviewed-by: Richard Moe Gustavsen --- src/plugins/platforms/ios/qiosglobal.h | 1 + src/plugins/platforms/ios/qiosglobal.mm | 1 + src/plugins/platforms/ios/quiview.mm | 2 ++ 3 files changed, 4 insertions(+) diff --git a/src/plugins/platforms/ios/qiosglobal.h b/src/plugins/platforms/ios/qiosglobal.h index 14e06aa37c..8b39aded06 100644 --- a/src/plugins/platforms/ios/qiosglobal.h +++ b/src/plugins/platforms/ios/qiosglobal.h @@ -49,6 +49,7 @@ QT_BEGIN_NAMESPACE Q_DECLARE_LOGGING_CATEGORY(lcQpaApplication); Q_DECLARE_LOGGING_CATEGORY(lcQpaInputMethods); +Q_DECLARE_LOGGING_CATEGORY(lcQpaWindow); #if !defined(QT_NO_DEBUG) #define qImDebug \ diff --git a/src/plugins/platforms/ios/qiosglobal.mm b/src/plugins/platforms/ios/qiosglobal.mm index 8de6481444..f27b2242df 100644 --- a/src/plugins/platforms/ios/qiosglobal.mm +++ b/src/plugins/platforms/ios/qiosglobal.mm @@ -46,6 +46,7 @@ QT_BEGIN_NAMESPACE Q_LOGGING_CATEGORY(lcQpaApplication, "qt.qpa.application"); Q_LOGGING_CATEGORY(lcQpaInputMethods, "qt.qpa.input.methods"); +Q_LOGGING_CATEGORY(lcQpaWindow, "qt.qpa.window"); bool isQtApplication() { diff --git a/src/plugins/platforms/ios/quiview.mm b/src/plugins/platforms/ios/quiview.mm index 9966bd50a3..bf26feac9f 100644 --- a/src/plugins/platforms/ios/quiview.mm +++ b/src/plugins/platforms/ios/quiview.mm @@ -165,6 +165,7 @@ requestedGeometry : qt_window_private(m_qioswindow->window())->geometry; QWindow *window = m_qioswindow->window(); + qCDebug(lcQpaWindow) << m_qioswindow->window() << "new geometry is" << actualGeometry; QWindowSystemInterface::handleGeometryChange(window, actualGeometry, previousGeometry); if (actualGeometry.size() != previousGeometry.size()) { @@ -197,6 +198,7 @@ region = QRect(QPoint(), bounds); } + qCDebug(lcQpaWindow) << m_qioswindow->window() << region << "isExposed" << m_qioswindow->isExposed(); QWindowSystemInterface::handleExposeEvent(m_qioswindow->window(), region); } -- cgit v1.2.3 From 7ce71f00911d3a8e139c6d4b4a3655863a413c4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 21 Nov 2017 20:42:51 +0100 Subject: Disable -optimize-debug for Clang It results in Xcode outputting a warning when debugging: [app name] was compiled with optimization - stepping may behave oddly; variables may not be available. And the warning is correct, debugging is broken in this situation. Likely caused by Clang treating -Og as -O1: https://reviews.llvm.org/D24998 Change-Id: I25d6bf1e65c81cc5be92b9847f7d5dd6754a0177 Reviewed-by: Allan Sandfeld Jensen --- config_help.txt | 2 +- configure.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config_help.txt b/config_help.txt index f06584a480..6b1401c618 100644 --- a/config_help.txt +++ b/config_help.txt @@ -82,7 +82,7 @@ Build options: -debug-and-release ... Build two versions of Qt, with and without debugging turned on [yes] (Apple and Windows only) -optimize-debug ...... Enable debug-friendly optimizations in debug builds - [auto] (Not supported with MSVC) + [auto] (Not supported with MSVC or Clang toolchains) -optimize-size ....... Optimize release builds for size instead of speed [no] -optimized-tools ..... Build optimized host tools even in debug build [no] -force-debug-info .... Create symbol files for release builds [no] diff --git a/configure.json b/configure.json index a91456aaf3..ce20aa3dc1 100644 --- a/configure.json +++ b/configure.json @@ -689,7 +689,7 @@ }, "optimize_debug": { "label": "Optimize debug build", - "condition": "!config.msvc && (features.debug || features.debug_and_release) && tests.optimize_debug", + "condition": "!config.msvc && !config.clang && (features.debug || features.debug_and_release) && tests.optimize_debug", "output": [ "privateConfig" ] }, "optimize_size": { @@ -1312,7 +1312,7 @@ Configure with '-qreal float' to create a build that is binary-compatible with 5 { "type": "feature", "args": "optimize_debug", - "condition": "!config.msvc && (features.debug || features.debug_and_release)" + "condition": "!config.msvc && !config.clang && (features.debug || features.debug_and_release)" }, { "type": "feature", -- cgit v1.2.3 From 0f3c9782e6e2459f3fea361962492f52fa9c4fd9 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Mon, 20 Nov 2017 16:50:12 +0100 Subject: tst_QNetworkReply::ioHttpRedirectErrors - fix a flaky test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This test became a real pain recently. A close look at the test shows several problems (strangely enough, the failure can never be reproduced on real machines, only on VM - Ubuntu and RHEL 6.6). There are several asserts that are firing from time to time here and there. They show that the logic in test is broken/incorrect. QNAM can open several connections to a host, our test then incorrectly resets its 'client' data-member and bad things can later happen after 'bytesWrittenSlot' executed (and deleted a socket). For example, I can reproduce this scenario in every second run: 1. incoming connection -> client = socket(descriptor), connect to client's readyRead (s1) 2. incoming connection -> client = socket(descriptor), connect to client's readyRead (s2) QNAM sends a request on s1. We reply on s2 (which is already wrong) and call client->deleteLater(), which resets client to nullptr. If QNAM sends something else on s1, we hit assert(!client.isNull()). To avoid this, whenever 'sender' in any slot is different from the 'client', we use the actual 'sender' to reply. Another problem is this weird and rather cryptic waitForFinish which is not needed in this particular test since we wait for reply error, not 'finished'. As it happened before - it's not clear if these two problems were the cause of guaranteed fails on CI - an integration failed ~10 times in a row in the same test (not happening anymore though). Task-number: QTBUG-64569 Change-Id: Id9aa091290350c61fadf1c3c001e7c2e1b5ac8f4 Reviewed-by: Edward Welbourne Reviewed-by: Mårten Nordheim --- .../access/qnetworkreply/tst_qnetworkreply.cpp | 38 +++++++++++++++------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp index 3a752c0748..9fa54597f1 100644 --- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -622,7 +622,7 @@ protected: Q_ASSERT(!client.isNull()); // we need to emulate the bytesWrittenSlot call if the data is empty. if (dataToTransmit.size() == 0) { - QMetaObject::invokeMethod(this, "bytesWrittenSlot", Qt::QueuedConnection); + emit client->bytesWritten(0); } else { client->write(dataToTransmit); // FIXME: For SSL connections, if we don't flush the socket, the @@ -659,22 +659,26 @@ private slots: #ifndef QT_NO_SSL void slotSslErrors(const QList& errors) { - Q_ASSERT(!client.isNull()); - qDebug() << "slotSslErrors" << client->errorString() << errors; + QTcpSocket *currentClient = qobject_cast(sender()); + Q_ASSERT(currentClient); + qDebug() << "slotSslErrors" << currentClient->errorString() << errors; } #endif void slotError(QAbstractSocket::SocketError err) { - if (client.isNull()) - qDebug() << "slotError" << err; - else - qDebug() << "slotError" << err << client->errorString(); + QTcpSocket *currentClient = qobject_cast(sender()); + Q_ASSERT(currentClient); + qDebug() << "slotError" << err << currentClient->errorString(); } public slots: void readyReadSlot() { - Q_ASSERT(!client.isNull()); + QTcpSocket *currentClient = qobject_cast(sender()); + Q_ASSERT(currentClient); + if (currentClient != client) + client = currentClient; + receivedData += client->readAll(); const int doubleEndlPos = receivedData.indexOf("\r\n\r\n"); @@ -8290,11 +8294,23 @@ void tst_QNetworkReply::ioHttpRedirectErrors() QNetworkReplyPtr reply(manager.get(request)); if (localhost.scheme() == "https") reply.data()->ignoreSslErrors(); - QSignalSpy spy(reply.data(), SIGNAL(error(QNetworkReply::NetworkError))); - QCOMPARE(waitForFinish(reply), int(Failure)); + QEventLoop eventLoop; + QTimer watchDog; + watchDog.setSingleShot(true); - QCOMPARE(spy.count(), 1); + reply->connect(reply.data(), QOverload().of(&QNetworkReply::error), + [&eventLoop](QNetworkReply::NetworkError){ + eventLoop.exit(Failure); + }); + + watchDog.connect(&watchDog, &QTimer::timeout, [&eventLoop](){ + eventLoop.exit(Timeout); + }); + + watchDog.start(5000); + + QCOMPARE(eventLoop.exec(), int(Failure)); QCOMPARE(reply->error(), error); } -- cgit v1.2.3 From 048c380629e91231b3327949c98a49142eacbeba Mon Sep 17 00:00:00 2001 From: Filipe Azevedo Date: Wed, 22 Nov 2017 11:49:56 +0100 Subject: Code cleanup in QNAM The private class already store a QNetworkConfigurationManager and networkSessionRequired so it's not need to compute them again nor to instantiate temporary classes. Change-Id: I1bbd9439afa70c950ed6ec3e4fc63ddae4a5b259 Reviewed-by: Timur Pocheptsov --- src/network/access/qnetworkaccessmanager.cpp | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp index 848761c4a7..fba5755b77 100644 --- a/src/network/access/qnetworkaccessmanager.cpp +++ b/src/network/access/qnetworkaccessmanager.cpp @@ -985,8 +985,7 @@ QNetworkConfiguration QNetworkAccessManager::configuration() const if (session) { return session->configuration(); } else { - QNetworkConfigurationManager manager; - return manager.defaultConfiguration(); + return d->networkConfigurationManager.defaultConfiguration(); } } @@ -1010,12 +1009,11 @@ QNetworkConfiguration QNetworkAccessManager::activeConfiguration() const Q_D(const QNetworkAccessManager); QSharedPointer networkSession(d->getNetworkSession()); - QNetworkConfigurationManager manager; if (networkSession) { - return manager.configurationFromIdentifier( + return d->networkConfigurationManager.configurationFromIdentifier( networkSession->sessionProperty(QLatin1String("ActiveConfiguration")).toString()); } else { - return manager.defaultConfiguration(); + return d->networkConfigurationManager.defaultConfiguration(); } } @@ -1342,17 +1340,16 @@ QNetworkReply *QNetworkAccessManager::createRequest(QNetworkAccessManager::Opera } if (!d->networkSessionStrongRef && (d->initializeSession || !d->networkConfiguration.identifier().isEmpty())) { - QNetworkConfigurationManager manager; if (!d->networkConfiguration.identifier().isEmpty()) { if ((d->networkConfiguration.state() & QNetworkConfiguration::Defined) - && d->networkConfiguration != manager.defaultConfiguration()) - d->createSession(manager.defaultConfiguration()); + && d->networkConfiguration != d->networkConfigurationManager.defaultConfiguration()) + d->createSession(d->networkConfigurationManager.defaultConfiguration()); else d->createSession(d->networkConfiguration); } else { - if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) - d->createSession(manager.defaultConfiguration()); + if (d->networkSessionRequired) + d->createSession(d->networkConfigurationManager.defaultConfiguration()); else d->initializeSession = false; } @@ -1884,8 +1881,8 @@ void QNetworkAccessManagerPrivate::_q_onlineStateChanged(bool isOnline) online = (networkConfiguration.state() & QNetworkConfiguration::Active); } else { if (online != isOnline) { - _q_networkSessionClosed(); - createSession(q->configuration()); + _q_networkSessionClosed(); + createSession(q->configuration()); online = isOnline; } } @@ -1909,13 +1906,13 @@ void QNetworkAccessManagerPrivate::_q_configurationChanged(const QNetworkConfigu 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); + // CHECK: If it's having Active flag - why would it be disconnected ??? //this one disconnected but another one is online, // close and create new session _q_networkSessionClosed(); @@ -1926,6 +1923,7 @@ void QNetworkAccessManagerPrivate::_q_configurationChanged(const QNetworkConfigu } else if (onlineConfigurations.contains(id)) { //this one is disconnecting + // CHECK: If it disconnected while we create a session over a down configuration ??? onlineConfigurations.remove(id); if (!onlineConfigurations.isEmpty()) { _q_networkSessionClosed(); -- cgit v1.2.3 From 53f48fceeec7af4439ee45111e327dd4e7a226e8 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Wed, 1 Nov 2017 12:11:33 +0100 Subject: Start from the first visible item when doing a search MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since the first item in a treeview might be hidden, start from the first visible item in the view when starting or wrapping round during a keyboard search. Task-number: QTBUG-63869 Change-Id: I202bea567c6d4484c3ffaf8a5f9af8ea2e13708d Reviewed-by: Thorbjørn Lund Martsum --- src/widgets/itemviews/qtreeview.cpp | 18 ++-- .../widgets/itemviews/qtreeview/tst_qtreeview.cpp | 97 ++++++++++++++++++++++ 2 files changed, 110 insertions(+), 5 deletions(-) diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp index 805b855b9d..bbbadecff8 100644 --- a/src/widgets/itemviews/qtreeview.cpp +++ b/src/widgets/itemviews/qtreeview.cpp @@ -1014,11 +1014,16 @@ void QTreeView::keyboardSearch(const QString &search) if (!d->model->rowCount(d->root) || !d->model->columnCount(d->root)) return; + // Do a relayout nows, so that we can utilize viewItems + d->executePostedLayout(); + if (d->viewItems.isEmpty()) + return; + QModelIndex start; if (currentIndex().isValid()) start = currentIndex(); else - start = d->model->index(0, 0, d->root); + start = d->viewItems.at(0).index; bool skipRow = false; bool keyboardTimeWasValid = d->keyboardInputTime.isValid(); @@ -1046,13 +1051,16 @@ void QTreeView::keyboardSearch(const QString &search) // skip if we are searching for the same key or a new search started if (skipRow) { - if (indexBelow(start).isValid()) + if (indexBelow(start).isValid()) { start = indexBelow(start); - else - start = d->model->index(0, start.column(), d->root); + } else { + const int origCol = start.column(); + start = d->viewItems.at(0).index; + if (origCol != start.column()) + start = start.sibling(start.row(), origCol); + } } - d->executePostedLayout(); int startIndex = d->viewIndex(start); if (startIndex <= -1) return; diff --git a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp index 3260d7c968..dfcaa9b5b9 100644 --- a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp @@ -1067,6 +1067,103 @@ void tst_QTreeView::keyboardSearch() // The item that starts with B is selected. view.keyboardSearch(QLatin1String("B")); QVERIFY(view.selectionModel()->isSelected(model.index(1, 0))); + + // Test that it wraps round + model.appendRow(new QStandardItem("Andy")); + QTest::qWait(QApplication::keyboardInputInterval() * 2); + view.keyboardSearch(QLatin1String("A")); + QVERIFY(view.selectionModel()->isSelected(model.index(3, 0))); + QTest::qWait(QApplication::keyboardInputInterval() * 2); + view.keyboardSearch(QLatin1String("A")); + QVERIFY(view.selectionModel()->isSelected(model.index(0, 0))); + QTest::qWait(QApplication::keyboardInputInterval() * 2); + view.keyboardSearch(QLatin1String("A")); + QVERIFY(view.selectionModel()->isSelected(model.index(3, 0))); + + // Test that it handles the case where the first item is hidden correctly + model.insertRow(0, new QStandardItem("Hidden item")); + view.setRowHidden(0, QModelIndex(), true); + + QTest::qWait(QApplication::keyboardInputInterval() * 2); + view.keyboardSearch(QLatin1String("A")); + QVERIFY(view.selectionModel()->isSelected(model.index(1, 0))); + QTest::qWait(QApplication::keyboardInputInterval() * 2); + view.keyboardSearch(QLatin1String("A")); + QVERIFY(view.selectionModel()->isSelected(model.index(4, 0))); + QTest::qWait(QApplication::keyboardInputInterval() * 2); + view.keyboardSearch(QLatin1String("A")); + QVERIFY(view.selectionModel()->isSelected(model.index(1, 0))); + + QTest::qWait(QApplication::keyboardInputInterval() * 2); + model.clear(); + view.setCurrentIndex(QModelIndex()); + QList items = { new QStandardItem("Andreas"), new QStandardItem("Alicia") }; + model.appendRow(items); + items = { new QStandardItem("Baldrian"), new QStandardItem("Belinda") }; + model.appendRow(items); + items = { new QStandardItem("Cecilie"), new QStandardItem("Claire") }; + model.appendRow(items); + QVERIFY(!view.selectionModel()->hasSelection()); + QVERIFY(!view.selectionModel()->isSelected(model.index(0, 0))); + + // We want to search on the 2nd column so we have to force it to have + // an index in that column as a starting point + view.setCurrentIndex(QModelIndex(model.index(0, 1))); + // Second item in first row is selected + view.keyboardSearch(QLatin1String("A")); + QTRY_VERIFY(view.selectionModel()->isSelected(model.index(0, 1))); + QVERIFY(view.currentIndex() == model.index(0, 1)); + + // Second item in first row is still selected + view.keyboardSearch(QLatin1String("l")); + QVERIFY(view.selectionModel()->isSelected(model.index(0, 1))); + QCOMPARE(view.currentIndex(), model.index(0, 1)); + + // No "AnB" item - keep the same selection. + view.keyboardSearch(QLatin1String("B")); + QVERIFY(view.selectionModel()->isSelected(model.index(0, 1))); + QCOMPARE(view.currentIndex(), model.index(0, 1)); + + // Wait a bit. + QTest::qWait(QApplication::keyboardInputInterval() * 2); + + // The item that starts with B is selected. + view.keyboardSearch(QLatin1String("B")); + QVERIFY(view.selectionModel()->isSelected(model.index(1, 1))); + QCOMPARE(view.currentIndex(), model.index(1, 1)); + + // Test that it wraps round + items = { new QStandardItem("Andy"), new QStandardItem("Adele") }; + model.appendRow(items); + QTest::qWait(QApplication::keyboardInputInterval() * 2); + view.keyboardSearch(QLatin1String("A")); + QVERIFY(view.selectionModel()->isSelected(model.index(3, 1))); + QCOMPARE(view.currentIndex(), model.index(3, 1)); + QTest::qWait(QApplication::keyboardInputInterval() * 2); + view.keyboardSearch(QLatin1String("A")); + QVERIFY(view.selectionModel()->isSelected(model.index(0, 1))); + QCOMPARE(view.currentIndex(), model.index(0, 1)); + QTest::qWait(QApplication::keyboardInputInterval() * 2); + view.keyboardSearch(QLatin1String("A")); + QVERIFY(view.selectionModel()->isSelected(model.index(3, 1))); + QCOMPARE(view.currentIndex(), model.index(3, 1)); + + // Test that it handles the case where the first item is hidden correctly + model.insertRow(0, new QStandardItem("Hidden item")); + view.setRowHidden(0, QModelIndex(), true); + + QTest::qWait(QApplication::keyboardInputInterval() * 2); + view.keyboardSearch(QLatin1String("A")); + QVERIFY(view.selectionModel()->isSelected(model.index(1, 1))); + QCOMPARE(view.currentIndex(), model.index(1, 1)); + QTest::qWait(QApplication::keyboardInputInterval() * 2); + view.keyboardSearch(QLatin1String("A")); + QVERIFY(view.selectionModel()->isSelected(model.index(4, 1))); + QCOMPARE(view.currentIndex(), model.index(4, 1)); + QTest::qWait(QApplication::keyboardInputInterval() * 2); + view.keyboardSearch(QLatin1String("A")); + QVERIFY(view.selectionModel()->isSelected(model.index(1, 1))); + QCOMPARE(view.currentIndex(), model.index(1, 1)); } void tst_QTreeView::keyboardSearchMultiColumn() -- cgit v1.2.3 From c3a5c482efcac794033721e4e32b01b012704096 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Fri, 17 Nov 2017 14:44:36 +0100 Subject: Fix tst_QSslSocket::waitForConnectedEncryptedReadyRead ... and unblacklist it. It was blacklisted some years ago because it was failing too often. It was failing because the ssl socket had already received and decrypted all the data it was going to get, meaning the waitForReadyRead call was just going to block forever. Change-Id: Ia540735177d4e1be8696f2d752f1d7813faecfe5 Reviewed-by: Timur Pocheptsov Reviewed-by: Edward Welbourne --- tests/auto/network/ssl/qsslsocket/BLACKLIST | 2 -- tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp | 7 ++++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/auto/network/ssl/qsslsocket/BLACKLIST b/tests/auto/network/ssl/qsslsocket/BLACKLIST index 52c023b78f..a9ecc69f50 100644 --- a/tests/auto/network/ssl/qsslsocket/BLACKLIST +++ b/tests/auto/network/ssl/qsslsocket/BLACKLIST @@ -1,6 +1,4 @@ windows -[waitForConnectedEncryptedReadyRead:WithSocks5ProxyAuth] -* [protocolServerSide:ssl3-any] rhel-7.2 [protocolServerSide:tls1.0-any] diff --git a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp index c74d3b5375..f97627cb42 100644 --- a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp @@ -1587,7 +1587,12 @@ void tst_QSslSocket::waitForConnectedEncryptedReadyRead() QFETCH_GLOBAL(bool, setProxy); if (setProxy && !socket->waitForEncrypted(10000)) QSKIP("Skipping flaky test - See QTBUG-29941"); - QVERIFY(socket->waitForReadyRead(10000)); + + // We only do this if we have no bytes available to read already because readyRead will + // not be emitted again. + if (socket->bytesAvailable() == 0) + QVERIFY(socket->waitForReadyRead(10000)); + QVERIFY(!socket->peerCertificate().isNull()); QVERIFY(!socket->peerCertificateChain().isEmpty()); } -- cgit v1.2.3 From b71b7461b0b95bbf02c215019381b19e4070e07c Mon Sep 17 00:00:00 2001 From: Kevin Funk Date: Fri, 29 Sep 2017 22:17:10 +0200 Subject: CMake: Set SKIP_AUTOMOC/AUTOUIC where needed Make sure we don't run into warnings for CMake 3.10 Task-number: QTBUG-63442 Change-Id: Ida004705646f0c32fb4bf6006036d80b1f279fd7 Reviewed-by: David Faure Reviewed-by: Sebastian Holtermann Reviewed-by: Rolf Eike Beer --- src/corelib/Qt5CoreMacros.cmake | 9 +++- src/widgets/Qt5WidgetsMacros.cmake | 3 ++ tests/auto/cmake/CMakeLists.txt | 12 ++++-- tests/auto/cmake/test_QTBUG-63422/CMakeLists.txt | 30 ++++++++++++++ tests/auto/cmake/test_QTBUG-63422/mywidget.cpp | 43 ++++++++++++++++++++ tests/auto/cmake/test_QTBUG-63422/mywidget.h | 52 ++++++++++++++++++++++++ tests/auto/cmake/test_QTBUG-63422/mywidget.ui | 34 ++++++++++++++++ tests/auto/cmake/test_QTBUG-63422/res.qrc | 4 ++ 8 files changed, 182 insertions(+), 5 deletions(-) create mode 100644 tests/auto/cmake/test_QTBUG-63422/CMakeLists.txt create mode 100644 tests/auto/cmake/test_QTBUG-63422/mywidget.cpp create mode 100644 tests/auto/cmake/test_QTBUG-63422/mywidget.h create mode 100644 tests/auto/cmake/test_QTBUG-63422/mywidget.ui create mode 100644 tests/auto/cmake/test_QTBUG-63422/res.qrc diff --git a/src/corelib/Qt5CoreMacros.cmake b/src/corelib/Qt5CoreMacros.cmake index 489bc75511..8b65db95cb 100644 --- a/src/corelib/Qt5CoreMacros.cmake +++ b/src/corelib/Qt5CoreMacros.cmake @@ -137,6 +137,9 @@ function(QT5_CREATE_MOC_COMMAND infile outfile moc_flags moc_options moc_target DEPENDS ${infile} ${moc_depends} ${_moc_working_dir} VERBATIM) + set_source_files_properties(${infile} PROPERTIES SKIP_AUTOMOC ON) + set_source_files_properties(${outfile} PROPERTIES SKIP_AUTOMOC ON) + set_source_files_properties(${outfile} PROPERTIES SKIP_AUTOUIC ON) endfunction() @@ -155,7 +158,6 @@ function(QT5_GENERATE_MOC infile outfile ) set(moc_target ${ARGV3}) endif() qt5_create_moc_command(${abs_infile} ${_outfile} "${moc_flags}" "" "${moc_target}" "") - set_source_files_properties(${outfile} PROPERTIES SKIP_AUTOMOC TRUE) # dont run automoc on this file endfunction() @@ -246,6 +248,7 @@ function(QT5_ADD_BINARY_RESOURCES target ) get_filename_component(infile ${it} ABSOLUTE) _QT5_PARSE_QRC_FILE(${infile} _out_depends _rc_depends) + set_source_files_properties(${infile} PROPERTIES SKIP_AUTORCC ON) set(infiles ${infiles} ${infile}) set(out_depends ${out_depends} ${_out_depends}) set(rc_depends ${rc_depends} ${_rc_depends}) @@ -255,7 +258,6 @@ function(QT5_ADD_BINARY_RESOURCES target ) COMMAND ${Qt5Core_RCC_EXECUTABLE} ARGS ${rcc_options} --binary --name ${target} --output ${rcc_destination} ${infiles} DEPENDS ${rc_depends} ${out_depends} VERBATIM) - add_custom_target(${target} ALL DEPENDS ${rcc_destination}) endfunction() @@ -283,12 +285,15 @@ function(QT5_ADD_RESOURCES outfiles ) set(outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${outfilename}.cpp) _QT5_PARSE_QRC_FILE(${infile} _out_depends _rc_depends) + set_source_files_properties(${infile} PROPERTIES SKIP_AUTORCC ON) add_custom_command(OUTPUT ${outfile} COMMAND ${Qt5Core_RCC_EXECUTABLE} ARGS ${rcc_options} --name ${outfilename} --output ${outfile} ${infile} MAIN_DEPENDENCY ${infile} DEPENDS ${_rc_depends} "${out_depends}" VERBATIM) + set_source_files_properties(${outfile} PROPERTIES SKIP_AUTOMOC ON) + set_source_files_properties(${outfile} PROPERTIES SKIP_AUTOUIC ON) list(APPEND ${outfiles} ${outfile}) endforeach() set(${outfiles} ${${outfiles}} PARENT_SCOPE) diff --git a/src/widgets/Qt5WidgetsMacros.cmake b/src/widgets/Qt5WidgetsMacros.cmake index f5e7b7f050..737371a5ad 100644 --- a/src/widgets/Qt5WidgetsMacros.cmake +++ b/src/widgets/Qt5WidgetsMacros.cmake @@ -59,6 +59,9 @@ function(QT5_WRAP_UI outfiles ) COMMAND ${Qt5Widgets_UIC_EXECUTABLE} ARGS ${ui_options} -o ${outfile} ${infile} MAIN_DEPENDENCY ${infile} VERBATIM) + set_source_files_properties(${infile} PROPERTIES SKIP_AUTOUIC ON) + set_source_files_properties(${outfile} PROPERTIES SKIP_AUTOMOC ON) + set_source_files_properties(${outfile} PROPERTIES SKIP_AUTOUIC ON) list(APPEND ${outfiles} ${outfile}) endforeach() set(${outfiles} ${${outfiles}} PARENT_SCOPE) diff --git a/tests/auto/cmake/CMakeLists.txt b/tests/auto/cmake/CMakeLists.txt index 0e6da23c09..40c86132e9 100644 --- a/tests/auto/cmake/CMakeLists.txt +++ b/tests/auto/cmake/CMakeLists.txt @@ -157,7 +157,13 @@ if (NOT CMAKE_VERSION VERSION_LESS 2.8.11 AND NOT NO_WIDGETS) expect_pass(test_interface) endif() -if (NOT CMAKE_VERSION VERSION_LESS 2.8.12) - expect_pass(test_interface_link_libraries) - expect_pass(test_moc_macro_target) +expect_pass(test_interface_link_libraries) +expect_pass(test_moc_macro_target) + +if (NOT CMAKE_VERSION VERSION_LESS 3.8) + # With earlier CMake versions, this test would simply run moc multiple times and lead to: + # /usr/bin/ld: error: CMakeFiles/mywidget.dir/mywidget_automoc.cpp.o: multiple definition of 'MyWidget::qt_static_metacall(QObject*, QMetaObject::Call, int, void**)' + # /usr/bin/ld: CMakeFiles/mywidget.dir/moc_mywidget.cpp.o: previous definition here + # Reason: SKIP_* properties were added in CMake 3.8 only + expect_pass(test_QTBUG-63422) endif() diff --git a/tests/auto/cmake/test_QTBUG-63422/CMakeLists.txt b/tests/auto/cmake/test_QTBUG-63422/CMakeLists.txt new file mode 100644 index 0000000000..a0b82caee4 --- /dev/null +++ b/tests/auto/cmake/test_QTBUG-63422/CMakeLists.txt @@ -0,0 +1,30 @@ +cmake_minimum_required(VERSION 2.8) +project(test_dependent_modules) + +find_package(Qt5Widgets REQUIRED) + +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTOUIC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +# make sure CMP0071 warnings cause a test failure +set(CMAKE_SUPPRESS_DEVELOPER_ERRORS FALSE CACHE INTERNAL "" FORCE) + +qt5_wrap_cpp(moc_files mywidget.h) +qt5_wrap_ui(ui_files mywidget.ui) +qt5_add_resources(qrc_files res.qrc) + +add_executable(mywidget + # source files + mywidget.cpp + mywidget.h + mywidget.ui + res.qrc + + # generated files + ${moc_files} + ${ui_files} + ${qrc_files} +) +target_link_libraries(mywidget ${Qt5Widgets_LIBRARIES}) diff --git a/tests/auto/cmake/test_QTBUG-63422/mywidget.cpp b/tests/auto/cmake/test_QTBUG-63422/mywidget.cpp new file mode 100644 index 0000000000..7bc42537d5 --- /dev/null +++ b/tests/auto/cmake/test_QTBUG-63422/mywidget.cpp @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2017 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Kevin Funk +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "mywidget.h" +#include "ui_mywidget.h" + +MyWidget::MyWidget(QWidget *parent) + : QWidget(parent) +{ + emit someSignal(); +} + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + MyWidget myWidget; + return 0; +} diff --git a/tests/auto/cmake/test_QTBUG-63422/mywidget.h b/tests/auto/cmake/test_QTBUG-63422/mywidget.h new file mode 100644 index 0000000000..d0c79c0538 --- /dev/null +++ b/tests/auto/cmake/test_QTBUG-63422/mywidget.h @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2017 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Kevin Funk +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** 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 https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef MYWIDGET_H +#define MYWIDGET_H + +#include + +namespace Ui +{ +class MyWidget; +} + +class MyWidget : public QWidget +{ + Q_OBJECT +public: + MyWidget(QWidget *parent = nullptr); + +signals: + void someSignal(); + +private: + Ui::MyWidget *ui = nullptr; +}; + +#endif diff --git a/tests/auto/cmake/test_QTBUG-63422/mywidget.ui b/tests/auto/cmake/test_QTBUG-63422/mywidget.ui new file mode 100644 index 0000000000..ac42ac4dc2 --- /dev/null +++ b/tests/auto/cmake/test_QTBUG-63422/mywidget.ui @@ -0,0 +1,34 @@ + + + Form + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + + PushButton + + + + + + + + + + + + + + diff --git a/tests/auto/cmake/test_QTBUG-63422/res.qrc b/tests/auto/cmake/test_QTBUG-63422/res.qrc new file mode 100644 index 0000000000..4ca9cd5837 --- /dev/null +++ b/tests/auto/cmake/test_QTBUG-63422/res.qrc @@ -0,0 +1,4 @@ + + + + -- cgit v1.2.3 From d813c66bfcfac1837814ec4d174d0389172f0d4c Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 25 Apr 2017 12:02:09 -0300 Subject: Fix the build when AVX2 is enabled but __F16C__ isn't defined If -mavx2 is used, __AVX2__ is defined, which enables the F16C code after commit 280e321e52fd4e86545f3f0d4bd4e047786a897e, but that was wrong since we aren't allowed to use the F16C intrinsics with either Clang or GCC (we can only do that with GCC 4.9 and Clang 4.8, and only with an __attribute__ decoration). With ICC and MSVC, we are allowed to use the intrinsics, but the #include was missing. [ChangeLog][QtCore] Fixed a compilation issue with qfloat16 if AVX2 support is enabled in the compiler. Since all processors that support AVX2 also support F16C, for GCC and Clang it is recommended to either add -mf16c to your build or to use the corresponding -march= switch. Task-number: QTBUG-64529 Change-Id: I84e363d735b443cb9beefffd14b8ac1fd4baa978 Reviewed-by: Allan Sandfeld Jensen --- src/corelib/global/qfloat16.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/corelib/global/qfloat16.h b/src/corelib/global/qfloat16.h index 89a62a93db..a0aa9496b4 100644 --- a/src/corelib/global/qfloat16.h +++ b/src/corelib/global/qfloat16.h @@ -44,7 +44,16 @@ #include #include -#if defined __F16C__ +#if defined(QT_COMPILER_SUPPORTS_F16C) && defined(__AVX2__) && !defined(__F16C__) +// All processors that support AVX2 do support F16C too. That doesn't mean +// we're allowed to use the intrinsics directly, so we'll do it only for +// the Intel and Microsoft's compilers. +# if defined(Q_CC_INTEL) || defined(Q_CC_MSVC) +# define __F16C__ 1 +# endif +#endif + +#if defined(QT_COMPILER_SUPPORTS_F16C) && defined(__F16C__) #include #endif @@ -116,7 +125,7 @@ QT_WARNING_DISABLE_CLANG("-Wc99-extensions") QT_WARNING_DISABLE_GCC("-Wold-style-cast") inline qfloat16::qfloat16(float f) Q_DECL_NOTHROW { -#if defined(QT_COMPILER_SUPPORTS_F16C) && (defined(__F16C__) || defined(__AVX2__)) +#if defined(QT_COMPILER_SUPPORTS_F16C) && defined(__F16C__) __m128 packsingle = _mm_set_ss(f); __m128i packhalf = _mm_cvtps_ph(packsingle, 0); b16 = _mm_extract_epi16(packhalf, 0); @@ -134,7 +143,7 @@ QT_WARNING_POP inline qfloat16::operator float() const Q_DECL_NOTHROW { -#if defined(QT_COMPILER_SUPPORTS_F16C) && (defined(__F16C__) || defined(__AVX2__)) +#if defined(QT_COMPILER_SUPPORTS_F16C) && defined(__F16C__) __m128i packhalf = _mm_cvtsi32_si128(b16); __m128 packsingle = _mm_cvtph_ps(packhalf); return _mm_cvtss_f32(packsingle); -- cgit v1.2.3 From 45a5f28aa4d6bc090a5fa094d3b2eb68306714a2 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Sun, 19 Nov 2017 13:03:45 +0100 Subject: QTreeView/Fusion style : Draw child indicator correct in RTL-mode Fusion style did not honor direction option when drawing the child indicator. This lead to a wrong rendering of QTreeView in right-to-left mode. Task-number: QTBUG-63396 Change-Id: I2d5de03d7c831e3caabcc9269617eecb9338f163 Reviewed-by: Richard Moe Gustavsen --- src/widgets/styles/qfusionstyle.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index 016a5e2ad7..774eca1018 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -472,8 +472,10 @@ void QFusionStyle::drawPrimitive(PrimitiveElement elem, break; if (option->state & State_Open) drawPrimitive(PE_IndicatorArrowDown, option, painter, widget); - else - drawPrimitive(PE_IndicatorArrowRight, option, painter, widget); + else { + const bool reverse = (option->direction == Qt::RightToLeft); + drawPrimitive(reverse ? PE_IndicatorArrowLeft : PE_IndicatorArrowRight, option, painter, widget); + } break; } #if QT_CONFIG(tabbar) -- cgit v1.2.3 From a6d7f38791bd4627314be2c93d0989116413830e Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 18 Dec 2016 14:35:11 +0000 Subject: QHeaderView: Simplify and fix layoutChange handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A layoutChange indicates that anything can have moved to anywhere else, including as a result purely of new items being added. It can also indicate that items are removed. The old code here incorrectly assumed that the section count remained constant over this operation by setting the size of the oldSectionHidden QBitArray - whose size is the size before the layoutChange operation - and then calling setBit with model rows numbered after the layoutChange operation. As the two are not necessarily the same dimensions, this can result in asserts from the setBit call. Simplify the handling of layoutChanged entirely by clearing section information, and using the QPersistentIndexes which indicate hidden state to restore that state after re-population. Task-number: QTBUG-53221 Change-Id: I3cda13e86b51b3029b37b647a48748fb604db252 Reviewed-by: Thorbjørn Lund Martsum --- src/widgets/itemviews/qheaderview.cpp | 34 +++++---------- .../itemviews/qheaderview/tst_qheaderview.cpp | 49 ++++++++++++++++++++++ 2 files changed, 59 insertions(+), 24 deletions(-) diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp index 298270a785..4e4c9572a3 100644 --- a/src/widgets/itemviews/qheaderview.cpp +++ b/src/widgets/itemviews/qheaderview.cpp @@ -2086,40 +2086,26 @@ void QHeaderViewPrivate::_q_layoutChanged() { Q_Q(QHeaderView); viewport->update(); - if (persistentHiddenSections.isEmpty() || modelIsEmpty()) { - if (modelSectionCount() != sectionCount()) - q->initializeSections(); - persistentHiddenSections.clear(); + + const auto hiddenSections = persistentHiddenSections; + persistentHiddenSections.clear(); + + clear(); + q->initializeSections(); + invalidateCachedSizeHint(); + + if (modelIsEmpty()) { return; } - QBitArray oldSectionHidden = sectionsHiddenToBitVector(); - oldSectionHidden.resize(sectionItems.size()); - bool sectionCountChanged = false; - - for (int i = 0; i < persistentHiddenSections.count(); ++i) { - QModelIndex index = persistentHiddenSections.at(i); + for (const auto &index : hiddenSections) { if (index.isValid()) { const int logical = (orientation == Qt::Horizontal ? index.column() : index.row()); q->setSectionHidden(logical, true); - oldSectionHidden.setBit(logical, false); - } else if (!sectionCountChanged && (modelSectionCount() != sectionCount())) { - sectionCountChanged = true; - break; } } - persistentHiddenSections.clear(); - - for (int i = 0; i < oldSectionHidden.count(); ++i) { - if (oldSectionHidden.testBit(i)) - q->setSectionHidden(i, false); - } - - // the number of sections changed; we need to reread the state of the model - if (sectionCountChanged) - q->initializeSections(); } /*! diff --git a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp index fa543ae2c3..90019a1798 100644 --- a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp +++ b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp @@ -210,6 +210,7 @@ private slots: void QTBUG12268_hiddenMovedSectionSorting(); void QTBUG14242_hideSectionAutoSize(); void QTBUG50171_visualRegionForSwappedItems(); + void QTBUG53221_assertShiftHiddenRow(); void ensureNoIndexAtLength(); void offsetConsistent(); @@ -2384,6 +2385,54 @@ void tst_QHeaderView::QTBUG50171_visualRegionForSwappedItems() headerView.testVisualRegionForSelection(); } +class QTBUG53221_Model : public QAbstractItemModel +{ +public: + void insertRowAtBeginning() + { + Q_EMIT layoutAboutToBeChanged(); + m_displayNames.insert(0, QStringLiteral("Item %1").arg(m_displayNames.count())); + // Rows are always inserted at the beginning, so move all others. + foreach (const QModelIndex &persIndex, persistentIndexList()) + { + // The vertical header view will have a persistent index stored here on the second call to insertRowAtBeginning. + changePersistentIndex(persIndex, index(persIndex.row() + 1, persIndex.column(), persIndex.parent())); + } + Q_EMIT layoutChanged(); + } + + QVariant data(const QModelIndex &index, int role) const override + { + return (role == Qt::DisplayRole) ? m_displayNames.at(index.row()) : QVariant(); + } + + QModelIndex index(int row, int column, const QModelIndex &) const override { return createIndex(row, column); } + QModelIndex parent(const QModelIndex &) const override { return QModelIndex(); } + int rowCount(const QModelIndex &) const override { return m_displayNames.count(); } + int columnCount(const QModelIndex &) const override { return 1; } + +private: + QStringList m_displayNames; +}; + +void tst_QHeaderView::QTBUG53221_assertShiftHiddenRow() +{ + QTableView tableView; + QTBUG53221_Model modelTableView; + tableView.setModel(&modelTableView); + + modelTableView.insertRowAtBeginning(); + tableView.setRowHidden(0, true); + QCOMPARE(tableView.verticalHeader()->isSectionHidden(0), true); + modelTableView.insertRowAtBeginning(); + QCOMPARE(tableView.verticalHeader()->isSectionHidden(0), false); + QCOMPARE(tableView.verticalHeader()->isSectionHidden(1), true); + modelTableView.insertRowAtBeginning(); + QCOMPARE(tableView.verticalHeader()->isSectionHidden(0), false); + QCOMPARE(tableView.verticalHeader()->isSectionHidden(1), false); + QCOMPARE(tableView.verticalHeader()->isSectionHidden(2), true); +} + void protected_QHeaderView::testVisualRegionForSelection() { QRegion r = visualRegionForSelection(QItemSelection(model()->index(1, 0), model()->index(1, 2))); -- cgit v1.2.3 From fb2e795c6e61b3c5fb699aefdb2662769c12f76b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 21 Nov 2017 16:06:02 +0100 Subject: iOS: Take UIWindow bounds into account when making window fullscreen When an app is in split-view mode, the app can't use the full bounds of the screen, but should limit its area to that of its UIWindow. Task-number: QTBUG-48225 Change-Id: Ia66ad6bba24d9d73a8263ad3f65b9dee9b8a1b37 Reviewed-by: Richard Moe Gustavsen --- src/plugins/platforms/ios/qioswindow.mm | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/plugins/platforms/ios/qioswindow.mm b/src/plugins/platforms/ios/qioswindow.mm index 8ff0dfbd5f..fb161febda 100644 --- a/src/plugins/platforms/ios/qioswindow.mm +++ b/src/plugins/platforms/ios/qioswindow.mm @@ -244,12 +244,25 @@ void QIOSWindow::setWindowState(Qt::WindowState state) applyGeometry(m_normalGeometry); break; case Qt::WindowMaximized: - applyGeometry(window()->flags() & Qt::MaximizeUsingFullscreenGeometryHint ? - screen()->geometry() : screen()->availableGeometry()); - break; - case Qt::WindowFullScreen: - applyGeometry(screen()->geometry()); + case Qt::WindowFullScreen: { + // When an application is in split-view mode, the UIScreen still has the + // same geometry, but the UIWindow is resized to the area reserved for the + // application. We use this to constrain the geometry used when applying the + // fullscreen or maximized window states. Note that we do not do this + // in applyGeometry(), as we don't want to artificially limit window + // placement "outside" of the screen bounds if that's what the user wants. + + QRect uiWindowBounds = QRectF::fromCGRect(m_view.window.bounds).toRect(); + QRect fullscreenGeometry = screen()->geometry().intersected(uiWindowBounds); + QRect maximizedGeometry = window()->flags() & Qt::MaximizeUsingFullscreenGeometryHint ? + fullscreenGeometry : screen()->availableGeometry().intersected(uiWindowBounds); + + if (state & Qt::WindowFullScreen) + applyGeometry(fullscreenGeometry); + else + applyGeometry(maximizedGeometry); break; + } case Qt::WindowMinimized: applyGeometry(QRect()); break; -- cgit v1.2.3 From eade2255ea7cd8200569080e9b295479b1f51bed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 15 Nov 2017 14:50:58 +0100 Subject: Windows: Resolve QStandardPaths config location without qApp instance MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Calling QCoreApplication::applicationDirPath() requires an app instance, but on Windows the implementation just relies on qAppFileName(), which does not require any instance. As resolving the standard paths could be needed before QCoreApplication instantiation, e.g. for categorized logging, we use qAppFileName() directly. Change-Id: Id882cebd528bcb8e945e73a83f1dc3d599b74d1d Reviewed-by: Jan Arve Sæther --- src/corelib/io/qstandardpaths_win.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/corelib/io/qstandardpaths_win.cpp b/src/corelib/io/qstandardpaths_win.cpp index a64bde6fb4..a06b204da7 100644 --- a/src/corelib/io/qstandardpaths_win.cpp +++ b/src/corelib/io/qstandardpaths_win.cpp @@ -201,6 +201,10 @@ QString QStandardPaths::writableLocation(StandardLocation type) return result; } +#ifndef QT_BOOTSTRAPPED +extern QString qAppFileName(); +#endif + QStringList QStandardPaths::standardLocations(StandardLocation type) { QStringList dirs; @@ -217,8 +221,13 @@ QStringList QStandardPaths::standardLocations(StandardLocation type) dirs.append(programData); } #ifndef QT_BOOTSTRAPPED - dirs.append(QCoreApplication::applicationDirPath()); - dirs.append(QCoreApplication::applicationDirPath() + QLatin1String("/data")); + // Note: QCoreApplication::applicationDirPath(), while static, requires + // an application instance. But we might need to resolve the standard + // locations earlier than that, so we fall back to qAppFileName(). + QString applicationDirPath = qApp ? QCoreApplication::applicationDirPath() + : QFileInfo(qAppFileName()).path(); + dirs.append(applicationDirPath); + dirs.append(applicationDirPath + QLatin1String("/data")); #endif // !QT_BOOTSTRAPPED } // isConfigLocation() -- cgit v1.2.3