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
| QDialogButtonBox::Cancel);
connect(buttonBox, SIGNAL(accepted()), this, SLOT(verify()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
connect(buttonBox, &QDialogButtonBox::accepted, this, &DetailsDialog::verify);
connect(buttonBox, &QDialogButtonBox::rejected, this, &DetailsDialog::reject);
//! [0]
//! [1]

View File

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

View File

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

View File

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

View File

@ -95,10 +95,10 @@ warnings_are_errors:warning_clean {
# compiler.
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
# Regular clang 3.x-5.0
# Regular clang 3.x-6.0
apple_ver = $${QT_APPLE_CLANG_MAJOR_VERSION}.$${QT_APPLE_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
}
} else:intel_icc:linux {

View File

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

View File

@ -562,7 +562,8 @@
},
"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",
"output": [ "privateFeature" ]
},

View File

@ -1334,7 +1334,14 @@
\omitvalue WA_WState_WindowOpacitySet
\omitvalue WA_WState_AcceptedTouchBeginEvent
\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

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)
static int statx(int dirfd, const char *pathname, int flag, unsigned mask, struct statx *statxbuf)
{ return syscall(SYS_statx, dirfd, pathname, flag, mask, statxbuf); }
# elif !QT_CONFIG(statx) && !defined(SYS_statx)
# undef STATX_BASIC_STATS
# endif
# endif // !Q_OS_ANDROID
#endif

View File

