From 0cfdfcc82ec58b2016f4ab2973343eb85874f27d Mon Sep 17 00:00:00 2001 From: Christoph Schleifenbaum Date: Sun, 11 Oct 2015 15:27:37 +0200 Subject: QListView: Use correct available size when calculating scrollbars. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Calculation was working as long as one didn't use per pixel scrolling. Task-number: QTBUG-48579 Change-Id: Ie02e28b008c5c81ed45d7dd17fed96148c23b598 Reviewed-by: Thorbjørn Lindeijer Reviewed-by: Friedemann Kleint Reviewed-by: David Faure --- .../widgets/itemviews/qlistview/tst_qlistview.cpp | 24 +++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp index 244af1316a..1b21096b44 100644 --- a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp +++ b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp @@ -148,6 +148,7 @@ private slots: void spacing(); void testScrollToWithHidden(); void testViewOptions(); + void taskQTBUG_39902_mutualScrollBars_data(); void taskQTBUG_39902_mutualScrollBars(); }; @@ -2359,8 +2360,21 @@ private: QStyle* m_oldStyle; }; +void tst_QListView::taskQTBUG_39902_mutualScrollBars_data() +{ + QTest::addColumn("horizontalScrollMode"); + QTest::addColumn("verticalScrollMode"); + QTest::newRow("per item / per item") << QAbstractItemView::ScrollPerItem << QAbstractItemView::ScrollPerItem; + QTest::newRow("per pixel / per item") << QAbstractItemView::ScrollPerPixel << QAbstractItemView::ScrollPerItem; + QTest::newRow("per item / per pixel") << QAbstractItemView::ScrollPerItem << QAbstractItemView::ScrollPerPixel; + QTest::newRow("per pixel / per pixel") << QAbstractItemView::ScrollPerPixel << QAbstractItemView::ScrollPerPixel; +} + void tst_QListView::taskQTBUG_39902_mutualScrollBars() { + QFETCH(QAbstractItemView::ScrollMode, horizontalScrollMode); + QFETCH(QAbstractItemView::ScrollMode, verticalScrollMode); + QWidget window; window.resize(400, 300); QListView *view = new QListView(&window); @@ -2372,6 +2386,9 @@ void tst_QListView::taskQTBUG_39902_mutualScrollBars() model.setData(model.index(i, 0), itemSize, Qt::SizeHintRole); view->setModel(&model); + view->setVerticalScrollMode(verticalScrollMode); + view->setHorizontalScrollMode(horizontalScrollMode); + window.show(); QVERIFY(QTest::qWaitForWindowExposed(&window)); // make sure QListView is done with layouting the items (1/10 sec, like QListView) @@ -2412,7 +2429,7 @@ void tst_QListView::taskQTBUG_39902_mutualScrollBars() QTRY_VERIFY(view->horizontalScrollBar()->isVisible()); QTRY_VERIFY(view->verticalScrollBar()->isVisible()); - // now remove just one single pixel in with -> both scroll bars will show up since they depend on each other + // now remove just one single pixel in width -> both scroll bars will show up since they depend on each other view->resize(itemSize.width() + view->frameWidth() * 2 - 1, model.rowCount() * itemSize.height() + view->frameWidth() * 2); QTRY_VERIFY(view->horizontalScrollBar()->isVisible()); QTRY_VERIFY(view->verticalScrollBar()->isVisible()); @@ -2421,6 +2438,11 @@ void tst_QListView::taskQTBUG_39902_mutualScrollBars() view->resize(itemSize.width() + view->frameWidth() * 2, model.rowCount() * itemSize.height() + view->frameWidth() * 2); QTRY_VERIFY(!view->horizontalScrollBar()->isVisible()); QTRY_VERIFY(!view->verticalScrollBar()->isVisible()); + + // now remove just one single pixel in height -> both scroll bars will show up since they depend on each other + view->resize(itemSize.width() + view->frameWidth() * 2, model.rowCount() * itemSize.height() + view->frameWidth() * 2 - 1); + QTRY_VERIFY(view->horizontalScrollBar()->isVisible()); + QTRY_VERIFY(view->verticalScrollBar()->isVisible()); } QTEST_MAIN(tst_QListView) -- cgit v1.2.3 From 0872156559dd290e8e940d22a89cb95a46ef0cf6 Mon Sep 17 00:00:00 2001 From: Alex Trotsenko Date: Sat, 10 Oct 2015 19:49:41 +0300 Subject: QAbstractSocket: fix writing to socket in HostLookup state After calling connectToHost(), the socket enters HostLookup state. At this stage, the socket engine was not created yet, and writing to the socket should result in either data buffering or an error. So, add a check for d->socketEngine to prevent a crash on unbuffered sockets. Task-number: QTBUG-48356 Change-Id: I15ea9ce7de97ce6d7e13e358eca5350745b556bb Reviewed-by: Oswald Buddenhagen Reviewed-by: Richard J. Moore --- tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'tests') diff --git a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp index a4695955af..6f96e6d6f5 100644 --- a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp +++ b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp @@ -117,6 +117,7 @@ private slots: void readyRead(); void readyReadForEmptyDatagram(); void asyncReadDatagram(); + void writeInHostLookupState(); protected slots: void empty_readyReadSlot(); @@ -1725,5 +1726,17 @@ void tst_QUdpSocket::asyncReadDatagram() delete m_asyncReceiver; } +void tst_QUdpSocket::writeInHostLookupState() +{ + QFETCH_GLOBAL(bool, setProxy); + if (setProxy) + return; + + QUdpSocket socket; + socket.connectToHost("nosuchserver.qt-project.org", 80); + QCOMPARE(socket.state(), QUdpSocket::HostLookupState); + QVERIFY(!socket.putChar('0')); +} + QTEST_MAIN(tst_QUdpSocket) #include "tst_qudpsocket.moc" -- cgit v1.2.3