Merge remote-tracking branch 'origin/5.11' into dev

Conflicts:
	mkspecs/features/qt_common.prf
	src/corelib/tools/qstring.cpp
	src/plugins/platforms/windows/qwindowsmousehandler.cpp
	src/widgets/widgets/qmainwindowlayout_p.h

Change-Id: I5df613008f6336f69b257d08e49a133d033a9d65
This commit is contained in:
Liang Qi 2018-05-24 16:27:08 +02:00
commit f82e508516
52 changed files with 719 additions and 558 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 65 KiB

After

Width:  |  Height:  |  Size: 112 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 163 KiB

After

Width:  |  Height:  |  Size: 80 KiB

View File

@ -71,8 +71,8 @@ DetailsDialog::DetailsDialog(const QString &title, QWidget *parent)
buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok
| QDialogButtonBox::Cancel); | QDialogButtonBox::Cancel);
connect(buttonBox, SIGNAL(accepted()), this, SLOT(verify())); connect(buttonBox, &QDialogButtonBox::accepted, this, &DetailsDialog::verify);
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); connect(buttonBox, &QDialogButtonBox::rejected, this, &DetailsDialog::reject);
//! [0] //! [0]
//! [1] //! [1]

View File

@ -75,8 +75,8 @@ MainWindow::MainWindow()
letters = new QTabWidget; letters = new QTabWidget;
connect(newAction, SIGNAL(triggered()), this, SLOT(openDialog())); connect(newAction, &QAction::triggered, this, &MainWindow::openDialog);
connect(quitAction, SIGNAL(triggered()), this, SLOT(close())); connect(quitAction, &QAction::triggered, this, &MainWindow::close);
setCentralWidget(letters); setCentralWidget(letters);
setWindowTitle(tr("Order Form")); setWindowTitle(tr("Order Form"));

View File

@ -83,10 +83,10 @@ void EchoWindow::createGUI()
label->setFrameStyle(QFrame::Box | QFrame::Plain); label->setFrameStyle(QFrame::Box | QFrame::Plain);
button = new QPushButton(tr("Send Message")); button = new QPushButton(tr("Send Message"));
connect(lineEdit, SIGNAL(editingFinished()), connect(lineEdit, &QLineEdit::editingFinished,
this, SLOT(sendEcho())); this, &EchoWindow::sendEcho);
connect(button, SIGNAL(clicked()), connect(button, &QPushButton::clicked,
this, SLOT(sendEcho())); this, &EchoWindow::sendEcho);
layout = new QGridLayout; layout = new QGridLayout;
layout->addWidget(new QLabel(tr("Message:")), 0, 0); layout->addWidget(new QLabel(tr("Message:")), 0, 0);

View File

@ -59,7 +59,7 @@ DigitalClock::DigitalClock(QWidget *parent)
setSegmentStyle(Filled); setSegmentStyle(Filled);
QTimer *timer = new QTimer(this); QTimer *timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(showTime())); connect(timer, &QTimer::timeout, this, &DigitalClock::showTime);
timer->start(1000); timer->start(1000);
showTime(); showTime();

View File

