summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xconfigure6
-rw-r--r--mkspecs/features/winrt/default_pre.prf2
-rw-r--r--src/android/java/src/org/qtproject/qt5/android/bindings/QtActivity.java2
-rw-r--r--src/corelib/io/qwindowspipewriter_p.h1
-rw-r--r--src/corelib/tools/qbytearray.h2
-rw-r--r--src/gui/text/qrawfont.cpp16
-rw-r--r--src/network/socket/qlocalserver.cpp2
-rw-r--r--src/network/socket/qlocalsocket.h2
-rw-r--r--src/network/socket/qlocalsocket_p.h5
-rw-r--r--src/network/socket/qlocalsocket_win.cpp48
-rw-r--r--src/plugins/platforms/minimal/minimal.pro2
-rw-r--r--src/plugins/platforms/minimal/qminimalintegration.cpp25
-rw-r--r--src/plugins/platforms/minimal/qminimalintegration.h2
-rw-r--r--src/widgets/itemviews/qabstractitemview.cpp9
-rw-r--r--src/widgets/kernel/qwidgetwindow.cpp24
-rw-r--r--src/widgets/styles/qfusionstyle.cpp8
-rw-r--r--src/widgets/widgets/qtextbrowser.cpp1
-rw-r--r--tests/auto/auto.pro2
-rw-r--r--tests/auto/corelib/thread/qatomicinteger/tst_qatomicinteger.cpp93
-rw-r--r--tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp20
-rw-r--r--tests/auto/other/other.pro4
-rw-r--r--tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp108
-rw-r--r--tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp11
23 files changed, 251 insertions, 144 deletions
diff --git a/configure b/configure
index a7c9d0c7c9..03e89d56c4 100755
--- a/configure
+++ b/configure
@@ -3945,8 +3945,8 @@ if true; then ###[ '!' -f "$outpath/bin/qmake" ];
fi
case `basename "$PLATFORM"` in
win32-g++*)
- EXTRA_CFLAGS="-DUNICODE"
- EXTRA_CXXFLAGS="-DUNICODE"
+ EXTRA_CFLAGS="$EXTRA_CFLAGS -DUNICODE"
+ EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS -DUNICODE"
EXTRA_OBJS="qfilesystemengine_win.o \
qfilesystemiterator_win.o \
qfsfileengine_win.o \
@@ -3961,7 +3961,7 @@ if true; then ###[ '!' -f "$outpath/bin/qmake" ];
\"\$(SOURCE_PATH)/src/corelib/tools/qlocale_win.cpp\" \
\"\$(SOURCE_PATH)/src/corelib/plugin/qsystemlibrary.cpp\" \
\"\$(SOURCE_PATH)/tools/shared/windows/registry.cpp\""
- EXTRA_LFLAGS="-static -s -lole32 -luuid -ladvapi32 -lkernel32"
+ EXTRA_LFLAGS="$EXTRA_LFLAGS -static -s -lole32 -luuid -ladvapi32 -lkernel32"
EXEEXT=".exe"
;;
*)
diff --git a/mkspecs/features/winrt/default_pre.prf b/mkspecs/features/winrt/default_pre.prf
index 44e3c94b8a..8299950d8b 100644
--- a/mkspecs/features/winrt/default_pre.prf
+++ b/mkspecs/features/winrt/default_pre.prf
@@ -9,4 +9,6 @@
QMAKE_LIBS = ucrt.lib $$QMAKE_LIBS
}
+equals(TEMPLATE, "vcapp"): CONFIG += windeployqt
+
load(default_pre)
diff --git a/src/android/java/src/org/qtproject/qt5/android/bindings/QtActivity.java b/src/android/java/src/org/qtproject/qt5/android/bindings/QtActivity.java
index 678420dae7..ba16673479 100644
--- a/src/android/java/src/org/qtproject/qt5/android/bindings/QtActivity.java
+++ b/src/android/java/src/org/qtproject/qt5/android/bindings/QtActivity.java
@@ -399,7 +399,7 @@ public class QtActivity extends Activity
@Override
public boolean onKeyUp(int keyCode, KeyEvent event)
{
- if (QtApplication.m_delegateObject != null && QtApplication.onKeyDown != null)
+ if (QtApplication.m_delegateObject != null && QtApplication.onKeyUp != null)
return (Boolean) QtApplication.invokeDelegateMethod(QtApplication.onKeyUp, keyCode, event);
else
return super.onKeyUp(keyCode, event);
diff --git a/src/corelib/io/qwindowspipewriter_p.h b/src/corelib/io/qwindowspipewriter_p.h
index 945cbd18bf..59f20edae0 100644
--- a/src/corelib/io/qwindowspipewriter_p.h
+++ b/src/corelib/io/qwindowspipewriter_p.h
@@ -115,6 +115,7 @@ public:
qint64 write(const char *data, qint64 maxlen);
void stop();
bool waitForWrite(int msecs);
+ bool isWriteOperationActive() const { return writeSequenceStarted; }
qint64 bytesToWrite() const;
Q_SIGNALS:
diff --git a/src/corelib/tools/qbytearray.h b/src/corelib/tools/qbytearray.h
index 19c1f25bc7..a53d4eabd3 100644
--- a/src/corelib/tools/qbytearray.h
+++ b/src/corelib/tools/qbytearray.h
@@ -337,7 +337,7 @@ public:
QT_ASCII_CAST_WARN int indexOf(const QString &s, int from = 0) const;
QT_ASCII_CAST_WARN int lastIndexOf(const QString &s, int from = -1) const;
#endif
-#ifndef QT_NO_CAST_FROM_ASCII
+#if !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII)
inline QT_ASCII_CAST_WARN bool operator==(const QString &s2) const;
inline QT_ASCII_CAST_WARN bool operator!=(const QString &s2) const;
inline QT_ASCII_CAST_WARN bool operator<(const QString &s2) const;
diff --git a/src/gui/text/qrawfont.cpp b/src/gui/text/qrawfont.cpp
index 6065e17d9b..2a53b8869d 100644
--- a/src/gui/text/qrawfont.cpp
+++ b/src/gui/text/qrawfont.cpp
@@ -634,18 +634,18 @@ QList<QFontDatabase::WritingSystem> QRawFont::supportedWritingSystems() const
if (d->isValid()) {
QByteArray os2Table = fontTable("OS/2");
if (os2Table.size() > 86) {
- char *data = os2Table.data();
- quint32 *bigEndianUnicodeRanges = reinterpret_cast<quint32 *>(data + 42);
- quint32 *bigEndianCodepageRanges = reinterpret_cast<quint32 *>(data + 78);
+ const uchar * const data = reinterpret_cast<const uchar *>(os2Table.constData());
+ const uchar * const bigEndianUnicodeRanges = data + 42;
+ const uchar * const bigEndianCodepageRanges = data + 78;
quint32 unicodeRanges[4];
quint32 codepageRanges[2];
- for (int i=0; i<4; ++i) {
- if (i < 2)
- codepageRanges[i] = qFromBigEndian(bigEndianCodepageRanges[i]);
- unicodeRanges[i] = qFromBigEndian(bigEndianUnicodeRanges[i]);
- }
+ for (size_t i = 0; i < sizeof unicodeRanges / sizeof *unicodeRanges; ++i)
+ unicodeRanges[i] = qFromBigEndian<quint32>(bigEndianUnicodeRanges + i * sizeof(quint32));
+
+ for (size_t i = 0; i < sizeof codepageRanges / sizeof *codepageRanges; ++i)
+ codepageRanges[i] = qFromBigEndian<quint32>(bigEndianCodepageRanges + i * sizeof(quint32));
QSupportedWritingSystems ws = QPlatformFontDatabase::writingSystemsFromTrueTypeBits(unicodeRanges, codepageRanges);
for (int i = 0; i < QFontDatabase::WritingSystemsCount; ++i) {
diff --git a/src/network/socket/qlocalserver.cpp b/src/network/socket/qlocalserver.cpp
index 76d61f6958..a1085f726a 100644
--- a/src/network/socket/qlocalserver.cpp
+++ b/src/network/socket/qlocalserver.cpp
@@ -184,7 +184,7 @@ QLocalServer::SocketOptions QLocalServer::socketOptions() const
/*!
Stop listening for incoming connections. Existing connections are not
- effected, but any new connections will be refused.
+ affected, but any new connections will be refused.
\sa isListening(), listen()
*/
diff --git a/src/network/socket/qlocalsocket.h b/src/network/socket/qlocalsocket.h
index 0eecab206b..da91ef0e85 100644
--- a/src/network/socket/qlocalsocket.h
+++ b/src/network/socket/qlocalsocket.h
@@ -130,7 +130,7 @@ private:
Q_PRIVATE_SLOT(d_func(), void _q_stateChanged(QAbstractSocket::SocketState))
Q_PRIVATE_SLOT(d_func(), void _q_error(QAbstractSocket::SocketError))
#elif defined(Q_OS_WIN)
- Q_PRIVATE_SLOT(d_func(), void _q_canWrite())
+ Q_PRIVATE_SLOT(d_func(), void _q_bytesWritten(qint64))
Q_PRIVATE_SLOT(d_func(), void _q_pipeClosed())
Q_PRIVATE_SLOT(d_func(), void _q_winError(ulong, const QString &))
#else
diff --git a/src/network/socket/qlocalsocket_p.h b/src/network/socket/qlocalsocket_p.h
index 56f8b590f1..0f84aeea3e 100644
--- a/src/network/socket/qlocalsocket_p.h
+++ b/src/network/socket/qlocalsocket_p.h
@@ -61,6 +61,7 @@
#if defined(QT_LOCALSOCKET_TCP)
# include "qtcpsocket.h"
#elif defined(Q_OS_WIN)
+# include <private/qringbuffer_p.h>
# include "private/qwindowspipereader_p.h"
# include "private/qwindowspipewriter_p.h"
# include <qwineventnotifier.h>
@@ -129,10 +130,12 @@ public:
~QLocalSocketPrivate();
void destroyPipeHandles();
void setErrorString(const QString &function);
- void _q_canWrite();
+ void startNextWrite();
+ void _q_bytesWritten(qint64 bytes);
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 7f9b8a7b06..245108911e 100644
--- a/src/network/socket/qlocalsocket_win.cpp
+++ b/src/network/socket/qlocalsocket_win.cpp
@@ -213,15 +213,21 @@ qint64 QLocalSocket::readData(char *data, qint64 maxSize)
}
}
-qint64 QLocalSocket::writeData(const char *data, qint64 maxSize)
+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);
if (!d->pipeWriter) {
d->pipeWriter = new QWindowsPipeWriter(d->handle, this);
- connect(d->pipeWriter, SIGNAL(canWrite()), this, SLOT(_q_canWrite()));
- connect(d->pipeWriter, SIGNAL(bytesWritten(qint64)), this, SIGNAL(bytesWritten(qint64)));
+ QObjectPrivate::connect(d->pipeWriter, &QWindowsPipeWriter::bytesWritten,
+ d, &QLocalSocketPrivate::_q_bytesWritten);
}
- return d->pipeWriter->write(data, maxSize);
+ if (!d->pipeWriter->isWriteOperationActive())
+ d->startNextWrite();
+ return len;
}
void QLocalSocket::abort()
@@ -230,6 +236,7 @@ void QLocalSocket::abort()
if (d->pipeWriter) {
delete d->pipeWriter;
d->pipeWriter = 0;
+ d->writeBuffer.clear();
}
close();
}
@@ -272,7 +279,7 @@ qint64 QLocalSocket::bytesAvailable() const
qint64 QLocalSocket::bytesToWrite() const
{
Q_D(const QLocalSocket);
- return (d->pipeWriter) ? d->pipeWriter->bytesToWrite() : 0;
+ return d->writeBuffer.size();
}
bool QLocalSocket::canReadLine() const
@@ -304,9 +311,12 @@ void QLocalSocket::close()
bool QLocalSocket::flush()
{
Q_D(QLocalSocket);
- if (d->pipeWriter)
- return d->pipeWriter->waitForWrite(0);
- return false;
+ bool written = false;
+ if (d->pipeWriter) {
+ while (d->pipeWriter->waitForWrite(0))
+ written = true;
+ }
+ return written;
}
void QLocalSocket::disconnectFromServer()
@@ -319,10 +329,11 @@ void QLocalSocket::disconnectFromServer()
// It must be destroyed before close() to prevent an infinite loop.
delete d->pipeWriter;
d->pipeWriter = 0;
+ d->writeBuffer.clear();
}
flush();
- if (d->pipeWriter && d->pipeWriter->bytesToWrite() != 0) {
+ if (bytesToWrite() != 0) {
d->state = QLocalSocket::ClosingState;
emit stateChanged(d->state);
} else {
@@ -351,11 +362,24 @@ bool QLocalSocket::setSocketDescriptor(qintptr socketDescriptor,
return true;
}
-void QLocalSocketPrivate::_q_canWrite()
+void QLocalSocketPrivate::startNextWrite()
+{
+ Q_Q(QLocalSocket);
+ if (writeBuffer.isEmpty()) {
+ if (state == QLocalSocket::ClosingState)
+ q->close();
+ } else {
+ Q_ASSERT(pipeWriter);
+ pipeWriter->write(writeBuffer.readPointer(), writeBuffer.nextDataBlockSize());
+ }
+}
+
+void QLocalSocketPrivate::_q_bytesWritten(qint64 bytes)
{
Q_Q(QLocalSocket);
- if (state == QLocalSocket::ClosingState)
- q->close();
+ writeBuffer.free(bytes);
+ startNextWrite();
+ emit q->bytesWritten(bytes);
}
qintptr QLocalSocket::socketDescriptor() const
diff --git a/src/plugins/platforms/minimal/minimal.pro b/src/plugins/platforms/minimal/minimal.pro
index d6914026ae..0d31d6605b 100644
--- a/src/plugins/platforms/minimal/minimal.pro
+++ b/src/plugins/platforms/minimal/minimal.pro
@@ -10,6 +10,8 @@ HEADERS = qminimalintegration.h \
OTHER_FILES += minimal.json
+CONFIG += qpa/genericunixfontdatabase
+
PLUGIN_TYPE = platforms
PLUGIN_CLASS_NAME = QMinimalIntegrationPlugin
!equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = -
diff --git a/src/plugins/platforms/minimal/qminimalintegration.cpp b/src/plugins/platforms/minimal/qminimalintegration.cpp
index f547048894..7224f4114c 100644
--- a/src/plugins/platforms/minimal/qminimalintegration.cpp
+++ b/src/plugins/platforms/minimal/qminimalintegration.cpp
@@ -43,7 +43,14 @@
#include <QtGui/private/qpixmap_raster_p.h>
#include <QtGui/private/qguiapplication_p.h>
#include <qpa/qplatformwindow.h>
+
+#if defined(Q_OS_WIN)
+#include <QtPlatformSupport/private/qbasicfontdatabase_p.h>
+#elif defined(QT_NO_FONTCONFIG)
#include <qpa/qplatformfontdatabase.h>
+#else
+#include <QtPlatformSupport/private/qgenericunixfontdatabase_p.h>
+#endif
#if !defined(Q_OS_WIN)
#include <QtPlatformSupport/private/qgenericunixeventdispatcher_p.h>
@@ -68,7 +75,7 @@ static inline unsigned parseOptions(const QStringList &paramList)
}
QMinimalIntegration::QMinimalIntegration(const QStringList &parameters)
- : m_dummyFontDatabase(0)
+ : m_fontDatabase(0)
, m_options(parseOptions(parameters))
{
if (qEnvironmentVariableIsSet(debugBackingStoreEnvironmentVariable)
@@ -87,7 +94,7 @@ QMinimalIntegration::QMinimalIntegration(const QStringList &parameters)
QMinimalIntegration::~QMinimalIntegration()
{
- delete m_dummyFontDatabase;
+ delete m_fontDatabase;
}
bool QMinimalIntegration::hasCapability(QPlatformIntegration::Capability cap) const
@@ -110,11 +117,17 @@ public:
QPlatformFontDatabase *QMinimalIntegration::fontDatabase() const
{
- if (m_options & EnableFonts)
+ if (m_options & EnableFonts) {
+#ifndef QT_NO_FONTCONFIG
+ if (!m_fontDatabase)
+ m_fontDatabase = new QGenericUnixFontDatabase;
+#else
return QPlatformIntegration::fontDatabase();
- if (!m_dummyFontDatabase)
- m_dummyFontDatabase = new DummyFontDatabase;
- return m_dummyFontDatabase;
+#endif
+ }
+ if (!m_fontDatabase)
+ m_fontDatabase = new DummyFontDatabase;
+ return m_fontDatabase;
}
QPlatformWindow *QMinimalIntegration::createPlatformWindow(QWindow *window) const
diff --git a/src/plugins/platforms/minimal/qminimalintegration.h b/src/plugins/platforms/minimal/qminimalintegration.h
index 8c3617cfcc..755664d14d 100644
--- a/src/plugins/platforms/minimal/qminimalintegration.h
+++ b/src/plugins/platforms/minimal/qminimalintegration.h
@@ -85,7 +85,7 @@ public:
static QMinimalIntegration *instance();
private:
- mutable QPlatformFontDatabase *m_dummyFontDatabase;
+ mutable QPlatformFontDatabase *m_fontDatabase;
unsigned m_options;
};
diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp
index da4492a684..1bdb4352af 100644
--- a/src/widgets/itemviews/qabstractitemview.cpp
+++ b/src/widgets/itemviews/qabstractitemview.cpp
@@ -782,7 +782,13 @@ void QAbstractItemView::setSelectionModel(QItemSelectionModel *selectionModel)
return;
}
+ QItemSelection oldSelection;
+ QModelIndex oldCurrentIndex;
+
if (d->selectionModel) {
+ oldSelection = d->selectionModel->selection();
+ oldCurrentIndex = d->selectionModel->currentIndex();
+
disconnect(d->selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
this, SLOT(selectionChanged(QItemSelection,QItemSelection)));
disconnect(d->selectionModel, SIGNAL(currentChanged(QModelIndex,QModelIndex)),
@@ -796,6 +802,9 @@ void QAbstractItemView::setSelectionModel(QItemSelectionModel *selectionModel)
this, SLOT(selectionChanged(QItemSelection,QItemSelection)));
connect(d->selectionModel, SIGNAL(currentChanged(QModelIndex,QModelIndex)),
this, SLOT(currentChanged(QModelIndex,QModelIndex)));
+
+ selectionChanged(d->selectionModel->selection(), oldSelection);
+ currentChanged(d->selectionModel->currentIndex(), oldCurrentIndex);
}
}
diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp
index c22841dd56..3ba04e4a2a 100644
--- a/src/widgets/kernel/qwidgetwindow.cpp
+++ b/src/widgets/kernel/qwidgetwindow.cpp
@@ -162,11 +162,29 @@ QObject *QWidgetWindow::focusObject() const
return widget;
}
+static inline bool shouldBePropagatedToWidget(QEvent *event)
+{
+ switch (event->type()) {
+ // Handing show events to widgets would cause them to be triggered twice
+ case QEvent::Show:
+ case QEvent::Hide:
+ case QEvent::Timer:
+ case QEvent::DynamicPropertyChange:
+ case QEvent::ChildAdded:
+ case QEvent::ChildRemoved:
+ return false;
+ default:
+ return true;
+ }
+}
+
bool QWidgetWindow::event(QEvent *event)
{
if (m_widget->testAttribute(Qt::WA_DontShowOnScreen)) {
// \a event is uninteresting for QWidgetWindow, the event was probably
// generated before WA_DontShowOnScreen was set
+ if (!shouldBePropagatedToWidget(event))
+ return true;
return QCoreApplication::sendEvent(m_widget, event);
}
@@ -291,10 +309,6 @@ bool QWidgetWindow::event(QEvent *event)
return true;
#endif // QT_NO_CONTEXTMENU
- // Handing show events to widgets (see below) here would cause them to be triggered twice
- case QEvent::Show:
- case QEvent::Hide:
- return QWindow::event(event);
case QEvent::WindowBlocked:
qt_button_down = 0;
break;
@@ -309,7 +323,7 @@ bool QWidgetWindow::event(QEvent *event)
break;
}
- if (QCoreApplication::sendEvent(m_widget, event) && event->type() != QEvent::Timer)
+ if (shouldBePropagatedToWidget(event) && QCoreApplication::sendEvent(m_widget, event))
return true;
return QWindow::event(event);
diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp
index 3bab2f5dbe..b15b9701d9 100644
--- a/src/widgets/styles/qfusionstyle.cpp
+++ b/src/widgets/styles/qfusionstyle.cpp
@@ -1538,13 +1538,7 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio
QRect r = option->rect;
painter->fillRect(r, highlight);
painter->setPen(QPen(highlightOutline));
- const QLine lines[4] = {
- QLine(QPoint(r.left() + 1, r.bottom()), QPoint(r.right() - 1, r.bottom())),
- QLine(QPoint(r.left() + 1, r.top()), QPoint(r.right() - 1, r.top())),
- QLine(QPoint(r.left(), r.top()), QPoint(r.left(), r.bottom())),
- QLine(QPoint(r.right() , r.top()), QPoint(r.right(), r.bottom())),
- };
- painter->drawLines(lines, 4);
+ painter->drawRect(QRectF(r).adjusted(0.5, 0.5, -0.5, -0.5));
}
bool checkable = menuItem->checkType != QStyleOptionMenuItem::NotCheckable;
bool checked = menuItem->checked;
diff --git a/src/widgets/widgets/qtextbrowser.cpp b/src/widgets/widgets/qtextbrowser.cpp
index db66d39089..45da34c383 100644
--- a/src/widgets/widgets/qtextbrowser.cpp
+++ b/src/widgets/widgets/qtextbrowser.cpp
@@ -659,6 +659,7 @@ void QTextBrowserPrivate::init()
#ifndef QT_NO_CURSOR
viewport->setCursor(oldCursor);
#endif
+ q->setAttribute(Qt::WA_InputMethodEnabled, !q->isReadOnly());
q->setUndoRedoEnabled(false);
viewport->setMouseTracking(true);
QObject::connect(q->document(), SIGNAL(contentsChanged()), q, SLOT(_q_documentModified()));
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index ad7998a198..dd70d78ae5 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -24,7 +24,7 @@ ios: SUBDIRS = corelib gui
wince: SUBDIRS -= printsupport
cross_compile: SUBDIRS -= tools cmake installed_cmake
!qtHaveModule(opengl): SUBDIRS -= opengl
-!qtHaveModule(gui): SUBDIRS -= gui cmake
+!qtHaveModule(gui): SUBDIRS -= gui cmake installed_cmake
!qtHaveModule(widgets): SUBDIRS -= widgets
!qtHaveModule(printsupport): SUBDIRS -= printsupport
!qtHaveModule(concurrent): SUBDIRS -= concurrent
diff --git a/tests/auto/corelib/thread/qatomicinteger/tst_qatomicinteger.cpp b/tests/auto/corelib/thread/qatomicinteger/tst_qatomicinteger.cpp
index fe465df395..5f5252aa96 100644
--- a/tests/auto/corelib/thread/qatomicinteger/tst_qatomicinteger.cpp
+++ b/tests/auto/corelib/thread/qatomicinteger/tst_qatomicinteger.cpp
@@ -174,9 +174,6 @@ private Q_SLOTS:
void fetchAndSub_data() { addData(); }
void fetchAndSub();
- void addSub_data() { addData(); }
- void addSub();
-
void fetchAndOr_data() { addData(); }
void fetchAndOr();
@@ -656,96 +653,6 @@ void tst_QAtomicIntegerXX::fetchAndSub()
}
}
-void tst_QAtomicIntegerXX::addSub()
-{
- QFETCH(LargeInt, value);
- QAtomicInteger<T> atomic(value);
-
- // note: this test has undefined behavior for signed max and min
- T parcel1 = 42;
- T parcel2 = T(0-parcel1);
- T newValue1 = T(value) + parcel1;
- T newValue2 = T(value) - parcel1;
-
- QCOMPARE(atomic.fetchAndAddRelaxed(parcel1), T(value));
- QCOMPARE(atomic.load(), newValue1);
- QCOMPARE(atomic.fetchAndSubRelaxed(parcel1), newValue1);
- QCOMPARE(atomic.load(), T(value));
- QCOMPARE(atomic.fetchAndSubRelaxed(parcel1), T(value));
- QCOMPARE(atomic.load(), newValue2);
- QCOMPARE(atomic.fetchAndAddRelaxed(parcel1), newValue2);
- QCOMPARE(atomic.load(), T(value));
- QCOMPARE(atomic.fetchAndAddRelaxed(parcel2), T(value));
- QCOMPARE(atomic.load(), newValue2);
- QCOMPARE(atomic.fetchAndSubRelaxed(parcel2), newValue2);
- QCOMPARE(atomic.load(), T(value));
- QCOMPARE(atomic.fetchAndSubRelaxed(parcel2), T(value));
- QCOMPARE(atomic.load(), newValue1);
- QCOMPARE(atomic.fetchAndAddRelaxed(parcel2), newValue1);
- QCOMPARE(atomic.load(), T(value));
-
- QCOMPARE(atomic.fetchAndAddAcquire(parcel1), T(value));
- QCOMPARE(atomic.load(), newValue1);
- QCOMPARE(atomic.fetchAndSubAcquire(parcel1), newValue1);
- QCOMPARE(atomic.load(), T(value));
- QCOMPARE(atomic.fetchAndSubAcquire(parcel1), T(value));
- QCOMPARE(atomic.load(), newValue2);
- QCOMPARE(atomic.fetchAndAddAcquire(parcel1), newValue2);
- QCOMPARE(atomic.load(), T(value));
- QCOMPARE(atomic.fetchAndAddAcquire(parcel2), T(value));
- QCOMPARE(atomic.load(), newValue2);
- QCOMPARE(atomic.fetchAndSubAcquire(parcel2), newValue2);
- QCOMPARE(atomic.load(), T(value));
- QCOMPARE(atomic.fetchAndSubAcquire(parcel2), T(value));
- QCOMPARE(atomic.load(), newValue1);
- QCOMPARE(atomic.fetchAndAddAcquire(parcel2), newValue1);
- QCOMPARE(atomic.load(), T(value));
-
- QCOMPARE(atomic.fetchAndAddRelease(parcel1), T(value));
- QCOMPARE(atomic.load(), newValue1);
- QCOMPARE(atomic.fetchAndSubRelease(parcel1), newValue1);
- QCOMPARE(atomic.load(), T(value));
- QCOMPARE(atomic.fetchAndSubRelease(parcel1), T(value));
- QCOMPARE(atomic.load(), newValue2);
- QCOMPARE(atomic.fetchAndAddRelease(parcel1), newValue2);
- QCOMPARE(atomic.load(), T(value));
- QCOMPARE(atomic.fetchAndAddRelease(parcel2), T(value));
- QCOMPARE(atomic.load(), newValue2);
- QCOMPARE(atomic.fetchAndSubRelease(parcel2), newValue2);
- QCOMPARE(atomic.load(), T(value));
- QCOMPARE(atomic.fetchAndSubRelease(parcel2), T(value));
- QCOMPARE(atomic.load(), newValue1);
- QCOMPARE(atomic.fetchAndAddRelease(parcel2), newValue1);
- QCOMPARE(atomic.load(), T(value));
-
- QCOMPARE(atomic.fetchAndAddOrdered(parcel1), T(value));
- QCOMPARE(atomic.load(), newValue1);
- QCOMPARE(atomic.fetchAndSubOrdered(parcel1), newValue1);
- QCOMPARE(atomic.load(), T(value));
- QCOMPARE(atomic.fetchAndSubOrdered(parcel1), T(value));
- QCOMPARE(atomic.load(), newValue2);
- QCOMPARE(atomic.fetchAndAddOrdered(parcel1), newValue2);
- QCOMPARE(atomic.load(), T(value));
- QCOMPARE(atomic.fetchAndAddOrdered(parcel2), T(value));
- QCOMPARE(atomic.load(), newValue2);
- QCOMPARE(atomic.fetchAndSubOrdered(parcel2), newValue2);
- QCOMPARE(atomic.load(), T(value));
- QCOMPARE(atomic.fetchAndSubOrdered(parcel2), T(value));
- QCOMPARE(atomic.load(), newValue1);
- QCOMPARE(atomic.fetchAndAddOrdered(parcel2), newValue1);
- QCOMPARE(atomic.load(), T(value));
-
- // operator+= and operator-=
- QCOMPARE(atomic += parcel1, newValue1);
- QCOMPARE(atomic -= parcel1, T(value));
- QCOMPARE(atomic -= parcel1, newValue2);
- QCOMPARE(atomic += parcel1, T(value));
- QCOMPARE(atomic += parcel2, newValue2);
- QCOMPARE(atomic -= parcel2, T(value));
- QCOMPARE(atomic -= parcel2, newValue1);
- QCOMPARE(atomic += parcel2, T(value));
-}
-
void tst_QAtomicIntegerXX::fetchAndOr()
{
QFETCH(LargeInt, value);
diff --git a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp
index 123fbfeb2a..d553854cb2 100644
--- a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp
+++ b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp
@@ -97,7 +97,10 @@ private slots:
void multiConnect();
void writeOnlySocket();
+
+ void writeToClientAndDisconnect_data();
void writeToClientAndDisconnect();
+
void debug();
void bytesWrittenSignal();
void syncDisconnectNotify();
@@ -1026,8 +1029,16 @@ void tst_QLocalSocket::writeOnlySocket()
QCOMPARE(client.state(), QLocalSocket::ConnectedState);
}
+void tst_QLocalSocket::writeToClientAndDisconnect_data()
+{
+ QTest::addColumn<int>("chunks");
+ QTest::newRow("one chunk") << 1;
+ QTest::newRow("several chunks") << 20;
+}
+
void tst_QLocalSocket::writeToClientAndDisconnect()
{
+ QFETCH(int, chunks);
QLocalServer server;
QLocalSocket client;
QSignalSpy readChannelFinishedSpy(&client, SIGNAL(readChannelFinished()));
@@ -1041,14 +1052,17 @@ void tst_QLocalSocket::writeToClientAndDisconnect()
char buffer[100];
memset(buffer, 0, sizeof(buffer));
- QCOMPARE(clientSocket->write(buffer, sizeof(buffer)), (qint64)sizeof(buffer));
- clientSocket->waitForBytesWritten();
+ for (int i = 0; i < chunks; ++i)
+ QCOMPARE(clientSocket->write(buffer, sizeof(buffer)), qint64(sizeof(buffer)));
+ while (clientSocket->bytesToWrite())
+ QVERIFY(clientSocket->waitForBytesWritten());
clientSocket->close();
server.close();
client.waitForDisconnected();
QCOMPARE(readChannelFinishedSpy.count(), 1);
- QCOMPARE(client.read(buffer, sizeof(buffer)), (qint64)sizeof(buffer));
+ const QByteArray received = client.readAll();
+ QCOMPARE(received.size(), qint64(sizeof(buffer) * chunks));
QCOMPARE(client.state(), QLocalSocket::UnconnectedState);
}
diff --git a/tests/auto/other/other.pro b/tests/auto/other/other.pro
index 673e922fdd..0e9f054a01 100644
--- a/tests/auto/other/other.pro
+++ b/tests/auto/other/other.pro
@@ -24,6 +24,10 @@ SUBDIRS=\
windowsmobile \
toolsupport \
+!qtHaveModule(gui): SUBDIRS -= \
+ qcomplextext \
+ qprocess_and_guieventloop \
+
!qtHaveModule(widgets): SUBDIRS -= \
gestures \
lancelot \
diff --git a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
index 2dd0337117..89fb30557b 100644
--- a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
+++ b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
@@ -32,6 +32,7 @@
#include <qabstractitemview.h>
#include <qstandarditemmodel.h>
#include <qapplication.h>
+#include <qevent.h>
#include <qlistview.h>
#include <qlistwidget.h>
#include <qtableview.h>
@@ -248,6 +249,8 @@ private slots:
void shiftSelectionAfterChangingModelContents();
void QTBUG48968_reentrant_updateEditorGeometries();
void QTBUG50102_SH_ItemView_ScrollMode();
+ void QTBUG50535_update_on_new_selection_model();
+ void testSelectionModelInSyncWithView();
};
class MyAbstractItemDelegate : public QAbstractItemDelegate
@@ -2067,6 +2070,111 @@ void tst_QAbstractItemView::QTBUG50102_SH_ItemView_ScrollMode()
QCOMPARE(view.horizontalScrollMode(), styleScrollMode);
}
+void tst_QAbstractItemView::QTBUG50535_update_on_new_selection_model()
+{
+ QStandardItemModel model;
+ for (int i = 0; i < 10; ++i)
+ model.appendRow(new QStandardItem(QStringLiteral("%1").arg(i)));
+
+ class ListView : public QListView
+ {
+ public:
+ ListView()
+ : m_paintEventsCount(0)
+ {
+ }
+
+ int m_paintEventsCount;
+
+ protected:
+ bool viewportEvent(QEvent *event) Q_DECL_OVERRIDE
+ {
+ if (event->type() == QEvent::Paint)
+ ++m_paintEventsCount;
+ return QListView::viewportEvent(event);
+ }
+ };
+
+ // keep the current/selected row in the "low range", i.e. be sure it's visible, otherwise we
+ // don't get updates and the test fails.
+
+ ListView view;
+ view.setModel(&model);
+ view.selectionModel()->setCurrentIndex(model.index(1, 0), QItemSelectionModel::SelectCurrent);
+ view.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
+
+
+ QItemSelectionModel selectionModel(&model);
+ selectionModel.setCurrentIndex(model.index(2, 0), QItemSelectionModel::Current);
+
+ int oldPaintEventsCount = view.m_paintEventsCount;
+ view.setSelectionModel(&selectionModel);
+ QTRY_VERIFY(view.m_paintEventsCount > oldPaintEventsCount);
+
+
+ QItemSelectionModel selectionModel2(&model);
+ selectionModel2.select(model.index(0, 0), QItemSelectionModel::ClearAndSelect);
+ selectionModel2.setCurrentIndex(model.index(1, 0), QItemSelectionModel::Current);
+
+ oldPaintEventsCount = view.m_paintEventsCount;
+ view.setSelectionModel(&selectionModel2);
+ QTRY_VERIFY(view.m_paintEventsCount > oldPaintEventsCount);
+}
+
+void tst_QAbstractItemView::testSelectionModelInSyncWithView()
+{
+ QStandardItemModel model;
+ for (int i = 0; i < 10; ++i)
+ model.appendRow(new QStandardItem(QStringLiteral("%1").arg(i)));
+
+ class ListView : public QListView
+ {
+ public:
+ using QListView::selectedIndexes;
+ };
+
+ ListView view;
+ QVERIFY(!view.selectionModel());
+
+ view.setModel(&model);
+ QVERIFY(view.selectionModel());
+ QVERIFY(view.selectedIndexes().isEmpty());
+ QVERIFY(view.selectionModel()->selection().isEmpty());
+
+ view.setCurrentIndex(model.index(0, 0));
+ QCOMPARE(view.currentIndex(), model.index(0, 0));
+ QCOMPARE(view.selectionModel()->currentIndex(), model.index(0, 0));
+
+ view.selectionModel()->setCurrentIndex(model.index(1, 0), QItemSelectionModel::SelectCurrent);
+ QCOMPARE(view.currentIndex(), model.index(1, 0));
+ QCOMPARE(view.selectedIndexes(), QModelIndexList() << model.index(1, 0));
+ QCOMPARE(view.selectionModel()->currentIndex(), model.index(1, 0));
+ QCOMPARE(view.selectionModel()->selection().indexes(), QModelIndexList() << model.index(1, 0));
+
+ view.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
+
+ QItemSelectionModel selectionModel(&model);
+ selectionModel.setCurrentIndex(model.index(2, 0), QItemSelectionModel::Current);
+
+ view.setSelectionModel(&selectionModel);
+ QCOMPARE(view.currentIndex(), model.index(2, 0));
+ QCOMPARE(view.selectedIndexes(), QModelIndexList());
+ QCOMPARE(view.selectionModel()->currentIndex(), model.index(2, 0));
+ QCOMPARE(view.selectionModel()->selection().indexes(), QModelIndexList());
+
+
+ QItemSelectionModel selectionModel2(&model);
+ selectionModel2.select(model.index(0, 0), QItemSelectionModel::ClearAndSelect);
+ selectionModel2.setCurrentIndex(model.index(1, 0), QItemSelectionModel::Current);
+
+ view.setSelectionModel(&selectionModel2);
+ QCOMPARE(view.currentIndex(), model.index(1, 0));
+ QCOMPARE(view.selectedIndexes(), QModelIndexList() << model.index(0, 0));
+ QCOMPARE(view.selectionModel()->currentIndex(), model.index(1, 0));
+ QCOMPARE(view.selectionModel()->selection().indexes(), QModelIndexList() << model.index(0, 0));
+}
QTEST_MAIN(tst_QAbstractItemView)
#include "tst_qabstractitemview.moc"
diff --git a/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp b/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp
index a8b0d45ffa..700fa505c1 100644
--- a/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp
+++ b/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp
@@ -83,6 +83,7 @@ private slots:
void clearHistory();
void sourceInsideLoadResource();
void textInteractionFlags_vs_readOnly();
+ void inputMethodAttribute_vs_readOnly();
void anchorsWithSelfBuiltHtml();
void relativeNonLocalUrls();
void adjacentAnchors();
@@ -438,6 +439,16 @@ void tst_QTextBrowser::textInteractionFlags_vs_readOnly()
QCOMPARE(browser->textInteractionFlags(), Qt::TextBrowserInteraction);
}
+void tst_QTextBrowser::inputMethodAttribute_vs_readOnly()
+{
+ QVERIFY(browser->isReadOnly());
+ QVERIFY(!browser->testAttribute(Qt::WA_InputMethodEnabled));
+ browser->setReadOnly(false);
+ QVERIFY(browser->testAttribute(Qt::WA_InputMethodEnabled));
+ browser->setReadOnly(true);
+ QVERIFY(!browser->testAttribute(Qt::WA_InputMethodEnabled));
+}
+
void tst_QTextBrowser::anchorsWithSelfBuiltHtml()
{
browser->setHtml("<p>Hello <a href=\"#anchor\">Link</a>"