@ -4429,6 +4429,7 @@ QDebug operator<<(QDebug dbg, const QObject *o)
/*!
\macro Q_NAMESPACE
\relates QObject
\since 5.8
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);
}
inline bool isValidValueOffset(uint offset, uint tableOffset)
{
return offset >= sizeof(Base)
&& offset + sizeof(uint) <= tableOffset;
}
bool Value::isValid(const Base *b) const
{
int offset = -1;
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::Bool:
default:
break;
}
if (offset == -1)
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;
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
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
{
// See man 7 locale for precedence - LC_ALL beats LC_MESSAGES beats LANG:
QByteArray lang = qgetenv("LC_ALL");
if (lang.isEmpty())
lang = qgetenv("LC_MESSAGES");
@ -118,12 +146,12 @@ QLocale QSystemLocale::fallbackUiLocale() const
if (lang.isEmpty() || lang == QByteArray("C") || lang == QByteArray("POSIX"))
return QLocale(QString::fromLatin1(lang));
// if the locale is not the "C" locale and LANGUAGE is not empty, return
// the first part of LANGUAGE if LANGUAGE is set and has a first part:
// ... otherwise, if the first part of LANGUAGE says more than or
// contradicts what we have, use that:
QByteArray language = qgetenv("LANGUAGE");
if (!language.isEmpty()) {
language = language.split(':').constFirst();
if (!language.isEmpty())
if (contradicts(language, lang))
return QLocale(QString::fromLatin1(language));
}

View File

@ -246,7 +246,8 @@ namespace QtSharedPointer {
struct ExternalRefCountWithContiguousData: public ExternalRefCountData
{
typedef ExternalRefCountData Parent;
T data;
typedef typename std::remove_cv<T>::type NoCVType;
NoCVType data;
static void deleter(ExternalRefCountData *self)
{
@ -262,7 +263,7 @@ namespace QtSharedPointer {
}
static void noDeleter(ExternalRefCountData *) { }
static inline ExternalRefCountData *create(T **ptr, DestroyerFn destroy)
static inline ExternalRefCountData *create(NoCVType **ptr, DestroyerFn destroy)
{
ExternalRefCountWithContiguousData *d =
static_cast<ExternalRefCountWithContiguousData *>(::operator new(sizeof(ExternalRefCountWithContiguousData)));
@ -437,10 +438,12 @@ public:
# endif
typename Private::DestroyerFn noDestroy = &Private::noDeleter;
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
new (result.data()) T(std::forward<Args>(arguments)...);
new (ptr) T(std::forward<Args>(arguments)...);
result.value = ptr;
result.d->destroyer = destroy;
result.d->setQObjectShared(result.value, true);
# 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.
bool qt_is_ascii(const char *&ptr, const char *end) Q_DECL_NOTHROW
{
#if defined(__AVX2__)
if (!simdTestMask(ptr, end, 0x80808080))
return false;
#elif defined(__SSE2__)
#if defined(__SSE2__)
// 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) {
__m128i data = _mm_loadu_si128(reinterpret_cast<const __m128i *>(ptr));
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
#ifdef __SSE2__
const char *ptr = reinterpret_cast<const char*>(a);
qptrdiff distance = reinterpret_cast<const char*>(b) - ptr;
a += l & ~7;
b += l & ~7;
l &= 7;
const QChar *end = a + l;
qptrdiff offset = 0;
// we're going to read ptr[0..15] (16 bytes)
for ( ; ptr + 15 < reinterpret_cast<const char *>(a); ptr += 16) {
__m128i a_data = _mm_loadu_si128((const __m128i*)ptr);
__m128i b_data = _mm_loadu_si128((const __m128i*)(ptr + distance));
// we're going to read a[0..15] and b[0..15] (32 bytes)
for ( ; a + offset + 16 <= end; offset += 16) {
#ifdef __AVX2__
__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);
uint mask = ~_mm_movemask_epi8(result);
if (ushort(mask)) {
// found a different byte
// found a different character
uint idx = qCountTrailingZeroBits(mask);
return reinterpret_cast<const QChar *>(ptr + idx)->unicode()
- reinterpret_cast<const QChar *>(ptr + distance + idx)->unicode();
return a[offset + idx / 2].unicode() - b[offset + idx / 2].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 {
return reinterpret_cast<const QChar *>(ptr)[i].unicode()
- reinterpret_cast<const QChar *>(ptr + distance)[i].unicode();
return a[offset + i].unicode() - b[offset + i].unicode();
};
return UnrollTailLoop<7>::exec(l, 0, lambda, lambda);
return UnrollTailLoop<3>::exec(l, 0, lambda, lambda);
#endif
#if defined(__ARM_NEON__) && defined(Q_PROCESSOR_ARM_64) // vaddv is only available on Aarch64
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 py = fy * iw - qreal(0.5);
int x1 = int(px) - (px < 0);
int x1 = qFloor(px);
int x2;
int y1 = int(py) - (py < 0);
int y1 = qFloor(py);
int y2;
distxs[i] = int((px - x1) * (1<<16));
distys[i] = int((py - y1) * (1<<16));
distxs[i] = qFloor((px - x1) * (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.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 replyPrivate = httpReply->d_func();
replyPrivate->compressedData.append(data, length);
replyPrivate->totalProgress += length;
const QByteArray wrapped(data, length);

View File

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

View File

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

View File

@ -792,6 +792,53 @@ QFunctionPointer QEGLPlatformContext::getProcAddress(const char *procName)
{ "glVertexAttribIFormat", (QFunctionPointer) ::glVertexAttribIFormat },
{ "glVertexBindingDivisor", (QFunctionPointer) ::glVertexBindingDivisor },
#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) {

View File

@ -520,11 +520,25 @@ static bool isValidWheelReceiver(QWindow *candidate)
static void redirectWheelEvent(QWindow *window, const QPoint &globalPos, int delta,
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 (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);
QWindowSystemInterface::handleWheelEvent(window,
QWindowsGeometryHint::mapFromGlobal(window, globalPos),
QWindowSystemInterface::handleWheelEvent(receiver,
QWindowsGeometryHint::mapFromGlobal(receiver, globalPos),
globalPos, QPoint(), point, mods);
}
}

View File

@ -1174,11 +1174,11 @@ void QWindowsWindow::initialize()
const Qt::WindowState state = w->windowState();
if (state != Qt::WindowMaximized && state != Qt::WindowFullScreen
&& creationContext->requestedGeometryIn != creationContext->obtainedGeometry) {
QWindowSystemInterface::handleGeometryChange(w, creationContext->obtainedGeometry);
QWindowSystemInterface::handleGeometryChange<QWindowSystemInterface::SynchronousDelivery>(w, creationContext->obtainedGeometry);
}
QPlatformScreen *obtainedScreen = screenForGeometry(creationContext->obtainedGeometry);
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)
: QXcbObject(conn), m_screen(screen), m_gtkCursorThemeInitialized(false)
{
#if QT_CONFIG(cursor)
// see NUM_BITMAPS in libXcursor/src/xcursorint.h
m_bitmapCache.setMaxCost(8);
#endif
if (cursorCount++)
return;

View File

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

View File

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

View File

@ -465,10 +465,10 @@ bool QSQLiteResult::exec()
#if (SQLITE_VERSION_NUMBER >= 3003011)
// 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
// has parameters
if (paramCount > 1 && paramCount < values.count()) {
if (paramCount >= 1 && paramCount < values.count()) {
const auto countIndexes = [](int counter, const QVector<int> &indexList) {
return counter + indexList.length();
};

View File

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

View File

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

View File

@ -587,12 +587,9 @@ void QWin32PrintEngine::drawPixmap(const QRectF &targetRect,
QPixmap p = QPixmap::fromImage(img);
HBITMAP hbitmap = qt_pixmapToWinHBITMAP(p, HBitmapNoAlpha);
HDC display_dc = GetDC(0);
HDC hbitmap_hdc = CreateCompatibleDC(display_dc);
HDC hbitmap_hdc = CreateCompatibleDC(d->hdc);
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,
hbitmap_hdc, 0, 0, p.width(), p.height(), SRCCOPY))
qErrnoWarning("QWin32PrintEngine::drawPixmap, StretchBlt failed");
@ -620,13 +617,10 @@ void QWin32PrintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pm, cons
} else {
int dc_state = SaveDC(d->hdc);
HDC display_dc = GetDC(0);
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);
ReleaseDC(0, display_dc);
QRectF trect = d->painterMatrix.mapRect(r);
int tx = int(trect.left() * d->stretch_x + d->origin_x);
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
the record.
Note that the generated flags in \a values are preserved
and determine whether the corresponding fields are used when
changes are submitted to the database. The caller should
remember to set the generated flag to FALSE for fields
where the database is meant to supply the value, such as an
automatically incremented ID.
Note that the generated flags in \a values are preserved to
determine whether the corresponding fields are used when changes
are submitted to the database. By default, it is set to \c true
for all fields in a QSqlRecord. You must set the flag to \c false
using \l{QSqlRecord::}{setGenerated}(false) for any value in
\a values, to save changes back to the database.
For edit strategies OnFieldChange and OnRowChange, a row may
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;
}
class NamePredicate : public std::unary_function<QTestTablePrivate::Element, bool>
class NamePredicate
{
public:
explicit NamePredicate(const char *needle) : m_needle(needle) {}

View File

@ -37,7 +37,7 @@
#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
{
@ -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
{ return a == b; }
@ -135,7 +135,7 @@ private:
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
{ return a.count (0) > b.count (0); }

View File

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

View File

@ -3513,7 +3513,7 @@ QRect QFusionStyle::subControlRect(ComplexControl control, const QStyleOptionCom
int frameWidth = 2;
rect = visualRect(option->direction, option->rect, rect);
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);
if (const QStyleOptionComboBox *box = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
if (!box->editable) {

View File

@ -100,7 +100,7 @@ public:
QCursor adjustedCursor;
bool hasOldCursor = false;
bool cursorAdjusted = false;
#endif
#endif // QT_CONFIG(cursor)
QList<int> movingSeparator;
QPoint movingSeparatorOrigin, movingSeparatorPos;
@ -110,7 +110,8 @@ public:
bool separatorMove(const QPoint &pos);
bool endSeparatorMove(const QPoint &pos);
bool windowEvent(QEvent *e);
#endif
#endif // QT_CONFIG(dockwidget)
};
@ -203,7 +204,7 @@ bool QMainWindowLayoutSeparatorHelper<Layout>::windowEvent(QEvent *event)
break;
}
#ifndef QT_NO_CURSOR
#if QT_CONFIG(cursor)
case QEvent::HoverMove: {
adjustCursor(static_cast<QHoverEvent *>(event)->pos());
break;
@ -219,7 +220,7 @@ bool QMainWindowLayoutSeparatorHelper<Layout>::windowEvent(QEvent *event)
case QEvent::ShortcutOverride: // when a menu pops up
adjustCursor(QPoint(0, 0));
break;
#endif // QT_NO_CURSOR
#endif // QT_CONFIG(cursor)
case QEvent::MouseButtonPress: {
QMouseEvent *e = static_cast<QMouseEvent *>(event);
@ -234,7 +235,7 @@ bool QMainWindowLayoutSeparatorHelper<Layout>::windowEvent(QEvent *event)
case QEvent::MouseMove: {
QMouseEvent *e = static_cast<QMouseEvent *>(event);
#ifndef QT_NO_CURSOR
#if QT_CONFIG(cursor)
adjustCursor(e->pos());
#endif
if (e->buttons() & Qt::LeftButton) {
@ -258,7 +259,7 @@ bool QMainWindowLayoutSeparatorHelper<Layout>::windowEvent(QEvent *event)
break;
}
#if !defined(QT_NO_CURSOR)
#if QT_CONFIG(cursor)
case QEvent::CursorChange:
// CursorChange events are triggered as mouse moves to new widgets even
// 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);
}
break;
#endif
#endif // QT_CONFIG(cursor)
case QEvent::Timer:
if (static_cast<QTimerEvent *>(event)->timerId() == separatorMoveTimer.timerId()) {
// let's move the separators
@ -374,7 +375,7 @@ public:
private:
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
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
QT = core-private testlib network
SOURCES = ../tst_qprocess.cpp
INCLUDEPATH += ../../../../../shared
HEADERS += ../../../../../shared/emulationdetector.h
TARGET = ../tst_qprocess

View File

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

View File

@ -93,6 +93,7 @@ private slots:
void lambdaCustomDeleter();
#endif
void creating();
void creatingCvQualified();
void creatingVariadic();
void creatingQObject();
void mixTrackingPointerCode();
@ -1771,6 +1772,13 @@ void tst_QSharedPointer::creating()
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()
{
int i = 42;

View File

@ -469,6 +469,9 @@ void tst_QNetworkRequest::rawHeaderParsing_data()
<< QVariant::fromValue(QList<QNetworkCookie>() << cookie << cookie2)
<< true << "Set-Cookie"
<< "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()

View File

@ -2070,8 +2070,6 @@ void tst_QSqlQuery::prepare_bind_exec()
const QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(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)
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(1).toString(), QString("name"));
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
}

View File

@ -494,9 +494,6 @@ void tst_QFiledialog::completer()
QAbstractItemModel *cModel = completer->completionModel();
QVERIFY(cModel);
//wait a bit
QTest::qWait(500);
// path C:\depot\qt\examples\dialogs\standarddialogs
// files
// [debug] [release] [tmp] dialog dialog main makefile makefile.debug makefile.release standarddialgos
@ -509,7 +506,7 @@ void tst_QFiledialog::completer()
// \ -> \_viminfo
// c:\depot -> 'nothing'
// 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()) {
// 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
fd.setDirectory(QDir::home());
QTest::qWait(1000);
#ifdef QT_KEYPAD_NAVIGATION
list->setEditFocus(true);
#endif
@ -1341,8 +1337,7 @@ void tst_QFiledialog::clearLineEdit()
QTest::keyClick(list, Qt::Key_O, Qt::ControlModifier);
#endif
QTest::qWait(2000);
QVERIFY(fd.directory().absolutePath() != QDir::home().absolutePath());
QTRY_VERIFY(fd.directory().absolutePath() != QDir::home().absolutePath());
QVERIFY(!lineEdit->text().isEmpty());
// 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.setDirectory(QDir::home());
QTest::qWait(1000);
QTest::keyClick(list, Qt::Key_Down);
#ifndef Q_OS_MAC
QTest::keyClick(list, Qt::Key_Return);
@ -1358,8 +1352,7 @@ void tst_QFiledialog::clearLineEdit()
QTest::keyClick(list, Qt::Key_O, Qt::ControlModifier);
#endif
QTest::qWait(2000);
QVERIFY(fd.directory().absolutePath() != QDir::home().absolutePath());
QTRY_VERIFY(fd.directory().absolutePath() != QDir::home().absolutePath());
QVERIFY(lineEdit->text().isEmpty());
//remove the dir

View File

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

View File

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

View File

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

View File

@ -167,6 +167,12 @@ void tst_QCommandLinkButton::onReleased()
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.
QVERIFY( !testWidget->isCheckable() );
@ -421,8 +427,7 @@ void tst_QCommandLinkButton::defaultAndAutoDefault()
QVERIFY(dialog.isVisible());
QObject::connect(&button1, SIGNAL(clicked()), &dialog, SLOT(hide()));
QKeyEvent event(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier);
QApplication::sendEvent(&dialog, &event);
QTest::keyClick(&dialog, Qt::Key_Return);
QVERIFY(!dialog.isVisible());
}
@ -462,8 +467,7 @@ void tst_QCommandLinkButton::defaultAndAutoDefault()
QVERIFY(dialog.isVisible());
QObject::connect(&button1, SIGNAL(clicked()), &dialog, SLOT(hide()));
QKeyEvent event(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier);
QApplication::sendEvent(&dialog, &event);
QTest::keyClick(&dialog, Qt::Key_Return);
QVERIFY(!dialog.isVisible());
}
@ -478,8 +482,7 @@ void tst_QCommandLinkButton::defaultAndAutoDefault()
// No default button is set, and button2 is the first autoDefault button
// that is next in the tab order
QObject::connect(&button2, SIGNAL(clicked()), &dialog, SLOT(hide()));
QKeyEvent event(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier);
QApplication::sendEvent(&dialog, &event);
QTest::keyClick(&dialog, Qt::Key_Return);
QVERIFY(!dialog.isVisible());
// Reparenting

View File

@ -814,6 +814,7 @@ void tst_QDoubleSpinBox::setReadOnly()
QDoubleSpinBox spin(0);
spin.setValue(0.2);
spin.show();
QVERIFY(QTest::qWaitForWindowActive(&spin));
QCOMPARE(spin.value(), 0.2);
QTest::keyClick(&spin, Qt::Key_Up);
QCOMPARE(spin.value(), 1.2);
@ -836,7 +837,7 @@ void tst_QDoubleSpinBox::editingFinished()
layout->addWidget(box2);
testFocusWidget->show();
QApplication::setActiveWindow(testFocusWidget);
testFocusWidget->activateWindow();
QVERIFY(QTest::qWaitForWindowActive(testFocusWidget));
box->setFocus();
QTRY_VERIFY(box->hasFocus());
@ -844,7 +845,6 @@ void tst_QDoubleSpinBox::editingFinished()
QSignalSpy editingFinishedSpy1(box, SIGNAL(editingFinished()));
QSignalSpy editingFinishedSpy2(box2, SIGNAL(editingFinished()));
box->setFocus();
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)
#define SHOULD_CHECK_ARM_ON_X86
#include <QFileInfo>
#if QT_CONFIG(process) && QT_CONFIG(regularexpression)
#include <QProcess>
#include <QRegularExpression>