@ -95,10 +95,10 @@ warnings_are_errors:warning_clean {
# compiler. # compiler.
clang { clang {
# Apple clang 4.0-4.2,5.0-5.1,6.0-6.4,7.0-7.3,8.0-8.3,9.0-9.2 # Apple clang 4.0-4.2,5.0-5.1,6.0-6.4,7.0-7.3,8.0-8.3,9.0-9.2
# Regular clang 3.x-5.0 # Regular clang 3.x-6.0
apple_ver = $${QT_APPLE_CLANG_MAJOR_VERSION}.$${QT_APPLE_CLANG_MINOR_VERSION} apple_ver = $${QT_APPLE_CLANG_MAJOR_VERSION}.$${QT_APPLE_CLANG_MINOR_VERSION}
reg_ver = $${QT_CLANG_MAJOR_VERSION}.$${QT_CLANG_MINOR_VERSION} reg_ver = $${QT_CLANG_MAJOR_VERSION}.$${QT_CLANG_MINOR_VERSION}
contains(apple_ver, "4\\.[012]|5\\.[01]|6\\.[01234]|7\\.[0123]|8\\.[0123]|9\\.[012]")|contains(reg_ver, "[34]\\.|5\\.0") { contains(apple_ver, "4\\.[012]|5\\.[01]|6\\.[01234]|7\\.[0123]|8\\.[0123]|9\\.[012]")|contains(reg_ver, "[345]\\.|6\\.0") {
QMAKE_CXXFLAGS_WARN_ON += -Werror -Wno-error=\\$${LITERAL_HASH}warnings -Wno-error=deprecated-declarations $$WERROR QMAKE_CXXFLAGS_WARN_ON += -Werror -Wno-error=\\$${LITERAL_HASH}warnings -Wno-error=deprecated-declarations $$WERROR
} }
} else:intel_icc:linux { } else:intel_icc:linux {

View File

@ -361,7 +361,7 @@ public abstract class QtLoader {
inputStream = assetsManager.open(source); inputStream = assetsManager.open(source);
outputStream = new FileOutputStream(destinationFile); outputStream = new FileOutputStream(destinationFile);
copyFile(inputStream, outputStream); copyFile(inputStream, outputStream);
catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} finally { } finally {
if (inputStream != null) if (inputStream != null)
@ -392,7 +392,7 @@ public abstract class QtLoader {
inputStream = new FileInputStream(source); inputStream = new FileInputStream(source);
outputStream = new FileOutputStream(destinationFile); outputStream = new FileOutputStream(destinationFile);
copyFile(inputStream, outputStream); copyFile(inputStream, outputStream);
catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} finally { } finally {
if (inputStream != null) if (inputStream != null)
@ -416,8 +416,13 @@ public abstract class QtLoader {
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} finally { } finally {
if (inputStream != null) if (inputStream != null) {
inputStream.close(); try {
inputStream.close();
} catch (Exception e) {
e.printStackTrace();
}
}
} }
} }
@ -456,7 +461,7 @@ public abstract class QtLoader {
try { try {
outputStream = new DataOutputStream(new FileOutputStream(versionFile)); outputStream = new DataOutputStream(new FileOutputStream(versionFile));
outputStream.writeLong(packageVersion); outputStream.writeLong(packageVersion);
catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} finally { } finally {
if (outputStream != null) if (outputStream != null)

View File

@ -562,7 +562,8 @@
}, },
"linkat": { "linkat": {
"label": "linkat()", "label": "linkat()",
"autoDetect": "config.linux", "comment": "Currently only used by QTemporaryFile; linkat() exists on Android, but hardlink creation fails due to security rules",
"autoDetect": "config.linux && !config.android",
"condition": "tests.linkat", "condition": "tests.linkat",
"output": [ "privateFeature" ] "output": [ "privateFeature" ]
}, },

View File

@ -1334,7 +1334,14 @@
\omitvalue WA_WState_WindowOpacitySet \omitvalue WA_WState_WindowOpacitySet
\omitvalue WA_WState_AcceptedTouchBeginEvent \omitvalue WA_WState_AcceptedTouchBeginEvent
\omitvalue WA_MacNoShadow \omitvalue WA_MacNoShadow
\omitvalue WA_ContentsMarginsRespectsSafeArea \value WA_ContentsMarginsRespectsSafeArea A QWidget respects the safe
area margins of a window by incorporating the margins into its contents'
margins by default. This means, that a QLayout will use the content area
of a widget for its layout, unless the Qt::WA_LayoutOnEntireRect attribute
is set. This along with a contents margin of 0 can be used on the actual
layout, to allow for example a background image to underlay the status bar and other
system areas on an iOS device, while still allowing child widgets of
that background to be inset based on the safe area.
*/ */
/*! \typedef Qt::HANDLE /*! \typedef Qt::HANDLE

View File

@ -114,6 +114,8 @@ static int renameat2(int oldfd, const char *oldpath, int newfd, const char *newp
# if !QT_CONFIG(statx) && defined(SYS_statx) # if !QT_CONFIG(statx) && defined(SYS_statx)
static int statx(int dirfd, const char *pathname, int flag, unsigned mask, struct statx *statxbuf) static int statx(int dirfd, const char *pathname, int flag, unsigned mask, struct statx *statxbuf)
{ return syscall(SYS_statx, dirfd, pathname, flag, mask, statxbuf); } { return syscall(SYS_statx, dirfd, pathname, flag, mask, statxbuf); }
# elif !QT_CONFIG(statx) && !defined(SYS_statx)
# undef STATX_BASIC_STATS
# endif # endif
# endif // !Q_OS_ANDROID # endif // !Q_OS_ANDROID
#endif #endif

View File

@ -4429,6 +4429,7 @@ QDebug operator<<(QDebug dbg, const QObject *o)
/*! /*!
\macro Q_NAMESPACE \macro Q_NAMESPACE
\relates QObject
\since 5.8 \since 5.8
The Q_NAMESPACE macro can be used to add QMetaObject capabilities The Q_NAMESPACE macro can be used to add QMetaObject capabilities

View File

@ -326,38 +326,35 @@ int Value::usedStorage(const Base *b) const
return alignedSize(s); return alignedSize(s);
} }
inline bool isValidValueOffset(uint offset, uint tableOffset)
{
return offset >= sizeof(Base)
&& offset + sizeof(uint) <= tableOffset;
}
bool Value::isValid(const Base *b) const bool Value::isValid(const Base *b) const
{ {
int offset = -1;
switch (type) { switch (type) {
case QJsonValue::Double:
if (latinOrIntValue)
break;
Q_FALLTHROUGH();
case QJsonValue::String:
case QJsonValue::Array:
case QJsonValue::Object:
offset = value;
break;
case QJsonValue::Null: case QJsonValue::Null:
case QJsonValue::Bool: case QJsonValue::Bool:
default:
break;
}
if (offset == -1)
return true; return true;
if (offset + sizeof(uint) > b->tableOffset || offset < (int)sizeof(Base)) case QJsonValue::Double:
return latinOrIntValue || isValidValueOffset(value, b->tableOffset);
case QJsonValue::String:
if (!isValidValueOffset(value, b->tableOffset))
return false;
if (latinOrIntValue)
return asLatin1String(b).isValid(b->tableOffset - value);
return asString(b).isValid(b->tableOffset - value);
case QJsonValue::Array:
return isValidValueOffset(value, b->tableOffset)
&& static_cast<Array *>(base(b))->isValid(b->tableOffset - value);
case QJsonValue::Object:
return isValidValueOffset(value, b->tableOffset)
&& static_cast<Object *>(base(b))->isValid(b->tableOffset - value);
default:
return false; return false;
}
int s = usedStorage(b);
if (s < 0 || s > (int)b->tableOffset - offset)
return false;
if (type == QJsonValue::Array)
return static_cast<Array *>(base(b))->isValid(s);
if (type == QJsonValue::Object)
return static_cast<Object *>(base(b))->isValid(s);
return true;
} }
/*! /*!

View File

@ -107,8 +107,36 @@ Q_GLOBAL_STATIC(QSystemLocaleData, qSystemLocaleData)
#ifndef QT_NO_SYSTEMLOCALE #ifndef QT_NO_SYSTEMLOCALE
static bool contradicts(const QByteArray &maybe, const QByteArray &known)
{
if (maybe.isEmpty())
return false;
/*
If \a known (our current best shot at deciding which language to use)
provides more information (e.g. script, country) than \a maybe (a
candidate to replace \a known) and \a maybe agrees with \a known in what
it does provide, we keep \a known; this happens when \a maybe comes from
LANGUAGE (usually a simple language code) and LANG includes script and/or
country. A textual comparison won't do because, for example, bn (Bengali)
isn't a prefix of ben_IN, but the latter is a refinement of the former.
(Meanwhile, bn is a prefix of bnt, Bantu; and a prefix of ben is be,
Belarusian. There are many more such prefixings between two- and
three-letter codes.)
*/
QLocale::Language langm, langk;
QLocale::Script scriptm, scriptk;
QLocale::Country landm, landk;
QLocalePrivate::getLangAndCountry(maybe, langm, scriptm, landm);
QLocalePrivate::getLangAndCountry(known, langk, scriptk, landk);
return (langm != QLocale::AnyLanguage && langm != langk)
|| (scriptm != QLocale::AnyScript && scriptm != scriptk)
|| (landm != QLocale::AnyCountry && landm != landk);
}
QLocale QSystemLocale::fallbackUiLocale() const QLocale QSystemLocale::fallbackUiLocale() const
{ {
// See man 7 locale for precedence - LC_ALL beats LC_MESSAGES beats LANG:
QByteArray lang = qgetenv("LC_ALL"); QByteArray lang = qgetenv("LC_ALL");
if (lang.isEmpty()) if (lang.isEmpty())
lang = qgetenv("LC_MESSAGES"); lang = qgetenv("LC_MESSAGES");
@ -118,12 +146,12 @@ QLocale QSystemLocale::fallbackUiLocale() const
if (lang.isEmpty() || lang == QByteArray("C") || lang == QByteArray("POSIX")) if (lang.isEmpty() || lang == QByteArray("C") || lang == QByteArray("POSIX"))
return QLocale(QString::fromLatin1(lang)); return QLocale(QString::fromLatin1(lang));
// if the locale is not the "C" locale and LANGUAGE is not empty, return // ... otherwise, if the first part of LANGUAGE says more than or
// the first part of LANGUAGE if LANGUAGE is set and has a first part: // contradicts what we have, use that:
QByteArray language = qgetenv("LANGUAGE"); QByteArray language = qgetenv("LANGUAGE");
if (!language.isEmpty()) { if (!language.isEmpty()) {
language = language.split(':').constFirst(); language = language.split(':').constFirst();
if (!language.isEmpty()) if (contradicts(language, lang))
return QLocale(QString::fromLatin1(language)); return QLocale(QString::fromLatin1(language));
} }

View File

@ -246,7 +246,8 @@ namespace QtSharedPointer {
struct ExternalRefCountWithContiguousData: public ExternalRefCountData struct ExternalRefCountWithContiguousData: public ExternalRefCountData
{ {
typedef ExternalRefCountData Parent; typedef ExternalRefCountData Parent;
T data; typedef typename std::remove_cv<T>::type NoCVType;
NoCVType data;
static void deleter(ExternalRefCountData *self) static void deleter(ExternalRefCountData *self)
{ {
@ -262,7 +263,7 @@ namespace QtSharedPointer {
} }
static void noDeleter(ExternalRefCountData *) { } static void noDeleter(ExternalRefCountData *) { }
static inline ExternalRefCountData *create(T **ptr, DestroyerFn destroy) static inline ExternalRefCountData *create(NoCVType **ptr, DestroyerFn destroy)
{ {
ExternalRefCountWithContiguousData *d = ExternalRefCountWithContiguousData *d =
static_cast<ExternalRefCountWithContiguousData *>(::operator new(sizeof(ExternalRefCountWithContiguousData))); static_cast<ExternalRefCountWithContiguousData *>(::operator new(sizeof(ExternalRefCountWithContiguousData)));
@ -437,10 +438,12 @@ public:
# endif # endif
typename Private::DestroyerFn noDestroy = &Private::noDeleter; typename Private::DestroyerFn noDestroy = &Private::noDeleter;
QSharedPointer result(Qt::Uninitialized); QSharedPointer result(Qt::Uninitialized);
result.d = Private::create(&result.value, noDestroy); typename std::remove_cv<T>::type *ptr;
result.d = Private::create(&ptr, noDestroy);
// now initialize the data // now initialize the data
new (result.data()) T(std::forward<Args>(arguments)...); new (ptr) T(std::forward<Args>(arguments)...);
result.value = ptr;
result.d->destroyer = destroy; result.d->destroyer = destroy;
result.d->setQObjectShared(result.value, true); result.d->setQObjectShared(result.value, true);
# ifdef QT_SHAREDPOINTER_TRACK_POINTERS # ifdef QT_SHAREDPOINTER_TRACK_POINTERS

View File

@ -357,11 +357,20 @@ static bool simdTestMask(const char *&ptr, const char *end, quint32 maskval)
// character. Usually harmless. // character. Usually harmless.
bool qt_is_ascii(const char *&ptr, const char *end) Q_DECL_NOTHROW bool qt_is_ascii(const char *&ptr, const char *end) Q_DECL_NOTHROW
{ {
#if defined(__AVX2__) #if defined(__SSE2__)
if (!simdTestMask(ptr, end, 0x80808080))
return false;
#elif defined(__SSE2__)
// Testing for the high bit can be done efficiently with just PMOVMSKB // Testing for the high bit can be done efficiently with just PMOVMSKB
# if defined(__AVX2__)
while (ptr + 32 <= end) {
__m256i data = _mm256_loadu_si256(reinterpret_cast<const __m256i *>(ptr));
quint32 mask = _mm256_movemask_epi8(data);
if (mask) {
uint idx = qCountTrailingZeroBits(mask);
ptr += idx;
return false;
}
ptr += 32;
}
# endif
while (ptr + 16 <= end) { while (ptr + 16 <= end) {
__m128i data = _mm_loadu_si128(reinterpret_cast<const __m128i *>(ptr)); __m128i data = _mm_loadu_si128(reinterpret_cast<const __m128i *>(ptr));
quint32 mask = _mm_movemask_epi8(data); quint32 mask = _mm_movemask_epi8(data);
@ -778,30 +787,70 @@ static int ucstrncmp(const QChar *a, const QChar *b, size_t l)
} }
#endif // __mips_dsp #endif // __mips_dsp
#ifdef __SSE2__ #ifdef __SSE2__
const char *ptr = reinterpret_cast<const char*>(a); const QChar *end = a + l;
qptrdiff distance = reinterpret_cast<const char*>(b) - ptr; qptrdiff offset = 0;
a += l & ~7;
b += l & ~7;
l &= 7;
// we're going to read ptr[0..15] (16 bytes) // we're going to read a[0..15] and b[0..15] (32 bytes)
for ( ; ptr + 15 < reinterpret_cast<const char *>(a); ptr += 16) { for ( ; a + offset + 16 <= end; offset += 16) {
__m128i a_data = _mm_loadu_si128((const __m128i*)ptr); #ifdef __AVX2__
__m128i b_data = _mm_loadu_si128((const __m128i*)(ptr + distance)); __m256i a_data = _mm256_loadu_si256(reinterpret_cast<const __m256i *>(a + offset));
__m256i b_data = _mm256_loadu_si256(reinterpret_cast<const __m256i *>(b + offset));
__m256i result = _mm256_cmpeq_epi16(a_data, b_data);
uint mask = _mm256_movemask_epi8(result);
#else
__m128i a_data1 = _mm_loadu_si128(reinterpret_cast<const __m128i *>(a + offset));
__m128i a_data2 = _mm_loadu_si128(reinterpret_cast<const __m128i *>(a + offset + 8));
__m128i b_data1 = _mm_loadu_si128(reinterpret_cast<const __m128i *>(b + offset));
__m128i b_data2 = _mm_loadu_si128(reinterpret_cast<const __m128i *>(b + offset + 8));
__m128i result1 = _mm_cmpeq_epi16(a_data1, b_data1);
__m128i result2 = _mm_cmpeq_epi16(a_data2, b_data2);
uint mask = _mm_movemask_epi8(result1) | (_mm_movemask_epi8(result2) << 16);
#endif
mask = ~mask;
if (mask) {
// found a different character
uint idx = qCountTrailingZeroBits(mask);
return a[offset + idx / 2].unicode() - b[offset + idx / 2].unicode();
}
}
// we're going to read a[0..7] and b[0..7] (16 bytes)
if (a + offset + 8 <= end) {
__m128i a_data = _mm_loadu_si128(reinterpret_cast<const __m128i *>(a + offset));
__m128i b_data = _mm_loadu_si128(reinterpret_cast<const __m128i *>(b + offset));
__m128i result = _mm_cmpeq_epi16(a_data, b_data); __m128i result = _mm_cmpeq_epi16(a_data, b_data);
uint mask = ~_mm_movemask_epi8(result); uint mask = ~_mm_movemask_epi8(result);
if (ushort(mask)) { if (ushort(mask)) {
// found a different byte // found a different character
uint idx = qCountTrailingZeroBits(mask); uint idx = qCountTrailingZeroBits(mask);
return reinterpret_cast<const QChar *>(ptr + idx)->unicode() return a[offset + idx / 2].unicode() - b[offset + idx / 2].unicode();
- reinterpret_cast<const QChar *>(ptr + distance + idx)->unicode();
} }
offset += 8;
} }
// we're going to read a[0..3] and b[0..3] (8 bytes)
if (a + offset + 4 <= end) {
__m128i a_data = _mm_loadl_epi64(reinterpret_cast<const __m128i *>(a + offset));
__m128i b_data = _mm_loadl_epi64(reinterpret_cast<const __m128i *>(b + offset));
__m128i result = _mm_cmpeq_epi16(a_data, b_data);
uint mask = ~_mm_movemask_epi8(result);
if (uchar(mask)) {
// found a different character
uint idx = qCountTrailingZeroBits(mask);
return a[offset + idx / 2].unicode() - b[offset + idx / 2].unicode();
}
offset += 4;
}
// reset l
l &= 3;
const auto lambda = [=](size_t i) -> int { const auto lambda = [=](size_t i) -> int {
return reinterpret_cast<const QChar *>(ptr)[i].unicode() return a[offset + i].unicode() - b[offset + i].unicode();
- reinterpret_cast<const QChar *>(ptr + distance)[i].unicode();
}; };
return UnrollTailLoop<7>::exec(l, 0, lambda, lambda); return UnrollTailLoop<3>::exec(l, 0, lambda, lambda);
#endif #endif
#if defined(__ARM_NEON__) && defined(Q_PROCESSOR_ARM_64) // vaddv is only available on Aarch64 #if defined(__ARM_NEON__) && defined(Q_PROCESSOR_ARM_64) // vaddv is only available on Aarch64
if (l >= 8) { if (l >= 8) {

File diff suppressed because it is too large Load Diff

View File

@ -3231,13 +3231,13 @@ static const QRgba64 *QT_FASTCALL fetchTransformedBilinear64(QRgba64 *buffer, co
const qreal px = fx * iw - qreal(0.5); const qreal px = fx * iw - qreal(0.5);
const qreal py = fy * iw - qreal(0.5); const qreal py = fy * iw - qreal(0.5);
int x1 = int(px) - (px < 0); int x1 = qFloor(px);
int x2; int x2;
int y1 = int(py) - (py < 0); int y1 = qFloor(py);
int y2; int y2;
distxs[i] = int((px - x1) * (1<<16)); distxs[i] = qFloor((px - x1) * (1<<16));
distys[i] = int((py - y1) * (1<<16)); distys[i] = qFloor((py - y1) * (1<<16));
fetchTransformedBilinear_pixelBounds<blendType>(image.width, image.x1, image.x2 - 1, x1, x2); fetchTransformedBilinear_pixelBounds<blendType>(image.width, image.x1, image.x2 - 1, x1, x2);
fetchTransformedBilinear_pixelBounds<blendType>(image.height, image.y1, image.y2 - 1, y1, y2); fetchTransformedBilinear_pixelBounds<blendType>(image.height, image.y1, image.y2 - 1, y1, y2);

View File

@ -1150,7 +1150,6 @@ void QHttp2ProtocolHandler::updateStream(Stream &stream, const Frame &frame,
auto &httpRequest = stream.request(); auto &httpRequest = stream.request();
auto replyPrivate = httpReply->d_func(); auto replyPrivate = httpReply->d_func();
replyPrivate->compressedData.append(data, length);
replyPrivate->totalProgress += length; replyPrivate->totalProgress += length;
const QByteArray wrapped(data, length); const QByteArray wrapped(data, length);

View File

@ -924,6 +924,8 @@ static int parseHeaderName(const QByteArray &headerName)
return QNetworkRequest::ContentLengthHeader; return QNetworkRequest::ContentLengthHeader;
else if (qstricmp(headerName.constData(), "cookie") == 0) else if (qstricmp(headerName.constData(), "cookie") == 0)
return QNetworkRequest::CookieHeader; return QNetworkRequest::CookieHeader;
else if (qstricmp(headerName.constData(), "content-disposition") == 0)
return QNetworkRequest::ContentDispositionHeader;
break; break;
case 'e': case 'e':
@ -1048,6 +1050,7 @@ static QVariant parseHeaderValue(QNetworkRequest::KnownHeaders header, const QBy
case QNetworkRequest::UserAgentHeader: case QNetworkRequest::UserAgentHeader:
case QNetworkRequest::ServerHeader: case QNetworkRequest::ServerHeader:
case QNetworkRequest::ContentTypeHeader: case QNetworkRequest::ContentTypeHeader:
case QNetworkRequest::ContentDispositionHeader:
// copy exactly, convert to QString // copy exactly, convert to QString
return QString::fromLatin1(value); return QString::fromLatin1(value);

View File

@ -169,7 +169,7 @@ template <typename Lambda> struct ProcessNetlinkRequest
forever { forever {
qsizetype len = recv(sock, buf, bufsize, 0); qsizetype len = recv(sock, buf, bufsize, 0);
hdr = reinterpret_cast<struct nlmsghdr *>(buf); hdr = reinterpret_cast<struct nlmsghdr *>(buf);
if (!NLMSG_OK(hdr, len)) if (!NLMSG_OK(hdr, quint32(len)))
return; return;
auto arg = reinterpret_cast<FirstArgument>(NLMSG_DATA(hdr)); auto arg = reinterpret_cast<FirstArgument>(NLMSG_DATA(hdr));
@ -194,7 +194,7 @@ template <typename Lambda> struct ProcessNetlinkRequest
hdr = NLMSG_NEXT(hdr, len); hdr = NLMSG_NEXT(hdr, len);
arg = reinterpret_cast<FirstArgument>(NLMSG_DATA(hdr)); arg = reinterpret_cast<FirstArgument>(NLMSG_DATA(hdr));
payloadLen = NLMSG_PAYLOAD(hdr, 0); payloadLen = NLMSG_PAYLOAD(hdr, 0);
} while (NLMSG_OK(hdr, len)); } while (NLMSG_OK(hdr, quint32(len)));
if (len == 0) if (len == 0)
continue; // get new datagram continue; // get new datagram

View File

@ -792,6 +792,53 @@ QFunctionPointer QEGLPlatformContext::getProcAddress(const char *procName)
{ "glVertexAttribIFormat", (QFunctionPointer) ::glVertexAttribIFormat }, { "glVertexAttribIFormat", (QFunctionPointer) ::glVertexAttribIFormat },
{ "glVertexBindingDivisor", (QFunctionPointer) ::glVertexBindingDivisor }, { "glVertexBindingDivisor", (QFunctionPointer) ::glVertexBindingDivisor },
#endif // QT_OPENGL_ES_3_1 #endif // QT_OPENGL_ES_3_1
#ifdef QT_OPENGL_ES_3_2
{ "glBlendBarrier", (QFunctionPointer) ::glBlendBarrier },
{ "glCopyImageSubData", (QFunctionPointer) ::glCopyImageSubData },
{ "glDebugMessageControl", (QFunctionPointer) ::glDebugMessageControl },
{ "glDebugMessageInsert", (QFunctionPointer) ::glDebugMessageInsert },
{ "glDebugMessageCallback", (QFunctionPointer) ::glDebugMessageCallback },
{ "glGetDebugMessageLog", (QFunctionPointer) ::glGetDebugMessageLog },
{ "glPushDebugGroup", (QFunctionPointer) ::glPushDebugGroup },
{ "glPopDebugGroup", (QFunctionPointer) ::glPopDebugGroup },
{ "glObjectLabel", (QFunctionPointer) ::glObjectLabel },
{ "glGetObjectLabel", (QFunctionPointer) ::glGetObjectLabel },
{ "glObjectPtrLabel", (QFunctionPointer) ::glObjectPtrLabel },
{ "glGetObjectPtrLabel", (QFunctionPointer) ::glGetObjectPtrLabel },
{ "glGetPointerv", (QFunctionPointer) ::glGetPointerv },
{ "glEnablei", (QFunctionPointer) ::glEnablei },
{ "glDisablei", (QFunctionPointer) ::glDisablei },
{ "glBlendEquationi", (QFunctionPointer) ::glBlendEquationi },
{ "glBlendEquationSeparatei", (QFunctionPointer) ::glBlendEquationSeparatei },
{ "glBlendFunci", (QFunctionPointer) ::glBlendFunci },
{ "glBlendFuncSeparatei", (QFunctionPointer) ::glBlendFuncSeparatei },
{ "glColorMaski", (QFunctionPointer) ::glColorMaski },
{ "glIsEnabledi", (QFunctionPointer) ::glIsEnabledi },
{ "glDrawElementsBaseVertex", (QFunctionPointer) ::glDrawElementsBaseVertex },
{ "glDrawRangeElementsBaseVertex", (QFunctionPointer) ::glDrawRangeElementsBaseVertex },
{ "glDrawElementsInstancedBaseVertex", (QFunctionPointer) ::glDrawElementsInstancedBaseVertex },
{ "glFramebufferTexture", (QFunctionPointer) ::glFramebufferTexture },
{ "glPrimitiveBoundingBox", (QFunctionPointer) ::glPrimitiveBoundingBox },
{ "glGetGraphicsResetStatus", (QFunctionPointer) ::glGetGraphicsResetStatus },
{ "glReadnPixels", (QFunctionPointer) ::glReadnPixels },
{ "glGetnUniformfv", (QFunctionPointer) ::glGetnUniformfv },
{ "glGetnUniformiv", (QFunctionPointer) ::glGetnUniformiv },
{ "glGetnUniformuiv", (QFunctionPointer) ::glGetnUniformuiv },
{ "glMinSampleShading", (QFunctionPointer) ::glMinSampleShading },
{ "glPatchParameteri", (QFunctionPointer) ::glPatchParameteri },
{ "glTexParameterIiv", (QFunctionPointer) ::glTexParameterIiv },
{ "glTexParameterIuiv", (QFunctionPointer) ::glTexParameterIuiv },
{ "glGetTexParameterIiv", (QFunctionPointer) ::glGetTexParameterIiv },
{ "glGetTexParameterIuiv", (QFunctionPointer) ::glGetTexParameterIuiv },
{ "glSamplerParameterIiv", (QFunctionPointer) ::glSamplerParameterIiv },
{ "glSamplerParameterIuiv", (QFunctionPointer) ::glSamplerParameterIuiv },
{ "glGetSamplerParameterIiv", (QFunctionPointer) ::glGetSamplerParameterIiv },
{ "glGetSamplerParameterIuiv", (QFunctionPointer) ::glGetSamplerParameterIuiv },
{ "glTexBuffer", (QFunctionPointer) ::glTexBuffer },
{ "glTexBufferRange", (QFunctionPointer) ::glTexBufferRange },
{ "glTexStorage3DMultisample", (QFunctionPointer) ::glTexStorage3DMultisample },
#endif // QT_OPENGL_ES_3_2
}; };
for (size_t i = 0; i < sizeof(standardFuncs) / sizeof(StdFunc); ++i) { for (size_t i = 0; i < sizeof(standardFuncs) / sizeof(StdFunc); ++i) {

View File

@ -520,11 +520,25 @@ static bool isValidWheelReceiver(QWindow *candidate)
static void redirectWheelEvent(QWindow *window, const QPoint &globalPos, int delta, static void redirectWheelEvent(QWindow *window, const QPoint &globalPos, int delta,
Qt::Orientation orientation, Qt::KeyboardModifiers mods) Qt::Orientation orientation, Qt::KeyboardModifiers mods)
{ {
// Redirect wheel event to one of the following, in order of preference:
// 1) The window under mouse
// 2) The window receiving the event
// If a window is blocked by modality, it can't get the event. // If a window is blocked by modality, it can't get the event.
if (isValidWheelReceiver(window)) {
QWindow *receiver = QWindowsScreen::windowAt(globalPos, CWP_SKIPINVISIBLE);
while (receiver && receiver->flags().testFlag(Qt::WindowTransparentForInput))
receiver = receiver->parent();
bool handleEvent = true;
if (!isValidWheelReceiver(receiver)) {
receiver = window;
if (!isValidWheelReceiver(receiver))
handleEvent = false;
}
if (handleEvent) {
const QPoint point = (orientation == Qt::Vertical) ? QPoint(0, delta) : QPoint(delta, 0); const QPoint point = (orientation == Qt::Vertical) ? QPoint(0, delta) : QPoint(delta, 0);
QWindowSystemInterface::handleWheelEvent(window, QWindowSystemInterface::handleWheelEvent(receiver,
QWindowsGeometryHint::mapFromGlobal(window, globalPos), QWindowsGeometryHint::mapFromGlobal(receiver, globalPos),
globalPos, QPoint(), point, mods); globalPos, QPoint(), point, mods);
} }
} }

View File

@ -1174,11 +1174,11 @@ void QWindowsWindow::initialize()
const Qt::WindowState state = w->windowState(); const Qt::WindowState state = w->windowState();
if (state != Qt::WindowMaximized && state != Qt::WindowFullScreen if (state != Qt::WindowMaximized && state != Qt::WindowFullScreen
&& creationContext->requestedGeometryIn != creationContext->obtainedGeometry) { && creationContext->requestedGeometryIn != creationContext->obtainedGeometry) {
QWindowSystemInterface::handleGeometryChange(w, creationContext->obtainedGeometry); QWindowSystemInterface::handleGeometryChange<QWindowSystemInterface::SynchronousDelivery>(w, creationContext->obtainedGeometry);
} }
QPlatformScreen *obtainedScreen = screenForGeometry(creationContext->obtainedGeometry); QPlatformScreen *obtainedScreen = screenForGeometry(creationContext->obtainedGeometry);
if (obtainedScreen && screen() != obtainedScreen) if (obtainedScreen && screen() != obtainedScreen)
QWindowSystemInterface::handleWindowScreenChanged(w, obtainedScreen->screen()); QWindowSystemInterface::handleWindowScreenChanged<QWindowSystemInterface::SynchronousDelivery>(w, obtainedScreen->screen());
} }
} }

View File

@ -301,8 +301,10 @@ QXcbCursorCacheKey::QXcbCursorCacheKey(const QCursor &c)
QXcbCursor::QXcbCursor(QXcbConnection *conn, QXcbScreen *screen) QXcbCursor::QXcbCursor(QXcbConnection *conn, QXcbScreen *screen)
: QXcbObject(conn), m_screen(screen), m_gtkCursorThemeInitialized(false) : QXcbObject(conn), m_screen(screen), m_gtkCursorThemeInitialized(false)
{ {
#if QT_CONFIG(cursor)
// see NUM_BITMAPS in libXcursor/src/xcursorint.h // see NUM_BITMAPS in libXcursor/src/xcursorint.h
m_bitmapCache.setMaxCost(8); m_bitmapCache.setMaxCost(8);
#endif
if (cursorCount++) if (cursorCount++)
return; return;

View File

@ -210,7 +210,7 @@ void QFlatpakFileDialog::openPortal()
QRegularExpressionMatch match = regexp.match(filter); QRegularExpressionMatch match = regexp.match(filter);
if (match.hasMatch()) { if (match.hasMatch()) {
QString userVisibleName = match.captured(1); QString userVisibleName = match.captured(1);
QStringList filterStrings = match.captured(2).split(QLatin1String(" ")); QStringList filterStrings = match.captured(2).split(QLatin1Char(' '), QString::SkipEmptyParts);
FilterConditionList filterConditions; FilterConditionList filterConditions;
for (const QString &filterString : filterStrings) { for (const QString &filterString : filterStrings) {

View File

@ -323,7 +323,8 @@ public:
return false; return false;
q->setLastError(QSqlError(QCoreApplication::translate("QIBaseDriver", msg), q->setLastError(QSqlError(QCoreApplication::translate("QIBaseDriver", msg),
imsg, typ, int(sqlcode))); imsg, typ,
sqlcode != -1 ? QString::number(sqlcode) : QString()));
return true; return true;
} }

View File

@ -465,10 +465,10 @@ bool QSQLiteResult::exec()
#if (SQLITE_VERSION_NUMBER >= 3003011) #if (SQLITE_VERSION_NUMBER >= 3003011)
// In the case of the reuse of a named placeholder // In the case of the reuse of a named placeholder
// We need to check explicitly that paramCount is greater than 1, as sqlite // We need to check explicitly that paramCount is greater than or equal to 1, as sqlite
// can end up in a case where for virtual tables it returns 0 even though it // can end up in a case where for virtual tables it returns 0 even though it
// has parameters // has parameters
if (paramCount > 1 && paramCount < values.count()) { if (paramCount >= 1 && paramCount < values.count()) {
const auto countIndexes = [](int counter, const QVector<int> &indexList) { const auto countIndexes = [](int counter, const QVector<int> &indexList) {
return counter + indexList.length(); return counter + indexList.length();
}; };

View File

@ -121,7 +121,6 @@
#include <qwizard.h> #include <qwizard.h>
#endif #endif
#include <qdebug.h> #include <qdebug.h>
#include <qlibrary.h>
#if QT_CONFIG(datetimeedit) #if QT_CONFIG(datetimeedit)
#include <qdatetimeedit.h> #include <qdatetimeedit.h>
#endif #endif

View File

@ -141,7 +141,9 @@ private:
void showEvent(QShowEvent *event) override; void showEvent(QShowEvent *event) override;
friend class QUnixPrintWidgetPrivate; friend class QUnixPrintWidgetPrivate;
#if QT_CONFIG(cups)
QPrinter *m_printer; QPrinter *m_printer;
#endif
Ui::QPrintPropertiesWidget widget; Ui::QPrintPropertiesWidget widget;
QDialogButtonBox *m_buttons; QDialogButtonBox *m_buttons;
#if QT_CONFIG(cupsjobwidget) #if QT_CONFIG(cupsjobwidget)
@ -271,7 +273,9 @@ QPrintPropertiesDialog::QPrintPropertiesDialog(QPrinter *printer, QPrintDevice *
QPrinter::OutputFormat outputFormat, const QString &printerName, QPrinter::OutputFormat outputFormat, const QString &printerName,
QAbstractPrintDialog *parent) QAbstractPrintDialog *parent)
: QDialog(parent) : QDialog(parent)
#if QT_CONFIG(cups)
, m_printer(printer) , m_printer(printer)
#endif
{ {
setWindowTitle(tr("Printer Properties")); setWindowTitle(tr("Printer Properties"));
QVBoxLayout *lay = new QVBoxLayout(this); QVBoxLayout *lay = new QVBoxLayout(this);

View File

@ -587,12 +587,9 @@ void QWin32PrintEngine::drawPixmap(const QRectF &targetRect,
QPixmap p = QPixmap::fromImage(img); QPixmap p = QPixmap::fromImage(img);
HBITMAP hbitmap = qt_pixmapToWinHBITMAP(p, HBitmapNoAlpha); HBITMAP hbitmap = qt_pixmapToWinHBITMAP(p, HBitmapNoAlpha);
HDC display_dc = GetDC(0); HDC hbitmap_hdc = CreateCompatibleDC(d->hdc);
HDC hbitmap_hdc = CreateCompatibleDC(display_dc);
HGDIOBJ null_bitmap = SelectObject(hbitmap_hdc, hbitmap); HGDIOBJ null_bitmap = SelectObject(hbitmap_hdc, hbitmap);
ReleaseDC(0, display_dc);
if (!StretchBlt(d->hdc, qRound(tposx - xform_offset_x), qRound(tposy - xform_offset_y), width, height, if (!StretchBlt(d->hdc, qRound(tposx - xform_offset_x), qRound(tposy - xform_offset_y), width, height,
hbitmap_hdc, 0, 0, p.width(), p.height(), SRCCOPY)) hbitmap_hdc, 0, 0, p.width(), p.height(), SRCCOPY))
qErrnoWarning("QWin32PrintEngine::drawPixmap, StretchBlt failed"); qErrnoWarning("QWin32PrintEngine::drawPixmap, StretchBlt failed");
@ -620,13 +617,10 @@ void QWin32PrintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pm, cons
} else { } else {
int dc_state = SaveDC(d->hdc); int dc_state = SaveDC(d->hdc);
HDC display_dc = GetDC(0);
HBITMAP hbitmap = qt_pixmapToWinHBITMAP(pm, HBitmapNoAlpha); HBITMAP hbitmap = qt_pixmapToWinHBITMAP(pm, HBitmapNoAlpha);
HDC hbitmap_hdc = CreateCompatibleDC(display_dc); HDC hbitmap_hdc = CreateCompatibleDC(d->hdc);
HGDIOBJ null_bitmap = SelectObject(hbitmap_hdc, hbitmap); HGDIOBJ null_bitmap = SelectObject(hbitmap_hdc, hbitmap);
ReleaseDC(0, display_dc);
QRectF trect = d->painterMatrix.mapRect(r); QRectF trect = d->painterMatrix.mapRect(r);
int tx = int(trect.left() * d->stretch_x + d->origin_x); int tx = int(trect.left() * d->stretch_x + d->origin_x);
int ty = int(trect.top() * d->stretch_y + d->origin_y); int ty = int(trect.top() * d->stretch_y + d->origin_y);

View File

@ -1368,12 +1368,12 @@ QSqlRecord QSqlTableModel::record(int row) const
target fields are mapped by field name, not by position in target fields are mapped by field name, not by position in
the record. the record.
Note that the generated flags in \a values are preserved Note that the generated flags in \a values are preserved to
and determine whether the corresponding fields are used when determine whether the corresponding fields are used when changes
changes are submitted to the database. The caller should are submitted to the database. By default, it is set to \c true
remember to set the generated flag to FALSE for fields for all fields in a QSqlRecord. You must set the flag to \c false
where the database is meant to supply the value, such as an using \l{QSqlRecord::}{setGenerated}(false) for any value in
automatically incremented ID. \a values, to save changes back to the database.
For edit strategies OnFieldChange and OnRowChange, a row may For edit strategies OnFieldChange and OnRowChange, a row may
receive a change only if no other row has a cached change. receive a change only if no other row has a cached change.

View File

@ -138,7 +138,7 @@ QTestData *QTestTable::testData(int index) const
return size_t(index) < d->dataList.size() ? d->dataList[index] : nullptr; return size_t(index) < d->dataList.size() ? d->dataList[index] : nullptr;
} }
class NamePredicate : public std::unary_function<QTestTablePrivate::Element, bool> class NamePredicate
{ {
public: public:
explicit NamePredicate(const char *needle) : m_needle(needle) {} explicit NamePredicate(const char *needle) : m_needle(needle) {}

View File

@ -37,7 +37,7 @@
#define QLALR_NO_CHECK_SORTED_TABLE #define QLALR_NO_CHECK_SORTED_TABLE
struct _Fit: public std::binary_function<int, int, bool> struct _Fit
{ {
inline bool operator () (int a, int b) const inline bool operator () (int a, int b) const
{ {
@ -45,7 +45,7 @@ struct _Fit: public std::binary_function<int, int, bool>
} }
}; };
struct _PerfectMatch: public std::binary_function<int, int, bool> struct _PerfectMatch
{ {
inline bool operator () (int a, int b) const inline bool operator () (int a, int b) const
{ return a == b; } { return a == b; }
@ -135,7 +135,7 @@ private:
const_iterator _M_endNonZeros; const_iterator _M_endNonZeros;
}; };
struct _SortUncompressedRow: public std::binary_function<UncompressedRow, UncompressedRow, bool> struct _SortUncompressedRow
{ {
inline bool operator () (const UncompressedRow &a, const UncompressedRow &b) const inline bool operator () (const UncompressedRow &a, const UncompressedRow &b) const
{ return a.count (0) > b.count (0); } { return a.count (0) > b.count (0); }

View File

@ -242,8 +242,9 @@ void Grammar::buildExtendedGrammar ()
non_terminals.insert (accept_symbol); non_terminals.insert (accept_symbol);
} }
struct Nullable: public std::unary_function<Name, bool> struct Nullable
{ {
typedef Name argument_type;
Automaton *_M_automaton; Automaton *_M_automaton;
Nullable (Automaton *aut): Nullable (Automaton *aut):

View File

@ -3513,7 +3513,7 @@ QRect QFusionStyle::subControlRect(ComplexControl control, const QStyleOptionCom
int frameWidth = 2; int frameWidth = 2;
rect = visualRect(option->direction, option->rect, rect); rect = visualRect(option->direction, option->rect, rect);
rect.setRect(option->rect.left() + frameWidth, option->rect.top() + frameWidth, rect.setRect(option->rect.left() + frameWidth, option->rect.top() + frameWidth,
option->rect.width() - 19 - 2 * frameWidth, option->rect.width() - int(QStyleHelper::dpiScaled(19)) - 2 * frameWidth,
option->rect.height() - 2 * frameWidth); option->rect.height() - 2 * frameWidth);
if (const QStyleOptionComboBox *box = qstyleoption_cast<const QStyleOptionComboBox *>(option)) { if (const QStyleOptionComboBox *box = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
if (!box->editable) { if (!box->editable) {

View File

@ -100,7 +100,7 @@ public:
QCursor adjustedCursor; QCursor adjustedCursor;
bool hasOldCursor = false; bool hasOldCursor = false;
bool cursorAdjusted = false; bool cursorAdjusted = false;
#endif #endif // QT_CONFIG(cursor)
QList<int> movingSeparator; QList<int> movingSeparator;
QPoint movingSeparatorOrigin, movingSeparatorPos; QPoint movingSeparatorOrigin, movingSeparatorPos;
@ -110,7 +110,8 @@ public:
bool separatorMove(const QPoint &pos); bool separatorMove(const QPoint &pos);
bool endSeparatorMove(const QPoint &pos); bool endSeparatorMove(const QPoint &pos);
bool windowEvent(QEvent *e); bool windowEvent(QEvent *e);
#endif
#endif // QT_CONFIG(dockwidget)
}; };
@ -203,7 +204,7 @@ bool QMainWindowLayoutSeparatorHelper<Layout>::windowEvent(QEvent *event)
break; break;
} }
#ifndef QT_NO_CURSOR #if QT_CONFIG(cursor)
case QEvent::HoverMove: { case QEvent::HoverMove: {
adjustCursor(static_cast<QHoverEvent *>(event)->pos()); adjustCursor(static_cast<QHoverEvent *>(event)->pos());
break; break;
@ -219,7 +220,7 @@ bool QMainWindowLayoutSeparatorHelper<Layout>::windowEvent(QEvent *event)
case QEvent::ShortcutOverride: // when a menu pops up case QEvent::ShortcutOverride: // when a menu pops up
adjustCursor(QPoint(0, 0)); adjustCursor(QPoint(0, 0));
break; break;
#endif // QT_NO_CURSOR #endif // QT_CONFIG(cursor)
case QEvent::MouseButtonPress: { case QEvent::MouseButtonPress: {
QMouseEvent *e = static_cast<QMouseEvent *>(event); QMouseEvent *e = static_cast<QMouseEvent *>(event);
@ -234,7 +235,7 @@ bool QMainWindowLayoutSeparatorHelper<Layout>::windowEvent(QEvent *event)
case QEvent::MouseMove: { case QEvent::MouseMove: {
QMouseEvent *e = static_cast<QMouseEvent *>(event); QMouseEvent *e = static_cast<QMouseEvent *>(event);
#ifndef QT_NO_CURSOR #if QT_CONFIG(cursor)
adjustCursor(e->pos()); adjustCursor(e->pos());
#endif #endif
if (e->buttons() & Qt::LeftButton) { if (e->buttons() & Qt::LeftButton) {
@ -258,7 +259,7 @@ bool QMainWindowLayoutSeparatorHelper<Layout>::windowEvent(QEvent *event)
break; break;
} }
#if !defined(QT_NO_CURSOR) #if QT_CONFIG(cursor)
case QEvent::CursorChange: case QEvent::CursorChange:
// CursorChange events are triggered as mouse moves to new widgets even // CursorChange events are triggered as mouse moves to new widgets even
// if the cursor doesn't actually change, so do not change oldCursor if // if the cursor doesn't actually change, so do not change oldCursor if
@ -271,7 +272,7 @@ bool QMainWindowLayoutSeparatorHelper<Layout>::windowEvent(QEvent *event)
w->setCursor(adjustedCursor); w->setCursor(adjustedCursor);
} }
break; break;
#endif #endif // QT_CONFIG(cursor)
case QEvent::Timer: case QEvent::Timer:
if (static_cast<QTimerEvent *>(event)->timerId() == separatorMoveTimer.timerId()) { if (static_cast<QTimerEvent *>(event)->timerId() == separatorMoveTimer.timerId()) {
// let's move the separators // let's move the separators
@ -374,7 +375,7 @@ public:
private: private:
QLayout *lay() const { return const_cast<QDockWidgetGroupWindowItem *>(this)->widget()->layout(); } QLayout *lay() const { return const_cast<QDockWidgetGroupWindowItem *>(this)->widget()->layout(); }
}; };
#endif #endif // QT_CONFIG(dockwidget)
/* This data structure represents the state of all the tool-bars and dock-widgets. It's value based /* This data structure represents the state of all the tool-bars and dock-widgets. It's value based
so it can be easilly copied into a temporary variable. All operations are performed without moving so it can be easilly copied into a temporary variable. All operations are performed without moving

View File

@ -2,6 +2,8 @@ CONFIG += testcase
CONFIG -= debug_and_release_target CONFIG -= debug_and_release_target
QT = core-private testlib network QT = core-private testlib network
SOURCES = ../tst_qprocess.cpp SOURCES = ../tst_qprocess.cpp
INCLUDEPATH += ../../../../../shared
HEADERS += ../../../../../shared/emulationdetector.h
TARGET = ../tst_qprocess TARGET = ../tst_qprocess

View File

@ -27,6 +27,7 @@
** **
****************************************************************************/ ****************************************************************************/
#include <emulationdetector.h>
#include <QtTest/QtTest> #include <QtTest/QtTest>
#include <QtCore/QProcess> #include <QtCore/QProcess>
@ -1165,6 +1166,8 @@ void tst_QProcess::processInAThread()
void tst_QProcess::processesInMultipleThreads() void tst_QProcess::processesInMultipleThreads()
{ {
if (EmulationDetector::isRunningArmOnX86())
QSKIP("Flakily hangs in QEMU. QTBUG-67760");
for (int i = 0; i < 10; ++i) { for (int i = 0; i < 10; ++i) {
// run from 1 to 10 threads, but run at least some tests // run from 1 to 10 threads, but run at least some tests
// with more threads than the ideal // with more threads than the ideal

View File

@ -93,6 +93,7 @@ private slots:
void lambdaCustomDeleter(); void lambdaCustomDeleter();
#endif #endif
void creating(); void creating();
void creatingCvQualified();
void creatingVariadic(); void creatingVariadic();
void creatingQObject(); void creatingQObject();
void mixTrackingPointerCode(); void mixTrackingPointerCode();
@ -1771,6 +1772,13 @@ void tst_QSharedPointer::creating()
safetyCheck(); safetyCheck();
} }
void tst_QSharedPointer::creatingCvQualified()
{
auto cptr = QSharedPointer<const Data>::create();
auto vptr = QSharedPointer<volatile Data>::create();
auto cvptr = QSharedPointer<const volatile Data>::create();
}
void tst_QSharedPointer::creatingVariadic() void tst_QSharedPointer::creatingVariadic()
{ {
int i = 42; int i = 42;

View File

@ -469,6 +469,9 @@ void tst_QNetworkRequest::rawHeaderParsing_data()
<< QVariant::fromValue(QList<QNetworkCookie>() << cookie << cookie2) << QVariant::fromValue(QList<QNetworkCookie>() << cookie << cookie2)
<< true << "Set-Cookie" << true << "Set-Cookie"
<< "a=b; path=/\nc=d"; << "a=b; path=/\nc=d";
QTest::newRow("Content-Disposition") << QNetworkRequest::ContentDispositionHeader
<< QVariant("attachment; filename=\"test.txt\"") << true
<< "Content-Disposition" << "attachment; filename=\"test.txt\"";
} }
void tst_QNetworkRequest::rawHeaderParsing() void tst_QNetworkRequest::rawHeaderParsing()

View File

@ -2070,8 +2070,6 @@ void tst_QSqlQuery::prepare_bind_exec()
const QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); const QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db);
const QString qtest_prepare(qTableName("qtest_prepare", __FILE__, db)); const QString qtest_prepare(qTableName("qtest_prepare", __FILE__, db));
if (dbType == QSqlDriver::Interbase && (db.databaseName() == "silence.nokia.troll.no:c:\\ibase\\testdb_ascii" || db.databaseName() == "/opt/interbase/qttest.gdb"))
QSKIP("Can't transliterate extended unicode to ascii");
if (dbType == QSqlDriver::DB2) if (dbType == QSqlDriver::DB2)
QSKIP("Needs someone with more Unicode knowledge than I have to fix"); QSKIP("Needs someone with more Unicode knowledge than I have to fix");
@ -2347,6 +2345,16 @@ void tst_QSqlQuery::prepare_bind_exec()
QCOMPARE(q.value(0).toInt(), 107); QCOMPARE(q.value(0).toInt(), 107);
QCOMPARE(q.value(1).toString(), QString("name")); QCOMPARE(q.value(1).toString(), QString("name"));
QCOMPARE(q.value(2).toString(), QString("107")); QCOMPARE(q.value(2).toString(), QString("107"));
// Test just duplicated placeholders
QVERIFY(q.prepare("insert into " + qtest_prepare + " (id, name, name2) values (110, :name, :name)"));
q.bindValue(":name", "name");
QVERIFY_SQL(q, exec());
QVERIFY(q.exec("select * from " + qtest_prepare + " where id > 109 order by id"));
QVERIFY(q.next());
QCOMPARE(q.value(0).toInt(), 110);
QCOMPARE(q.value(1).toString(), QString("name"));
QCOMPARE(q.value(2).toString(), QString("name"));
} // end of SQLite scope } // end of SQLite scope
} }

View File

@ -494,9 +494,6 @@ void tst_QFiledialog::completer()
QAbstractItemModel *cModel = completer->completionModel(); QAbstractItemModel *cModel = completer->completionModel();
QVERIFY(cModel); QVERIFY(cModel);
//wait a bit
QTest::qWait(500);
// path C:\depot\qt\examples\dialogs\standarddialogs // path C:\depot\qt\examples\dialogs\standarddialogs
// files // files
// [debug] [release] [tmp] dialog dialog main makefile makefile.debug makefile.release standarddialgos // [debug] [release] [tmp] dialog dialog main makefile makefile.debug makefile.release standarddialgos
@ -509,7 +506,7 @@ void tst_QFiledialog::completer()
// \ -> \_viminfo // \ -> \_viminfo
// c:\depot -> 'nothing' // c:\depot -> 'nothing'
// c:\depot\ -> C:\depot\devtools, C:\depot\dteske // c:\depot\ -> C:\depot\devtools, C:\depot\dteske
QCOMPARE(model->index(fd.directory().path()), model->index(startPath)); QTRY_COMPARE(model->index(fd.directory().path()), model->index(startPath));
if (input.isEmpty()) { if (input.isEmpty()) {
// Try to find a suitable directory under root that does not // Try to find a suitable directory under root that does not
@ -1330,7 +1327,6 @@ void tst_QFiledialog::clearLineEdit()
// saving a file the text shouldn't be cleared // saving a file the text shouldn't be cleared
fd.setDirectory(QDir::home()); fd.setDirectory(QDir::home());
QTest::qWait(1000);
#ifdef QT_KEYPAD_NAVIGATION #ifdef QT_KEYPAD_NAVIGATION
list->setEditFocus(true); list->setEditFocus(true);
#endif #endif
@ -1341,8 +1337,7 @@ void tst_QFiledialog::clearLineEdit()
QTest::keyClick(list, Qt::Key_O, Qt::ControlModifier); QTest::keyClick(list, Qt::Key_O, Qt::ControlModifier);
#endif #endif
QTest::qWait(2000); QTRY_VERIFY(fd.directory().absolutePath() != QDir::home().absolutePath());
QVERIFY(fd.directory().absolutePath() != QDir::home().absolutePath());
QVERIFY(!lineEdit->text().isEmpty()); QVERIFY(!lineEdit->text().isEmpty());
// selecting a dir the text should be cleared so one can just hit ok // selecting a dir the text should be cleared so one can just hit ok
@ -1350,7 +1345,6 @@ void tst_QFiledialog::clearLineEdit()
fd.setFileMode(QFileDialog::Directory); fd.setFileMode(QFileDialog::Directory);
fd.setDirectory(QDir::home()); fd.setDirectory(QDir::home());
QTest::qWait(1000);
QTest::keyClick(list, Qt::Key_Down); QTest::keyClick(list, Qt::Key_Down);
#ifndef Q_OS_MAC #ifndef Q_OS_MAC
QTest::keyClick(list, Qt::Key_Return); QTest::keyClick(list, Qt::Key_Return);
@ -1358,8 +1352,7 @@ void tst_QFiledialog::clearLineEdit()
QTest::keyClick(list, Qt::Key_O, Qt::ControlModifier); QTest::keyClick(list, Qt::Key_O, Qt::ControlModifier);
#endif #endif
QTest::qWait(2000); QTRY_VERIFY(fd.directory().absolutePath() != QDir::home().absolutePath());
QVERIFY(fd.directory().absolutePath() != QDir::home().absolutePath());
QVERIFY(lineEdit->text().isEmpty()); QVERIFY(lineEdit->text().isEmpty());
//remove the dir //remove the dir

View File

@ -184,8 +184,7 @@ void tst_QFileDialog2::listRoot()
fd.show(); fd.show();
QCOMPARE(qt_test_isFetchedRoot(),false); QCOMPARE(qt_test_isFetchedRoot(),false);
fd.setDirectory(""); fd.setDirectory("");
QTest::qWait(500); QTRY_COMPARE(qt_test_isFetchedRoot(),true);
QCOMPARE(qt_test_isFetchedRoot(),true);
} }
#endif #endif
@ -231,9 +230,7 @@ void tst_QFileDialog2::deleteDirAndFiles()
delete t; delete t;
FriendlyQFileDialog fd; FriendlyQFileDialog fd;
fd.d_func()->removeDirectory(tempPath); fd.d_func()->removeDirectory(tempPath);
QFileInfo info(tempPath); QTRY_VERIFY(!QFileInfo::exists(tempPath));
QTest::qWait(2000);
QVERIFY(!info.exists());
} }
#endif #endif
@ -551,22 +548,22 @@ void tst_QFileDialog2::task227304_proxyOnFileDialog()
QFileDialog fd(0, "", QDir::currentPath(), 0); QFileDialog fd(0, "", QDir::currentPath(), 0);
fd.setProxyModel(new FilterDirModel(QDir::currentPath())); fd.setProxyModel(new FilterDirModel(QDir::currentPath()));
fd.show(); fd.show();
QVERIFY(QTest::qWaitForWindowActive(&fd));
QLineEdit *edit = fd.findChild<QLineEdit*>("fileNameEdit"); QLineEdit *edit = fd.findChild<QLineEdit*>("fileNameEdit");
QTest::qWait(200); QVERIFY(edit);
QTest::keyClick(edit, Qt::Key_T); QTest::keyClick(edit, Qt::Key_T);
QTest::keyClick(edit, Qt::Key_S); QTest::keyClick(edit, Qt::Key_S);
QTest::qWait(200);
QTest::keyClick(edit->completer()->popup(), Qt::Key_Down); QTest::keyClick(edit->completer()->popup(), Qt::Key_Down);
CrashDialog *dialog = new CrashDialog(0, QString("crash dialog test"), QDir::homePath(), QString("*") ); CrashDialog *dialog = new CrashDialog(0, QString("crash dialog test"), QDir::homePath(), QString("*") );
dialog->setFileMode(QFileDialog::ExistingFile); dialog->setFileMode(QFileDialog::ExistingFile);
dialog->show(); dialog->show();
QVERIFY(QTest::qWaitForWindowActive(dialog));
QListView *list = dialog->findChild<QListView*>("listView"); QListView *list = dialog->findChild<QListView*>("listView");
QTest::qWait(200); QVERIFY(list);
QTest::keyClick(list, Qt::Key_Down); QTest::keyClick(list, Qt::Key_Down);
QTest::keyClick(list, Qt::Key_Return); QTest::keyClick(list, Qt::Key_Return);
QTest::qWait(200);
dialog->close(); dialog->close();
fd.close(); fd.close();
@ -603,21 +600,18 @@ void tst_QFileDialog2::task227930_correctNavigationKeyboardBehavior()
fd.setViewMode(QFileDialog::List); fd.setViewMode(QFileDialog::List);
fd.setDirectory(current.absolutePath()); fd.setDirectory(current.absolutePath());
fd.show(); fd.show();
QVERIFY(QTest::qWaitForWindowActive(&fd));
QListView *list = fd.findChild<QListView*>("listView"); QListView *list = fd.findChild<QListView*>("listView");
QTest::qWait(200); QVERIFY(list);
QTest::keyClick(list, Qt::Key_Down); QTest::keyClick(list, Qt::Key_Down);
QTest::keyClick(list, Qt::Key_Return); QTest::keyClick(list, Qt::Key_Return);
QTest::qWait(200);
QTest::mouseClick(list->viewport(), Qt::LeftButton,0); QTest::mouseClick(list->viewport(), Qt::LeftButton,0);
QTest::keyClick(list, Qt::Key_Down); QTest::keyClick(list, Qt::Key_Down);
QTest::keyClick(list, Qt::Key_Backspace); QTest::keyClick(list, Qt::Key_Backspace);
QTest::qWait(200);
QTest::keyClick(list, Qt::Key_Down); QTest::keyClick(list, Qt::Key_Down);
QTest::keyClick(list, Qt::Key_Down); QTest::keyClick(list, Qt::Key_Down);
QTest::keyClick(list, Qt::Key_Return); QTest::keyClick(list, Qt::Key_Return);
QTest::qWait(200);
QCOMPARE(fd.isVisible(), true); QCOMPARE(fd.isVisible(), true);
QTest::qWait(200);
file.close(); file.close();
file2.close(); file2.close();
file.remove(); file.remove();
@ -734,11 +728,11 @@ void tst_QFileDialog2::task233037_selectingDirectory()
list->setEditFocus(true); list->setEditFocus(true);
#endif #endif
QTest::keyClick(list, Qt::Key_Down); QTest::keyClick(list, Qt::Key_Down);
QTest::qWait(100);
QDialogButtonBox *buttonBox = fd.findChild<QDialogButtonBox*>("buttonBox"); QDialogButtonBox *buttonBox = fd.findChild<QDialogButtonBox*>("buttonBox");
QVERIFY(buttonBox);
QPushButton *button = buttonBox->button(QDialogButtonBox::Save); QPushButton *button = buttonBox->button(QDialogButtonBox::Save);
QVERIFY(button); QVERIFY(button);
QCOMPARE(button->isEnabled(), true); QVERIFY(button->isEnabled());
current.rmdir("test"); current.rmdir("test");
} }
@ -766,10 +760,10 @@ void tst_QFileDialog2::task235069_hideOnEscape()
fd.setDirectory(current.absolutePath()); fd.setDirectory(current.absolutePath());
fd.setAcceptMode(QFileDialog::AcceptSave); fd.setAcceptMode(QFileDialog::AcceptSave);
fd.show(); fd.show();
QVERIFY(QTest::qWaitForWindowActive(&fd));
QWidget *child = fd.findChild<QWidget *>(childName); QWidget *child = fd.findChild<QWidget *>(childName);
QVERIFY(child); QVERIFY(child);
child->setFocus(); child->setFocus();
QTest::qWait(200);
QTest::keyClick(child, Qt::Key_Escape); QTest::keyClick(child, Qt::Key_Escape);
QCOMPARE(fd.isVisible(), false); QCOMPARE(fd.isVisible(), false);
QCOMPARE(spyFinished.count(), 1); // QTBUG-7690 QCOMPARE(spyFinished.count(), 1); // QTBUG-7690
@ -788,14 +782,13 @@ void tst_QFileDialog2::task236402_dontWatchDeletedDir()
fd.setDirectory(current.absolutePath()); fd.setDirectory(current.absolutePath());
fd.setAcceptMode( QFileDialog::AcceptSave); fd.setAcceptMode( QFileDialog::AcceptSave);
fd.show(); fd.show();
QVERIFY(QTest::qWaitForWindowActive(&fd));
QListView *list = fd.findChild<QListView*>("listView"); QListView *list = fd.findChild<QListView*>("listView");
QVERIFY(list);
list->setFocus(); list->setFocus();
QTest::qWait(200);
QTest::keyClick(list, Qt::Key_Return); QTest::keyClick(list, Qt::Key_Return);
QTest::qWait(200);
QTest::keyClick(list, Qt::Key_Backspace); QTest::keyClick(list, Qt::Key_Backspace);
QTest::keyClick(list, Qt::Key_Down); QTest::keyClick(list, Qt::Key_Down);
QTest::qWait(200);
fd.d_func()->removeDirectory(current.absolutePath() + "/aaaaaaaaaa/"); fd.d_func()->removeDirectory(current.absolutePath() + "/aaaaaaaaaa/");
QTest::qWait(1000); QTest::qWait(1000);
} }
@ -810,16 +803,16 @@ void tst_QFileDialog2::task203703_returnProperSeparator()
fd.setViewMode(QFileDialog::List); fd.setViewMode(QFileDialog::List);
fd.setFileMode(QFileDialog::Directory); fd.setFileMode(QFileDialog::Directory);
fd.show(); fd.show();
QTest::qWait(500); QVERIFY(QTest::qWaitForWindowActive(&fd));
QListView *list = fd.findChild<QListView*>("listView"); QListView *list = fd.findChild<QListView*>("listView");
QVERIFY(list);
list->setFocus(); list->setFocus();
QTest::qWait(200);
QTest::keyClick(list, Qt::Key_Return); QTest::keyClick(list, Qt::Key_Return);
QTest::qWait(1000);
QDialogButtonBox *buttonBox = fd.findChild<QDialogButtonBox*>("buttonBox"); QDialogButtonBox *buttonBox = fd.findChild<QDialogButtonBox*>("buttonBox");
QVERIFY(buttonBox);
QPushButton *button = buttonBox->button(QDialogButtonBox::Cancel); QPushButton *button = buttonBox->button(QDialogButtonBox::Cancel);
QVERIFY(button);
QTest::keyClick(button, Qt::Key_Return); QTest::keyClick(button, Qt::Key_Return);
QTest::qWait(500);
QString result = fd.selectedFiles().first(); QString result = fd.selectedFiles().first();
QVERIFY(result.at(result.count() - 1) != '/'); QVERIFY(result.at(result.count() - 1) != '/');
QVERIFY(!result.contains('\\')); QVERIFY(!result.contains('\\'));
@ -846,47 +839,52 @@ void tst_QFileDialog2::task228844_ensurePreviousSorting()
fd.setDirectory(current.absolutePath()); fd.setDirectory(current.absolutePath());
fd.setViewMode(QFileDialog::Detail); fd.setViewMode(QFileDialog::Detail);
fd.show(); fd.show();
QTest::qWait(500); QVERIFY(QTest::qWaitForWindowActive(&fd));
QTreeView *tree = fd.findChild<QTreeView*>("treeView"); QTreeView *tree = fd.findChild<QTreeView*>("treeView");
QVERIFY(tree);
tree->header()->setSortIndicator(3,Qt::DescendingOrder); tree->header()->setSortIndicator(3,Qt::DescendingOrder);
QTest::qWait(200);
QDialogButtonBox *buttonBox = fd.findChild<QDialogButtonBox*>("buttonBox"); QDialogButtonBox *buttonBox = fd.findChild<QDialogButtonBox*>("buttonBox");
QVERIFY(buttonBox);
QPushButton *button = buttonBox->button(QDialogButtonBox::Open); QPushButton *button = buttonBox->button(QDialogButtonBox::Open);
QVERIFY(button);
QTest::mouseClick(button, Qt::LeftButton); QTest::mouseClick(button, Qt::LeftButton);
QTest::qWait(500);
QFileDialog fd2; QFileDialog fd2;
fd2.setFileMode(QFileDialog::Directory); fd2.setFileMode(QFileDialog::Directory);
fd2.restoreState(fd.saveState()); fd2.restoreState(fd.saveState());
current.cd("aaaaaaaaaaaaaaaaaa"); current.cd("aaaaaaaaaaaaaaaaaa");
fd2.setDirectory(current.absolutePath()); fd2.setDirectory(current.absolutePath());
fd2.show(); fd2.show();
QTest::qWait(500); QVERIFY(QTest::qWaitForWindowActive(&fd2));
QTreeView *tree2 = fd2.findChild<QTreeView*>("treeView"); QTreeView *tree2 = fd2.findChild<QTreeView*>("treeView");
QVERIFY(tree2);
tree2->setFocus(); tree2->setFocus();
QCOMPARE(tree2->rootIndex().data(QFileSystemModel::FilePathRole).toString(),current.absolutePath()); QCOMPARE(tree2->rootIndex().data(QFileSystemModel::FilePathRole).toString(),current.absolutePath());
QDialogButtonBox *buttonBox2 = fd2.findChild<QDialogButtonBox*>("buttonBox"); QDialogButtonBox *buttonBox2 = fd2.findChild<QDialogButtonBox*>("buttonBox");
QVERIFY(buttonBox2);
QPushButton *button2 = buttonBox2->button(QDialogButtonBox::Open); QPushButton *button2 = buttonBox2->button(QDialogButtonBox::Open);
QVERIFY(button2);
fd2.selectFile("g"); fd2.selectFile("g");
QTest::mouseClick(button2, Qt::LeftButton); QTest::mouseClick(button2, Qt::LeftButton);
QTest::qWait(500);
QCOMPARE(fd2.selectedFiles().first(), current.absolutePath() + QLatin1String("/g")); QCOMPARE(fd2.selectedFiles().first(), current.absolutePath() + QLatin1String("/g"));
QFileDialog fd3(0, "This is a third file dialog", tempFile->fileName()); QFileDialog fd3(0, "This is a third file dialog", tempFile->fileName());
fd3.restoreState(fd.saveState()); fd3.restoreState(fd.saveState());
fd3.setFileMode(QFileDialog::Directory); fd3.setFileMode(QFileDialog::Directory);
fd3.show(); fd3.show();
QTest::qWait(500); QVERIFY(QTest::qWaitForWindowActive(&fd3));
QTreeView *tree3 = fd3.findChild<QTreeView*>("treeView"); QTreeView *tree3 = fd3.findChild<QTreeView*>("treeView");
QVERIFY(tree3);
tree3->setFocus(); tree3->setFocus();
QCOMPARE(tree3->rootIndex().data(QFileSystemModel::FilePathRole).toString(), current.absolutePath()); QCOMPARE(tree3->rootIndex().data(QFileSystemModel::FilePathRole).toString(), current.absolutePath());
QDialogButtonBox *buttonBox3 = fd3.findChild<QDialogButtonBox*>("buttonBox"); QDialogButtonBox *buttonBox3 = fd3.findChild<QDialogButtonBox*>("buttonBox");
QVERIFY(buttonBox3);
QPushButton *button3 = buttonBox3->button(QDialogButtonBox::Open); QPushButton *button3 = buttonBox3->button(QDialogButtonBox::Open);
QVERIFY(button3);
QTest::mouseClick(button3, Qt::LeftButton); QTest::mouseClick(button3, Qt::LeftButton);
QTest::qWait(500);
QCOMPARE(fd3.selectedFiles().first(), tempFile->fileName()); QCOMPARE(fd3.selectedFiles().first(), tempFile->fileName());
current.cd("aaaaaaaaaaaaaaaaaa"); current.cd("aaaaaaaaaaaaaaaaaa");
@ -908,9 +906,8 @@ void tst_QFileDialog2::task239706_editableFilterCombo()
{ {
QFileDialog d; QFileDialog d;
d.setNameFilter("*.cpp *.h"); d.setNameFilter("*.cpp *.h");
d.show(); d.show();
QTest::qWait(500); QVERIFY(QTest::qWaitForWindowActive(&d));
QList<QComboBox *> comboList = d.findChildren<QComboBox *>(); QList<QComboBox *> comboList = d.findChildren<QComboBox *>();
QComboBox *filterCombo = 0; QComboBox *filterCombo = 0;
@ -961,9 +958,10 @@ void tst_QFileDialog2::task251321_sideBarHiddenEntries()
urls << QUrl::fromLocalFile(hiddenSubDir.absolutePath()); urls << QUrl::fromLocalFile(hiddenSubDir.absolutePath());
fd.setSidebarUrls(urls); fd.setSidebarUrls(urls);
fd.show(); fd.show();
QTest::qWait(250); QVERIFY(QTest::qWaitForWindowActive(&fd));
QSidebar *sidebar = fd.findChild<QSidebar*>("sidebar"); QSidebar *sidebar = fd.findChild<QSidebar*>("sidebar");
QVERIFY(sidebar);
sidebar->setFocus(); sidebar->setFocus();
sidebar->selectUrl(QUrl::fromLocalFile(hiddenSubDir.absolutePath())); sidebar->selectUrl(QUrl::fromLocalFile(hiddenSubDir.absolutePath()));
QTest::mouseClick(sidebar->viewport(), Qt::LeftButton, 0, sidebar->visualRect(sidebar->model()->index(0, 0)).center()); QTest::mouseClick(sidebar->viewport(), Qt::LeftButton, 0, sidebar->visualRect(sidebar->model()->index(0, 0)).center());
@ -1014,16 +1012,17 @@ void tst_QFileDialog2::task251341_sideBarRemoveEntries()
urls << QUrl::fromLocalFile("NotFound"); urls << QUrl::fromLocalFile("NotFound");
fd.setSidebarUrls(urls); fd.setSidebarUrls(urls);
fd.show(); fd.show();
QTest::qWait(250); QVERIFY(QTest::qWaitForWindowActive(&fd));
QSidebar *sidebar = fd.findChild<QSidebar*>("sidebar"); QSidebar *sidebar = fd.findChild<QSidebar*>("sidebar");
QVERIFY(sidebar);
sidebar->setFocus(); sidebar->setFocus();
//We enter in the first bookmark //We enter in the first bookmark
sidebar->selectUrl(QUrl::fromLocalFile(testSubDir.absolutePath())); sidebar->selectUrl(QUrl::fromLocalFile(testSubDir.absolutePath()));
QTest::mouseClick(sidebar->viewport(), Qt::LeftButton, 0, sidebar->visualRect(sidebar->model()->index(0, 0)).center()); QTest::mouseClick(sidebar->viewport(), Qt::LeftButton, 0, sidebar->visualRect(sidebar->model()->index(0, 0)).center());
QTest::qWait(250);
QFileSystemModel *model = fd.findChild<QFileSystemModel*>("qt_filesystem_model"); QFileSystemModel *model = fd.findChild<QFileSystemModel*>("qt_filesystem_model");
QVERIFY(model);
//There is no file //There is no file
QCOMPARE(model->rowCount(model->index(testSubDir.absolutePath())), 0); QCOMPARE(model->rowCount(model->index(testSubDir.absolutePath())), 0);
//Icon is not enabled QUrlModel::EnabledRole //Icon is not enabled QUrlModel::EnabledRole
@ -1034,7 +1033,6 @@ void tst_QFileDialog2::task251341_sideBarRemoveEntries()
//We enter in the second bookmark which is invalid //We enter in the second bookmark which is invalid
sidebar->selectUrl(QUrl::fromLocalFile("NotFound")); sidebar->selectUrl(QUrl::fromLocalFile("NotFound"));
QTest::mouseClick(sidebar->viewport(), Qt::LeftButton, 0, sidebar->visualRect(sidebar->model()->index(1, 0)).center()); QTest::mouseClick(sidebar->viewport(), Qt::LeftButton, 0, sidebar->visualRect(sidebar->model()->index(1, 0)).center());
QTest::qWait(250);
//We fallback to root because the entry in the bookmark is invalid //We fallback to root because the entry in the bookmark is invalid
QCOMPARE(model->rowCount(model->index("NotFound")), model->rowCount(model->index(model->rootPath()))); QCOMPARE(model->rowCount(model->index("NotFound")), model->rowCount(model->index(model->rootPath())));
@ -1086,7 +1084,7 @@ void tst_QFileDialog2::task254490_selectFileMultipleTimes()
fd.selectFile("new_file.txt"); fd.selectFile("new_file.txt");
fd.show(); fd.show();
QTest::qWait(250); QVERIFY(QTest::qWaitForWindowActive(&fd));
QLineEdit *lineEdit = fd.findChild<QLineEdit*>("fileNameEdit"); QLineEdit *lineEdit = fd.findChild<QLineEdit*>("fileNameEdit");
QVERIFY(lineEdit); QVERIFY(lineEdit);
@ -1130,7 +1128,7 @@ void tst_QFileDialog2::task259105_filtersCornerCases()
fd.setNameFilter(QLatin1String("All Files! (*);;Text Files (*.txt)")); fd.setNameFilter(QLatin1String("All Files! (*);;Text Files (*.txt)"));
fd.setOption(QFileDialog::HideNameFilterDetails, true); fd.setOption(QFileDialog::HideNameFilterDetails, true);
fd.show(); fd.show();
QTest::qWait(250); QVERIFY(QTest::qWaitForWindowActive(&fd));
//Extensions are hidden //Extensions are hidden
QComboBox *filters = fd.findChild<QComboBox*>("fileTypeCombo"); QComboBox *filters = fd.findChild<QComboBox*>("fileTypeCombo");
@ -1141,7 +1139,6 @@ void tst_QFileDialog2::task259105_filtersCornerCases()
//We should have the full names //We should have the full names
fd.setOption(QFileDialog::HideNameFilterDetails, false); fd.setOption(QFileDialog::HideNameFilterDetails, false);
QTest::qWait(250);
filters->setCurrentIndex(0); filters->setCurrentIndex(0);
QCOMPARE(filters->currentText(), QLatin1String("All Files! (*)")); QCOMPARE(filters->currentText(), QLatin1String("All Files! (*)"));
filters->setCurrentIndex(1); filters->setCurrentIndex(1);
@ -1155,14 +1152,12 @@ void tst_QFileDialog2::task259105_filtersCornerCases()
fd.setOption(QFileDialog::HideNameFilterDetails, true); fd.setOption(QFileDialog::HideNameFilterDetails, true);
filters->setCurrentIndex(0); filters->setCurrentIndex(0);
QTest::qWait(500);
QCOMPARE(filters->currentText(), QLatin1String("\352 (I like cheese) All Files!")); QCOMPARE(filters->currentText(), QLatin1String("\352 (I like cheese) All Files!"));
filters->setCurrentIndex(1); filters->setCurrentIndex(1);
QCOMPARE(filters->currentText(), QLatin1String("Text Files")); QCOMPARE(filters->currentText(), QLatin1String("Text Files"));
fd.setOption(QFileDialog::HideNameFilterDetails, true); fd.setOption(QFileDialog::HideNameFilterDetails, true);
filters->setCurrentIndex(0); filters->setCurrentIndex(0);
QTest::qWait(500);
QCOMPARE(filters->currentText(), QLatin1String("\352 (I like cheese) All Files!")); QCOMPARE(filters->currentText(), QLatin1String("\352 (I like cheese) All Files!"));
filters->setCurrentIndex(1); filters->setCurrentIndex(1);
QCOMPARE(filters->currentText(), QLatin1String("Text Files")); QCOMPARE(filters->currentText(), QLatin1String("Text Files"));

View File

@ -176,15 +176,12 @@ void tst_QFileSystemModel::indexPath()
#if !defined(Q_OS_WIN) #if !defined(Q_OS_WIN)
int depth = QDir::currentPath().count('/'); int depth = QDir::currentPath().count('/');
model->setRootPath(QDir::currentPath()); model->setRootPath(QDir::currentPath());
QTest::qWait(WAITTIME);
QString backPath; QString backPath;
for (int i = 0; i <= depth * 2 + 1; ++i) { for (int i = 0; i <= depth * 2 + 1; ++i) {
backPath += "../"; backPath += "../";
QModelIndex idx = model->index(backPath); QModelIndex idx = model->index(backPath);
QVERIFY(i != depth - 1 ? idx.isValid() : !idx.isValid()); QVERIFY(i != depth - 1 ? idx.isValid() : !idx.isValid());
} }
QTest::qWait(WAITTIME * 3);
qApp->processEvents();
#endif #endif
} }
@ -296,9 +293,7 @@ void tst_QFileSystemModel::iconProvider()
QVERIFY(!documentPaths.isEmpty()); QVERIFY(!documentPaths.isEmpty());
const QString documentPath = documentPaths.front(); const QString documentPath = documentPaths.front();
myModel->setRootPath(documentPath); myModel->setRootPath(documentPath);
//Let's wait to populate the model //We change the provider, icons must be updated
QTest::qWait(250);
//We change the provider, icons must me updated
CustomFileIconProvider *custom = new CustomFileIconProvider(); CustomFileIconProvider *custom = new CustomFileIconProvider();
myModel->setIconProvider(custom); myModel->setIconProvider(custom);
@ -421,7 +416,6 @@ void tst_QFileSystemModel::rowsInserted()
for (int i = 0; i < count; ++i) for (int i = 0; i < count; ++i)
files.append(QLatin1Char('c') + QString::number(i)); files.append(QLatin1Char('c') + QString::number(i));
QVERIFY(createFiles(tmp, files, 5)); QVERIFY(createFiles(tmp, files, 5));
TRY_WAIT(model->rowCount(root) == oldCount + count);
QTRY_COMPARE(model->rowCount(root), oldCount + count); QTRY_COMPARE(model->rowCount(root), oldCount + count);
int totalRowsInserted = 0; int totalRowsInserted = 0;
for (int i = 0; i < spy0.count(); ++i) { for (int i = 0; i < spy0.count(); ++i) {
@ -467,7 +461,6 @@ void tst_QFileSystemModel::rowsRemoved()
QFETCH(int, count); QFETCH(int, count);
QFETCH(int, ascending); QFETCH(int, ascending);
model->sort(0, (Qt::SortOrder)ascending); model->sort(0, (Qt::SortOrder)ascending);
QTest::qWait(WAITTIME);
QSignalSpy spy0(model, SIGNAL(rowsRemoved(QModelIndex,int,int))); QSignalSpy spy0(model, SIGNAL(rowsRemoved(QModelIndex,int,int)));
QSignalSpy spy1(model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int))); QSignalSpy spy1(model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)));
@ -477,8 +470,6 @@ void tst_QFileSystemModel::rowsRemoved()
QVERIFY(QFile::remove(tmp + '/' + model->index(i, 0, root).data().toString())); QVERIFY(QFile::remove(tmp + '/' + model->index(i, 0, root).data().toString()));
} }
for (int i = 0 ; i < 10; ++i) { for (int i = 0 ; i < 10; ++i) {
QTest::qWait(WAITTIME);
qApp->processEvents();
if (count != 0) { if (count != 0) {
if (i == 10 || spy0.count() != 0) { if (i == 10 || spy0.count() != 0) {
QVERIFY(spy0.count() >= 1); QVERIFY(spy0.count() >= 1);
@ -504,7 +495,6 @@ void tst_QFileSystemModel::rowsRemoved()
QVERIFY(QFile::exists(tmp + '/' + QString(".a"))); QVERIFY(QFile::exists(tmp + '/' + QString(".a")));
QVERIFY(QFile::remove(tmp + '/' + QString(".a"))); QVERIFY(QFile::remove(tmp + '/' + QString(".a")));
QVERIFY(QFile::remove(tmp + '/' + QString(".c"))); QVERIFY(QFile::remove(tmp + '/' + QString(".c")));
QTest::qWait(WAITTIME);
if (count != 0) QVERIFY(spy0.count() >= 1); else QCOMPARE(spy0.count(), 0); if (count != 0) QVERIFY(spy0.count() >= 1); else QCOMPARE(spy0.count(), 0);
if (count != 0) QVERIFY(spy1.count() >= 1); else QCOMPARE(spy1.count(), 0); if (count != 0) QVERIFY(spy1.count() >= 1); else QCOMPARE(spy1.count(), 0);
@ -517,10 +507,8 @@ void tst_QFileSystemModel::dataChanged_data()
void tst_QFileSystemModel::dataChanged() void tst_QFileSystemModel::dataChanged()
{ {
// This can't be tested right now sense we don't watch files, only directories QSKIP("This can't be tested right now since we don't watch files, only directories.");
return;
/*
QString tmp = flatDirTestPath; QString tmp = flatDirTestPath;
rowCount(); rowCount();
QModelIndex root = model->index(model->rootPath()); QModelIndex root = model->index(model->rootPath());
@ -538,7 +526,6 @@ void tst_QFileSystemModel::dataChanged()
QTest::qWait(WAITTIME); QTest::qWait(WAITTIME);
if (count != 0) QVERIFY(spy.count() >= 1); else QCOMPARE(spy.count(), 0); if (count != 0) QVERIFY(spy.count() >= 1); else QCOMPARE(spy.count(), 0);
*/
} }
void tst_QFileSystemModel::filters_data() void tst_QFileSystemModel::filters_data()
@ -796,7 +783,7 @@ void tst_QFileSystemModel::sort()
tree->setModel(myModel); tree->setModel(myModel);
tree->show(); tree->show();
tree->resize(800, 800); tree->resize(800, 800);
QTest::qWait(500); QVERIFY(QTest::qWaitForWindowActive(tree));
tree->header()->setSortIndicator(1,Qt::DescendingOrder); tree->header()->setSortIndicator(1,Qt::DescendingOrder);
tree->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents); tree->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
QStringList dirsToOpen; QStringList dirsToOpen;
@ -807,16 +794,15 @@ void tst_QFileSystemModel::sort()
for (int i = dirsToOpen.size() -1 ; i > 0 ; --i) { for (int i = dirsToOpen.size() -1 ; i > 0 ; --i) {
QString path = dirsToOpen[i]; QString path = dirsToOpen[i];
QTest::qWait(500);
tree->expand(myModel->index(path, 0)); tree->expand(myModel->index(path, 0));
} }
tree->expand(myModel->index(dirPath, 0)); tree->expand(myModel->index(dirPath, 0));
QTest::qWait(500);
QModelIndex parent = myModel->index(dirPath, 0); QModelIndex parent = myModel->index(dirPath, 0);
QList<QString> expectedOrder; QList<QString> expectedOrder;
expectedOrder << tempFile2.fileName() << tempFile.fileName() << dirPath + QChar('/') + ".." << dirPath + QChar('/') + "."; expectedOrder << tempFile2.fileName() << tempFile.fileName() << dirPath + QChar('/') + ".." << dirPath + QChar('/') + ".";
if (fileDialogMode) { if (fileDialogMode) {
QTRY_COMPARE(myModel->rowCount(parent), expectedOrder.count());
// File dialog Mode means sub trees are not sorted, only the current root. // File dialog Mode means sub trees are not sorted, only the current root.
// There's no way we can check that the sub tree is "not sorted"; just check if it // There's no way we can check that the sub tree is "not sorted"; just check if it
// has the same contents of the expected list // has the same contents of the expected list
@ -858,8 +844,8 @@ void tst_QFileSystemModel::mkdir()
QModelIndex idx = model->mkdir(tmpDir, "NewFoldermkdirtest4"); QModelIndex idx = model->mkdir(tmpDir, "NewFoldermkdirtest4");
QVERIFY(idx.isValid()); QVERIFY(idx.isValid());
int oldRow = idx.row(); int oldRow = idx.row();
QTest::qWait(WAITTIME);
idx = model->index(newFolderPath); idx = model->index(newFolderPath);
QVERIFY(idx.isValid());
QVERIFY(model->remove(idx)); QVERIFY(model->remove(idx));
QVERIFY(!bestatic.exists()); QVERIFY(!bestatic.exists());
QVERIFY(0 != idx.row()); QVERIFY(0 != idx.row());
@ -981,7 +967,6 @@ void tst_QFileSystemModel::drives()
foreach(const QFileInfo& driveRoot, drives) foreach(const QFileInfo& driveRoot, drives)
if (driveRoot.exists()) if (driveRoot.exists())
driveCount++; driveCount++;
QTest::qWait(5000);
QTRY_COMPARE(model.rowCount(), driveCount); QTRY_COMPARE(model.rowCount(), driveCount);
} }
@ -989,7 +974,8 @@ void tst_QFileSystemModel::dirsBeforeFiles()
{ {
QDir dir(flatDirTestPath); QDir dir(flatDirTestPath);
for (int i = 0; i < 3; ++i) { const int itemCount = 3;
for (int i = 0; i < itemCount; ++i) {
QLatin1Char c('a' + i); QLatin1Char c('a' + i);
dir.mkdir(c + QLatin1String("-dir")); dir.mkdir(c + QLatin1String("-dir"));
QFile file(flatDirTestPath + QLatin1Char('/') + c + QLatin1String("-file")); QFile file(flatDirTestPath + QLatin1Char('/') + c + QLatin1String("-file"));
@ -998,7 +984,8 @@ void tst_QFileSystemModel::dirsBeforeFiles()
} }
QModelIndex root = model->setRootPath(flatDirTestPath); QModelIndex root = model->setRootPath(flatDirTestPath);
QTest::qWait(1000); // allow model to be notified by the file system watcher // Wait for model to be notified by the file system watcher
QTRY_COMPARE(model->rowCount(root), 2 * itemCount);
// ensure that no file occurs before a directory // ensure that no file occurs before a directory
for (int i = 0; i < model->rowCount(root); ++i) { for (int i = 0; i < model->rowCount(root); ++i) {

View File

@ -197,8 +197,7 @@ void tst_QProgressDialog::task198202()
dlg.setLabel(0); dlg.setLabel(0);
QTest::ignoreMessage(QtWarningMsg, "QProgressDialog::setBar: Cannot set a null progress bar"); QTest::ignoreMessage(QtWarningMsg, "QProgressDialog::setBar: Cannot set a null progress bar");
dlg.setBar(0); dlg.setBar(0);
QTest::qWait(20); QTRY_COMPARE(dlg.sizeHint().height(), futureHeight);
QCOMPARE(dlg.sizeHint().height(), futureHeight);
} }
void tst_QProgressDialog::QTBUG_31046() void tst_QProgressDialog::QTBUG_31046()

View File

@ -167,6 +167,12 @@ void tst_QCommandLinkButton::onReleased()
void tst_QCommandLinkButton::setAutoRepeat() void tst_QCommandLinkButton::setAutoRepeat()
{ {
// Give the last tests time to finish - i.e., wait for the window close and
// deactivate to avoid a race condition here. We can't add this to the end
// of the defaultAndAutoDefault test, since any failure in that test will
// return out of that function.
QTest::qWait(1000);
// If this changes, this test must be completely revised. // If this changes, this test must be completely revised.
QVERIFY( !testWidget->isCheckable() ); QVERIFY( !testWidget->isCheckable() );
@ -421,8 +427,7 @@ void tst_QCommandLinkButton::defaultAndAutoDefault()
QVERIFY(dialog.isVisible()); QVERIFY(dialog.isVisible());
QObject::connect(&button1, SIGNAL(clicked()), &dialog, SLOT(hide())); QObject::connect(&button1, SIGNAL(clicked()), &dialog, SLOT(hide()));
QKeyEvent event(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier); QTest::keyClick(&dialog, Qt::Key_Return);
QApplication::sendEvent(&dialog, &event);
QVERIFY(!dialog.isVisible()); QVERIFY(!dialog.isVisible());
} }
@ -462,8 +467,7 @@ void tst_QCommandLinkButton::defaultAndAutoDefault()
QVERIFY(dialog.isVisible()); QVERIFY(dialog.isVisible());
QObject::connect(&button1, SIGNAL(clicked()), &dialog, SLOT(hide())); QObject::connect(&button1, SIGNAL(clicked()), &dialog, SLOT(hide()));
QKeyEvent event(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier); QTest::keyClick(&dialog, Qt::Key_Return);
QApplication::sendEvent(&dialog, &event);
QVERIFY(!dialog.isVisible()); QVERIFY(!dialog.isVisible());
} }
@ -478,8 +482,7 @@ void tst_QCommandLinkButton::defaultAndAutoDefault()
// No default button is set, and button2 is the first autoDefault button // No default button is set, and button2 is the first autoDefault button
// that is next in the tab order // that is next in the tab order
QObject::connect(&button2, SIGNAL(clicked()), &dialog, SLOT(hide())); QObject::connect(&button2, SIGNAL(clicked()), &dialog, SLOT(hide()));
QKeyEvent event(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier); QTest::keyClick(&dialog, Qt::Key_Return);
QApplication::sendEvent(&dialog, &event);
QVERIFY(!dialog.isVisible()); QVERIFY(!dialog.isVisible());
// Reparenting // Reparenting

View File

@ -814,6 +814,7 @@ void tst_QDoubleSpinBox::setReadOnly()
QDoubleSpinBox spin(0); QDoubleSpinBox spin(0);
spin.setValue(0.2); spin.setValue(0.2);
spin.show(); spin.show();
QVERIFY(QTest::qWaitForWindowActive(&spin));
QCOMPARE(spin.value(), 0.2); QCOMPARE(spin.value(), 0.2);
QTest::keyClick(&spin, Qt::Key_Up); QTest::keyClick(&spin, Qt::Key_Up);
QCOMPARE(spin.value(), 1.2); QCOMPARE(spin.value(), 1.2);
@ -836,7 +837,7 @@ void tst_QDoubleSpinBox::editingFinished()
layout->addWidget(box2); layout->addWidget(box2);
testFocusWidget->show(); testFocusWidget->show();
QApplication::setActiveWindow(testFocusWidget); testFocusWidget->activateWindow();
QVERIFY(QTest::qWaitForWindowActive(testFocusWidget)); QVERIFY(QTest::qWaitForWindowActive(testFocusWidget));
box->setFocus(); box->setFocus();
QTRY_VERIFY(box->hasFocus()); QTRY_VERIFY(box->hasFocus());
@ -844,7 +845,6 @@ void tst_QDoubleSpinBox::editingFinished()
QSignalSpy editingFinishedSpy1(box, SIGNAL(editingFinished())); QSignalSpy editingFinishedSpy1(box, SIGNAL(editingFinished()));
QSignalSpy editingFinishedSpy2(box2, SIGNAL(editingFinished())); QSignalSpy editingFinishedSpy2(box2, SIGNAL(editingFinished()));
box->setFocus();
QTest::keyClick(box, Qt::Key_Up); QTest::keyClick(box, Qt::Key_Up);
QTest::keyClick(box, Qt::Key_Up); QTest::keyClick(box, Qt::Key_Up);

View File

@ -34,6 +34,8 @@
#if defined(Q_OS_LINUX) && defined(Q_PROCESSOR_ARM) #if defined(Q_OS_LINUX) && defined(Q_PROCESSOR_ARM)
#define SHOULD_CHECK_ARM_ON_X86 #define SHOULD_CHECK_ARM_ON_X86
#include <QFileInfo>
#if QT_CONFIG(process) && QT_CONFIG(regularexpression) #if QT_CONFIG(process) && QT_CONFIG(regularexpression)
#include <QProcess> #include <QProcess>
#include <QRegularExpression> #include <QRegularExpression>