summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--configure.pri8
-rw-r--r--examples/opengl/computegles31/glwindow.cpp6
-rw-r--r--mkspecs/features/qt_example_installs.prf10
-rw-r--r--src/corelib/global/qendian.h12
-rw-r--r--src/corelib/global/qglobal.cpp4
-rw-r--r--src/corelib/io/qstandardpaths_unix.cpp51
-rw-r--r--src/corelib/serialization/qjson_p.h4
-rw-r--r--src/corelib/tools/qsharedpointer_impl.h51
-rw-r--r--src/gui/kernel/qdnd.cpp9
-rw-r--r--src/gui/kernel/qdnd_p.h4
-rw-r--r--src/gui/kernel/qdrag.cpp7
-rw-r--r--src/gui/opengl/qopenglfunctions_4_2_compatibility.h10
-rw-r--r--src/gui/opengl/qopenglfunctions_4_2_core.h10
-rw-r--r--src/gui/opengl/qopenglfunctions_4_3_compatibility.h10
-rw-r--r--src/gui/opengl/qopenglfunctions_4_3_core.h11
-rw-r--r--src/gui/opengl/qopenglfunctions_4_4_compatibility.h10
-rw-r--r--src/gui/opengl/qopenglfunctions_4_4_core.h10
-rw-r--r--src/gui/opengl/qopenglfunctions_4_5_compatibility.h10
-rw-r--r--src/gui/opengl/qopenglfunctions_4_5_core.h11
-rw-r--r--src/gui/opengl/qopenglversionfunctions.h10
-rw-r--r--src/gui/text/qfontdatabase.cpp3
-rw-r--r--src/gui/text/qtextdocumentlayout.cpp8
-rw-r--r--src/openglextensions/qopenglextensions.cpp9
-rw-r--r--src/openglextensions/qopenglextensions.h10
-rw-r--r--src/plugins/platforms/android/androidjniinput.cpp14
-rw-r--r--src/plugins/platforms/android/androidjniinput.h2
-rw-r--r--src/plugins/platforms/android/qandroidinputcontext.cpp3
-rw-r--r--src/plugins/platforms/cocoa/qprintengine_mac.mm2
-rw-r--r--src/plugins/platforms/windows/qwindowsinputcontext.cpp12
-rw-r--r--src/plugins/platforms/xcb/qxcbdrag.cpp8
-rw-r--r--src/plugins/sqldrivers/odbc/qsql_odbc.cpp10
-rw-r--r--src/testlib/doc/snippets/code/src_qtestlib_qtestcase.cpp30
-rw-r--r--src/testlib/doc/src/qttestlib-manual.qdoc53
-rw-r--r--src/testlib/qsignalspy.qdoc16
-rw-r--r--src/testlib/qtestcase.qdoc57
-rw-r--r--src/widgets/dialogs/qcolordialog.cpp4
-rw-r--r--src/widgets/doc/snippets/code/doc_src_stylesheet.qdoc2
-rw-r--r--src/widgets/graphicsview/qgraphicsscene.cpp13
-rw-r--r--src/widgets/graphicsview/qgraphicsscene_p.h17
-rw-r--r--src/widgets/kernel/qwidget.cpp4
-rw-r--r--src/widgets/kernel/qwidgetwindow.cpp12
-rw-r--r--tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp34
-rw-r--r--tests/auto/corelib/serialization/qdatastream_core_pixmap/tst_qdatastream_core_pixmap.cpp21
-rw-r--r--tests/auto/corelib/serialization/serialization.pro3
-rw-r--r--tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp54
-rw-r--r--tests/auto/other/other.pro5
-rw-r--r--tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp27
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicspixmapitem/tst_qgraphicspixmapitem.cpp8
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp2
-rw-r--r--tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp23
50 files changed, 527 insertions, 197 deletions
diff --git a/configure.pri b/configure.pri
index 3778ece180..16e2fccd77 100644
--- a/configure.pri
+++ b/configure.pri
@@ -741,7 +741,13 @@ defineTest(qtConfOutput_preparePaths) {
}
have_prefix = false
} else {
- config.input.prefix = $$absolute_path($$config.input.prefix, $$OUT_PWD)
+ equals(XSPEC, $$[QMAKE_SPEC]) {
+ # Only make the user-specified prefix absolute if we're not cross-compiling.
+ config.input.prefix = $$absolute_path($$config.input.prefix, $$OUT_PWD)
+ } else {
+ # But we still must normalize path separators.
+ config.input.prefix = $$replace(config.input.prefix, \\\\, /)
+ }
have_prefix = true
}
diff --git a/examples/opengl/computegles31/glwindow.cpp b/examples/opengl/computegles31/glwindow.cpp
index 7a14cba66d..29ec9fcff7 100644
--- a/examples/opengl/computegles31/glwindow.cpp
+++ b/examples/opengl/computegles31/glwindow.cpp
@@ -180,7 +180,7 @@ static const char *fsDisplaySource =
"}\n";
static const char *csComputeSourceV =
- "#define COMPUTEPATCHSIZE 32 \n"
+ "#define COMPUTEPATCHSIZE 10 // Setting this to 10 to comply with MAX_COMPUTE_WORK_GROUP_INVOCATIONS for both OpenGL and OpenGLES - see QTBUG-79374 \n"
"#define IMGFMT rgba8 \n"
"layout (local_size_x = COMPUTEPATCHSIZE, local_size_y = COMPUTEPATCHSIZE) in;\n"
"layout(binding=0, IMGFMT) uniform readonly highp image2D inputImage; // Use a sampler to improve performance \n"
@@ -221,7 +221,7 @@ static const char *csComputeSourceV =
"}\n";
static const char *csComputeSourceH =
- "#define COMPUTEPATCHSIZE 32 \n"
+ "#define COMPUTEPATCHSIZE 10 \n"
"#define IMGFMT rgba8 \n"
"layout (local_size_x = COMPUTEPATCHSIZE, local_size_y = COMPUTEPATCHSIZE) in;\n"
"layout(binding=0, IMGFMT) uniform readonly highp image2D inputImage; // Use a sampler to improve performance \n"
@@ -408,7 +408,7 @@ void GLWindow::paintGL()
// Process input image
- QSize workGroups = getWorkGroups( 32, QSize(m_texImageInput->width(), m_texImageInput->height()));
+ QSize workGroups = getWorkGroups(10, QSize(m_texImageInput->width(), m_texImageInput->height()));
// Pass 1
f->glBindImageTexture(0, m_texImageInput->textureId(), 0, 0, 0, GL_READ_WRITE, GL_RGBA8);
f->glBindImageTexture(1, m_texImageTmp->textureId(), 0, 0, 0, GL_READ_WRITE, GL_RGBA8);
diff --git a/mkspecs/features/qt_example_installs.prf b/mkspecs/features/qt_example_installs.prf
index 43b58817fe..72b47bce27 100644
--- a/mkspecs/features/qt_example_installs.prf
+++ b/mkspecs/features/qt_example_installs.prf
@@ -25,14 +25,16 @@ defineTest(addInstallFiles) {
export($$1)
}
-probase = $$relative_path($$_PRO_FILE_PWD_, $$dirname(_QMAKE_CONF_)/examples)
+moduleRoot = $$dirname(_QMAKE_CONF_)
+probase = $$relative_path($$_PRO_FILE_PWD_, $$moduleRoot/examples)
isEmpty(probase)|contains(probase, ^\\..*): \
return()
isEmpty(_QMAKE_CACHE_) {
- !equals(OUT_PWD, $$_PRO_FILE_PWD_): \
- return()
- error("You cannot build examples inside the Qt source tree, except as part of a proper Qt build.")
+ moduleRootRelativeToBuildDir = $$relative_path($$moduleRoot, $$OUT_PWD)
+ # Check if OUT_PWD is inside module root
+ equals(moduleRootRelativeToBuildDir, .)|contains(moduleRootRelativeToBuildDir, \(\.\./\)+\(\.\.\)?): \
+ error("You cannot build examples inside the Qt source tree, except as part of a proper Qt build.")
}
contains(TEMPLATE, "vc.*"): \
diff --git a/src/corelib/global/qendian.h b/src/corelib/global/qendian.h
index 615f523888..5cd9d3160b 100644
--- a/src/corelib/global/qendian.h
+++ b/src/corelib/global/qendian.h
@@ -327,9 +327,9 @@ public:
return pre;
}
- static constexpr QSpecialInteger max()
+ static Q_DECL_CONSTEXPR QSpecialInteger max()
{ return QSpecialInteger(std::numeric_limits<T>::max()); }
- static constexpr QSpecialInteger min()
+ static Q_DECL_CONSTEXPR QSpecialInteger min()
{ return QSpecialInteger(std::numeric_limits<T>::min()); }
};
@@ -373,8 +373,8 @@ public:
QLEInteger &operator ++(int);
QLEInteger &operator --(int);
- static constexpr QLEInteger max();
- static constexpr QLEInteger min();
+ static Q_DECL_CONSTEXPR QLEInteger max();
+ static Q_DECL_CONSTEXPR QLEInteger min();
};
template<typename T>
@@ -400,8 +400,8 @@ public:
QBEInteger &operator ++(int);
QBEInteger &operator --(int);
- static constexpr QBEInteger max();
- static constexpr QBEInteger min();
+ static Q_DECL_CONSTEXPR QBEInteger max();
+ static Q_DECL_CONSTEXPR QBEInteger min();
};
#else
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index 30a44aeef8..78ad2a5421 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -110,8 +110,8 @@ extern "C" {
// without full system POSIX.
# pragma weak shm_area_password
# pragma weak shm_area_name
- char *shm_area_password = "dummy";
- char *shm_area_name = "dummy";
+ char shm_area_password[] = "dummy";
+ char shm_area_name[] = "dummy";
}
#endif
diff --git a/src/corelib/io/qstandardpaths_unix.cpp b/src/corelib/io/qstandardpaths_unix.cpp
index 3d4a349c8c..cc656954d9 100644
--- a/src/corelib/io/qstandardpaths_unix.cpp
+++ b/src/corelib/io/qstandardpaths_unix.cpp
@@ -120,54 +120,59 @@ QString QStandardPaths::writableLocation(StandardLocation type)
}
case RuntimeLocation:
{
- const uint myUid = uint(geteuid());
// http://standards.freedesktop.org/basedir-spec/latest/
+ const uint myUid = uint(geteuid());
+ // since the current user is the owner, set both xxxUser and xxxOwner
+ const QFile::Permissions wantedPerms = QFile::ReadUser | QFile::WriteUser | QFile::ExeUser
+ | QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner;
QFileInfo fileInfo;
QString xdgRuntimeDir = QFile::decodeName(qgetenv("XDG_RUNTIME_DIR"));
if (xdgRuntimeDir.isEmpty()) {
const QString userName = QFileSystemEngine::resolveUserName(myUid);
xdgRuntimeDir = QDir::tempPath() + QLatin1String("/runtime-") + userName;
fileInfo.setFile(xdgRuntimeDir);
- if (!fileInfo.isDir()) {
- if (!QDir().mkdir(xdgRuntimeDir)) {
- qWarning("QStandardPaths: error creating runtime directory %s: %s", qPrintable(xdgRuntimeDir), qPrintable(qt_error_string(errno)));
- return QString();
- }
- }
#ifndef Q_OS_WASM
qWarning("QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '%s'", qPrintable(xdgRuntimeDir));
#endif
} else {
fileInfo.setFile(xdgRuntimeDir);
- if (!fileInfo.exists()) {
- qWarning("QStandardPaths: XDG_RUNTIME_DIR points to non-existing path '%s', "
- "please create it with 0700 permissions.", qPrintable(xdgRuntimeDir));
- return QString();
- }
+ }
+ if (fileInfo.exists()) {
if (!fileInfo.isDir()) {
qWarning("QStandardPaths: XDG_RUNTIME_DIR points to '%s' which is not a directory",
qPrintable(xdgRuntimeDir));
return QString();
}
+ } else {
+ QFileSystemEntry entry(xdgRuntimeDir);
+ if (!QFileSystemEngine::createDirectory(entry, false)) {
+ if (errno != EEXIST) {
+ qWarning("QStandardPaths: error creating runtime directory %s: %s",
+ qPrintable(xdgRuntimeDir), qPrintable(qt_error_string(errno)));
+ return QString();
+ }
+ } else {
+ QSystemError error;
+ if (!QFileSystemEngine::setPermissions(entry, wantedPerms, error)) {
+ qWarning("QStandardPaths: could not set correct permissions on runtime directory %s: %s",
+ qPrintable(xdgRuntimeDir), qPrintable(error.toString()));
+ return QString();
+ }
+ }
}
// "The directory MUST be owned by the user"
if (fileInfo.ownerId() != myUid) {
- qWarning("QStandardPaths: wrong ownership on runtime directory %s, %d instead of %d", qPrintable(xdgRuntimeDir),
- fileInfo.ownerId(), myUid);
+ qWarning("QStandardPaths: wrong ownership on runtime directory %s, %d instead of %d",
+ qPrintable(xdgRuntimeDir), fileInfo.ownerId(), myUid);
return QString();
}
// "and he MUST be the only one having read and write access to it. Its Unix access mode MUST be 0700."
- // since the current user is the owner, set both xxxUser and xxxOwner
- const QFile::Permissions wantedPerms = QFile::ReadUser | QFile::WriteUser | QFile::ExeUser
- | QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner;
if (fileInfo.permissions() != wantedPerms) {
- QFile file(xdgRuntimeDir);
- if (!file.setPermissions(wantedPerms)) {
- qWarning("QStandardPaths: could not set correct permissions on runtime directory %s: %s",
- qPrintable(xdgRuntimeDir), qPrintable(file.errorString()));
- return QString();
- }
+ qWarning("QStandardPaths: wrong permissions on runtime directory %s, %x instead of %x",
+ qPrintable(xdgRuntimeDir), uint(fileInfo.permissions()), uint(wantedPerms));
+ return QString();
}
+
return xdgRuntimeDir;
}
default:
diff --git a/src/corelib/serialization/qjson_p.h b/src/corelib/serialization/qjson_p.h
index 40b2414e4a..ff010cb902 100644
--- a/src/corelib/serialization/qjson_p.h
+++ b/src/corelib/serialization/qjson_p.h
@@ -222,7 +222,9 @@ public:
for (int i = 0; i < str.length(); ++i)
d->utf16[i] = uc[i];
#else
- memcpy(d->utf16, str.unicode(), str.length()*sizeof(ushort));
+ memcpy(static_cast<void *>(d->utf16),
+ static_cast<const void *>(str.unicode()),
+ str.length()*sizeof(ushort));
#endif
if (str.length() & 1)
d->utf16[str.length()] = 0;
diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h
index bccf8c5740..f2158436fd 100644
--- a/src/corelib/tools/qsharedpointer_impl.h
+++ b/src/corelib/tools/qsharedpointer_impl.h
@@ -69,21 +69,6 @@ QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
-
-// Macro QSHAREDPOINTER_VERIFY_AUTO_CAST
-// generates a compiler error if the following construct isn't valid:
-// T *ptr1;
-// X *ptr2 = ptr1;
-//
-#ifdef QT_NO_DEBUG
-# define QSHAREDPOINTER_VERIFY_AUTO_CAST(T, X) qt_noop()
-#else
-
-template<typename T> inline void qt_sharedpointer_cast_check(T *) { }
-# define QSHAREDPOINTER_VERIFY_AUTO_CAST(T, X) \
- qt_sharedpointer_cast_check<T>(static_cast<X *>(0))
-#endif
-
//
// forward declarations
//
@@ -293,6 +278,9 @@ template <class T> class QSharedPointer
{
typedef T *QSharedPointer:: *RestrictedBool;
typedef QtSharedPointer::ExternalRefCountData Data;
+ template <typename X>
+ using IfCompatible = typename std::enable_if<std::is_convertible<X*, T*>::value, bool>::type;
+
public:
typedef T Type;
typedef T element_type;
@@ -316,11 +304,11 @@ public:
Q_DECL_CONSTEXPR QSharedPointer(std::nullptr_t) Q_DECL_NOTHROW : value(nullptr), d(nullptr) { }
- template <class X>
+ template <class X, IfCompatible<X> = true>
inline explicit QSharedPointer(X *ptr) : value(ptr) // noexcept
{ internalConstruct(ptr, QtSharedPointer::NormalDeleter()); }
- template <class X, typename Deleter>
+ template <class X, typename Deleter, IfCompatible<X> = true>
inline QSharedPointer(X *ptr, Deleter deleter) : value(ptr) // throws
{ internalConstruct(ptr, deleter); }
@@ -349,7 +337,7 @@ public:
return *this;
}
- template <class X>
+ template <class X, IfCompatible<X> = true>
QSharedPointer(QSharedPointer<X> &&other) Q_DECL_NOTHROW
: value(other.value), d(other.d)
{
@@ -357,7 +345,7 @@ public:
other.value = nullptr;
}
- template <class X>
+ template <class X, IfCompatible<X> = true>
QSharedPointer &operator=(QSharedPointer<X> &&other) Q_DECL_NOTHROW
{
QSharedPointer moved(std::move(other));
@@ -367,11 +355,11 @@ public:
#endif
- template <class X>
+ template <class X, IfCompatible<X> = true>
QSharedPointer(const QSharedPointer<X> &other) Q_DECL_NOTHROW : value(other.value), d(other.d)
{ if (d) ref(); }
- template <class X>
+ template <class X, IfCompatible<X> = true>
inline QSharedPointer &operator=(const QSharedPointer<X> &other)
{
QSharedPointer copy(other);
@@ -379,11 +367,11 @@ public:
return *this;
}
- template <class X>
+ template <class X, IfCompatible<X> = true>
inline QSharedPointer(const QWeakPointer<X> &other) : value(nullptr), d(nullptr)
{ *this = other; }
- template <class X>
+ template <class X, IfCompatible<X> = true>
inline QSharedPointer<T> &operator=(const QWeakPointer<X> &other)
{ internalSet(other.d, other.value); return *this; }
@@ -553,6 +541,8 @@ class QWeakPointer
{
typedef T *QWeakPointer:: *RestrictedBool;
typedef QtSharedPointer::ExternalRefCountData Data;
+ template <typename X>
+ using IfCompatible = typename std::enable_if<std::is_convertible<X*, T*>::value, bool>::type;
public:
typedef T element_type;
@@ -574,14 +564,14 @@ public:
#ifndef QT_NO_QOBJECT
// special constructor that is enabled only if X derives from QObject
#if QT_DEPRECATED_SINCE(5, 0)
- template <class X>
+ template <class X, IfCompatible<X> = true>
QT_DEPRECATED inline QWeakPointer(X *ptr) : d(ptr ? Data::getAndRef(ptr) : nullptr), value(ptr)
{ }
#endif
#endif
#if QT_DEPRECATED_SINCE(5, 0)
- template <class X>
+ template <class X, IfCompatible<X> = true>
QT_DEPRECATED inline QWeakPointer &operator=(X *ptr)
{ return *this = QWeakPointer(ptr); }
#endif
@@ -619,11 +609,11 @@ public:
return *this;
}
- template <class X>
+ template <class X, IfCompatible<X> = true>
inline QWeakPointer(const QWeakPointer<X> &o) : d(nullptr), value(nullptr)
{ *this = o; }
- template <class X>
+ template <class X, IfCompatible<X> = true>
inline QWeakPointer &operator=(const QWeakPointer<X> &o)
{
// conversion between X and T could require access to the virtual table
@@ -640,14 +630,13 @@ public:
bool operator!=(const QWeakPointer<X> &o) const Q_DECL_NOTHROW
{ return !(*this == o); }
- template <class X>
+ template <class X, IfCompatible<X> = true>
inline QWeakPointer(const QSharedPointer<X> &o) : d(nullptr), value(nullptr)
{ *this = o; }
- template <class X>
+ template <class X, IfCompatible<X> = true>
inline QWeakPointer &operator=(const QSharedPointer<X> &o)
{
- QSHAREDPOINTER_VERIFY_AUTO_CAST(T, X); // if you get an error in this line, the cast is invalid
internalSet(o.d, o.data());
return *this;
}
@@ -684,7 +673,7 @@ public:
{ return *this = QWeakPointer<X>(ptr, true); }
#ifndef QT_NO_QOBJECT
- template <class X>
+ template <class X, IfCompatible<X> = true>
inline QWeakPointer(X *ptr, bool) : d(ptr ? Data::getAndRef(ptr) : nullptr), value(ptr)
{ }
#endif
diff --git a/src/gui/kernel/qdnd.cpp b/src/gui/kernel/qdnd.cpp
index 5c5f166554..dd541af3b8 100644
--- a/src/gui/kernel/qdnd.cpp
+++ b/src/gui/kernel/qdnd.cpp
@@ -113,11 +113,12 @@ Qt::DropAction QDragManager::drag(QDrag *o)
m_object->d_func()->target = 0;
- QGuiApplicationPrivate::instance()->notifyDragStarted(o);
+ QGuiApplicationPrivate::instance()->notifyDragStarted(m_object.data());
const Qt::DropAction result = m_platformDrag->drag(m_object);
- m_object = 0;
- if (!m_platformDrag->ownsDragObject())
- o->deleteLater();
+ if (!m_object.isNull() && !m_platformDrag->ownsDragObject())
+ m_object->deleteLater();
+
+ m_object.clear();
return result;
}
diff --git a/src/gui/kernel/qdnd_p.h b/src/gui/kernel/qdnd_p.h
index 8f8eb03f87..f095fbf7a0 100644
--- a/src/gui/kernel/qdnd_p.h
+++ b/src/gui/kernel/qdnd_p.h
@@ -101,13 +101,13 @@ public:
void setCurrentTarget(QObject *target, bool dropped = false);
QObject *currentTarget() const;
- QDrag *object() const { return m_object; }
+ QPointer<QDrag> object() const { return m_object; }
QObject *source() const;
private:
QObject *m_currentDropTarget;
QPlatformDrag *m_platformDrag;
- QDrag *m_object;
+ QPointer<QDrag> m_object;
static QDragManager *m_instance;
Q_DISABLE_COPY_MOVE(QDragManager)
diff --git a/src/gui/kernel/qdrag.cpp b/src/gui/kernel/qdrag.cpp
index dcd0d13d5c..8e2f7be23e 100644
--- a/src/gui/kernel/qdrag.cpp
+++ b/src/gui/kernel/qdrag.cpp
@@ -279,8 +279,11 @@ Qt::DropAction QDrag::exec(Qt::DropActions supportedActions, Qt::DropAction defa
}
d->supported_actions = supportedActions;
d->default_action = transformedDefaultDropAction;
- d->executed_action = QDragManager::self()->drag(this);
-
+ QPointer<QDrag> self = this;
+ auto executed_action = QDragManager::self()->drag(self.data());
+ if (self.isNull())
+ return Qt::IgnoreAction;
+ d->executed_action = executed_action;
return d->executed_action;
}
diff --git a/src/gui/opengl/qopenglfunctions_4_2_compatibility.h b/src/gui/opengl/qopenglfunctions_4_2_compatibility.h
index 6726d5fc44..a48d581c2d 100644
--- a/src/gui/opengl/qopenglfunctions_4_2_compatibility.h
+++ b/src/gui/opengl/qopenglfunctions_4_2_compatibility.h
@@ -57,6 +57,12 @@
#include <QtGui/QOpenGLVersionFunctions>
#include <QtGui/qopenglcontext.h>
+// MemoryBarrier is a macro on some architectures on Windows
+#ifdef Q_OS_WIN
+#pragma push_macro("MemoryBarrier")
+#undef MemoryBarrier
+#endif
+
QT_BEGIN_NAMESPACE
class Q_GUI_EXPORT QOpenGLFunctions_4_2_Compatibility : public QAbstractOpenGLFunctions
@@ -5632,6 +5638,10 @@ inline void QOpenGLFunctions_4_2_Compatibility::glVertexAttribI1i(GLuint index,
QT_END_NAMESPACE
+#ifdef Q_OS_WIN
+#pragma pop_macro("MemoryBarrier")
+#endif
+
#endif // QT_NO_OPENGL && !QT_OPENGL_ES_2
#endif
diff --git a/src/gui/opengl/qopenglfunctions_4_2_core.h b/src/gui/opengl/qopenglfunctions_4_2_core.h
index a921329741..5ca98e9808 100644
--- a/src/gui/opengl/qopenglfunctions_4_2_core.h
+++ b/src/gui/opengl/qopenglfunctions_4_2_core.h
@@ -57,6 +57,12 @@
#include <QtGui/QOpenGLVersionFunctions>
#include <QtGui/qopenglcontext.h>
+// MemoryBarrier is a macro on some architectures on Windows
+#ifdef Q_OS_WIN
+#pragma push_macro("MemoryBarrier")
+#undef MemoryBarrier
+#endif
+
QT_BEGIN_NAMESPACE
class Q_GUI_EXPORT QOpenGLFunctions_4_2_Core : public QAbstractOpenGLFunctions
@@ -3027,6 +3033,10 @@ inline void QOpenGLFunctions_4_2_Core::glDrawArraysInstancedBaseInstance(GLenum
QT_END_NAMESPACE
+#ifdef Q_OS_WIN
+#pragma pop_macro("MemoryBarrier")
+#endif
+
#endif // QT_NO_OPENGL && !QT_OPENGL_ES_2
#endif
diff --git a/src/gui/opengl/qopenglfunctions_4_3_compatibility.h b/src/gui/opengl/qopenglfunctions_4_3_compatibility.h
index b9d4eb1d6f..d969f5b3b4 100644
--- a/src/gui/opengl/qopenglfunctions_4_3_compatibility.h
+++ b/src/gui/opengl/qopenglfunctions_4_3_compatibility.h
@@ -57,6 +57,12 @@
#include <QtGui/QOpenGLVersionFunctions>
#include <QtGui/qopenglcontext.h>
+// MemoryBarrier is a macro on some architectures on Windows
+#ifdef Q_OS_WIN
+#pragma push_macro("MemoryBarrier")
+#undef MemoryBarrier
+#endif
+
QT_BEGIN_NAMESPACE
class Q_GUI_EXPORT QOpenGLFunctions_4_3_Compatibility : public QAbstractOpenGLFunctions
@@ -5839,6 +5845,10 @@ inline void QOpenGLFunctions_4_3_Compatibility::glVertexAttribI1i(GLuint index,
QT_END_NAMESPACE
+#ifdef Q_OS_WIN
+#pragma pop_macro("MemoryBarrier")
+#endif
+
#endif // QT_NO_OPENGL && !QT_OPENGL_ES_2
#endif
diff --git a/src/gui/opengl/qopenglfunctions_4_3_core.h b/src/gui/opengl/qopenglfunctions_4_3_core.h
index da552d64af..13675caf62 100644
--- a/src/gui/opengl/qopenglfunctions_4_3_core.h
+++ b/src/gui/opengl/qopenglfunctions_4_3_core.h
@@ -57,6 +57,13 @@
#include <QtGui/QOpenGLVersionFunctions>
#include <QtGui/qopenglcontext.h>
+// MemoryBarrier is a macro on some architectures on Windows
+#ifdef Q_OS_WIN
+#pragma push_macro("MemoryBarrier")
+#undef MemoryBarrier
+#endif
+
+
QT_BEGIN_NAMESPACE
class Q_GUI_EXPORT QOpenGLFunctions_4_3_Core : public QAbstractOpenGLFunctions
@@ -3230,6 +3237,10 @@ inline void QOpenGLFunctions_4_3_Core::glClearBufferData(GLenum target, GLenum i
QT_END_NAMESPACE
+#ifdef Q_OS_WIN
+#pragma pop_macro("MemoryBarrier")
+#endif
+
#endif // QT_NO_OPENGL && !QT_OPENGL_ES_2
#endif
diff --git a/src/gui/opengl/qopenglfunctions_4_4_compatibility.h b/src/gui/opengl/qopenglfunctions_4_4_compatibility.h
index 7a05bd802d..0acab349a1 100644
--- a/src/gui/opengl/qopenglfunctions_4_4_compatibility.h
+++ b/src/gui/opengl/qopenglfunctions_4_4_compatibility.h
@@ -59,6 +59,12 @@
QT_BEGIN_NAMESPACE
+// MemoryBarrier is a macro on some architectures on Windows
+#ifdef Q_OS_WIN
+#pragma push_macro("MemoryBarrier")
+#undef MemoryBarrier
+#endif
+
class Q_GUI_EXPORT QOpenGLFunctions_4_4_Compatibility : public QAbstractOpenGLFunctions
{
public:
@@ -5961,6 +5967,10 @@ inline void QOpenGLFunctions_4_4_Compatibility::glVertexP2ui(GLenum type, GLuint
QT_END_NAMESPACE
+#ifdef Q_OS_WIN
+#pragma pop_macro("MemoryBarrier")
+#endif
+
#endif // QT_NO_OPENGL && !QT_OPENGL_ES_2
#endif
diff --git a/src/gui/opengl/qopenglfunctions_4_4_core.h b/src/gui/opengl/qopenglfunctions_4_4_core.h
index 6b29a9659b..1ad6f40214 100644
--- a/src/gui/opengl/qopenglfunctions_4_4_core.h
+++ b/src/gui/opengl/qopenglfunctions_4_4_core.h
@@ -57,6 +57,12 @@
#include <QtGui/QOpenGLVersionFunctions>
#include <QtGui/qopenglcontext.h>
+// MemoryBarrier is a macro on some architectures on Windows
+#ifdef Q_OS_WIN
+#pragma push_macro("MemoryBarrier")
+#undef MemoryBarrier
+#endif
+
QT_BEGIN_NAMESPACE
class Q_GUI_EXPORT QOpenGLFunctions_4_4_Core : public QAbstractOpenGLFunctions
@@ -3415,6 +3421,10 @@ inline void QOpenGLFunctions_4_4_Core::glBufferStorage(GLenum target, GLsizeiptr
QT_END_NAMESPACE
+#ifdef Q_OS_WIN
+#pragma pop_macro("MemoryBarrier")
+#endif
+
#endif // QT_NO_OPENGL && !QT_OPENGL_ES_2
#endif
diff --git a/src/gui/opengl/qopenglfunctions_4_5_compatibility.h b/src/gui/opengl/qopenglfunctions_4_5_compatibility.h
index a809c1c90b..9d9d14548b 100644
--- a/src/gui/opengl/qopenglfunctions_4_5_compatibility.h
+++ b/src/gui/opengl/qopenglfunctions_4_5_compatibility.h
@@ -57,6 +57,12 @@
#include <QtGui/QOpenGLVersionFunctions>
#include <QtGui/qopenglcontext.h>
+// MemoryBarrier is a macro on some architectures on Windows
+#ifdef Q_OS_WIN
+#pragma push_macro("MemoryBarrier")
+#undef MemoryBarrier
+#endif
+
QT_BEGIN_NAMESPACE
class Q_GUI_EXPORT QOpenGLFunctions_4_5_Compatibility : public QAbstractOpenGLFunctions
@@ -6679,6 +6685,10 @@ inline void QOpenGLFunctions_4_5_Compatibility::glGetnMapdv(GLenum target, GLenu
QT_END_NAMESPACE
+#ifdef Q_OS_WIN
+#pragma pop_macro("MemoryBarrier")
+#endif
+
#endif // QT_NO_OPENGL && !QT_OPENGL_ES_2
#endif
diff --git a/src/gui/opengl/qopenglfunctions_4_5_core.h b/src/gui/opengl/qopenglfunctions_4_5_core.h
index bb1b17f7b1..bf872c628b 100644
--- a/src/gui/opengl/qopenglfunctions_4_5_core.h
+++ b/src/gui/opengl/qopenglfunctions_4_5_core.h
@@ -57,6 +57,12 @@
#include <QtGui/QOpenGLVersionFunctions>
#include <QtGui/qopenglcontext.h>
+// MemoryBarrier is a macro on some architectures on Windows
+#ifdef Q_OS_WIN
+#pragma push_macro("MemoryBarrier")
+#undef MemoryBarrier
+#endif
+
QT_BEGIN_NAMESPACE
class Q_GUI_EXPORT QOpenGLFunctions_4_5_Core : public QAbstractOpenGLFunctions
@@ -4056,6 +4062,11 @@ inline void QOpenGLFunctions_4_5_Core::glClipControl(GLenum origin, GLenum depth
QT_END_NAMESPACE
+#ifdef Q_OS_WIN
+#pragma pop_macro("MemoryBarrier")
+#endif
+
+
#endif // QT_NO_OPENGL && !QT_OPENGL_ES_2
#endif
diff --git a/src/gui/opengl/qopenglversionfunctions.h b/src/gui/opengl/qopenglversionfunctions.h
index f828e5668b..99c8565fbc 100644
--- a/src/gui/opengl/qopenglversionfunctions.h
+++ b/src/gui/opengl/qopenglversionfunctions.h
@@ -61,6 +61,12 @@
#include <QtCore/qpair.h>
#include <QtGui/qopengl.h>
+// MemoryBarrier is a macro on some architectures on Windows
+#ifdef Q_OS_WIN
+#pragma push_macro("MemoryBarrier")
+#undef MemoryBarrier
+#endif
+
QT_BEGIN_NAMESPACE
class QOpenGLContext;
@@ -1897,6 +1903,10 @@ public:
QT_END_NAMESPACE
+#ifdef Q_OS_WIN
+#pragma pop_macro("MemoryBarrier")
+#endif
+
#endif // QT_NO_OPENGL
#endif
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp
index fe7dd80e44..67783e5b42 100644
--- a/src/gui/text/qfontdatabase.cpp
+++ b/src/gui/text/qfontdatabase.cpp
@@ -733,7 +733,8 @@ void qt_registerFont(const QString &familyName, const QString &stylename,
const QSupportedWritingSystems &writingSystems, void *handle)
{
QFontDatabasePrivate *d = privateDb();
- qCDebug(lcFontDb) << "Adding font" << familyName << weight << style << pixelSize << "aa" << antialiased << "fixed" << fixedPitch;
+ qCDebug(lcFontDb) << "Adding font: familyName" << familyName << "stylename" << stylename << "weight" << weight
+ << "style" << style << "pixelSize" << pixelSize << "antialiased" << antialiased << "fixed" << fixedPitch;
QtFontStyle::Key styleKey;
styleKey.style = style;
styleKey.weight = weight;
diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp
index cf02e2f9c8..65cafc7bc2 100644
--- a/src/gui/text/qtextdocumentlayout.cpp
+++ b/src/gui/text/qtextdocumentlayout.cpp
@@ -1336,8 +1336,12 @@ void QTextDocumentLayoutPrivate::drawBlock(const QPointF &offset, QPainter *pain
tl->draw(painter, offset, selections, context.clip.isValid() ? (context.clip & clipRect) : clipRect);
- if ((context.cursorPosition >= blpos && context.cursorPosition < blpos + bllen)
- || (context.cursorPosition < -1 && !tl->preeditAreaText().isEmpty())) {
+ // if the block is empty and it precedes a table, do not draw the cursor.
+ // the cursor is drawn later after the table has been drawn so no need
+ // to draw it here.
+ if (!isEmptyBlockBeforeTable(frameIteratorForTextPosition(blpos))
+ && ((context.cursorPosition >= blpos && context.cursorPosition < blpos + bllen)
+ || (context.cursorPosition < -1 && !tl->preeditAreaText().isEmpty()))) {
int cpos = context.cursorPosition;
if (cpos < -1)
cpos = tl->preeditAreaPosition() - (cpos + 2);
diff --git a/src/openglextensions/qopenglextensions.cpp b/src/openglextensions/qopenglextensions.cpp
index 6413ae4a78..1660181e97 100644
--- a/src/openglextensions/qopenglextensions.cpp
+++ b/src/openglextensions/qopenglextensions.cpp
@@ -60,6 +60,12 @@
#include "qopenglextensions.h"
#include <QtGui/qopenglcontext.h>
+// MemoryBarrier is a macro on some architectures on Windows
+#ifdef Q_OS_WIN
+#pragma push_macro("MemoryBarrier")
+#undef MemoryBarrier
+#endif
+
QT_BEGIN_NAMESPACE
QAbstractOpenGLExtension::~QAbstractOpenGLExtension()
@@ -7720,3 +7726,6 @@ bool QOpenGLExtension_QCOM_tiled_rendering::initializeOpenGLFunctions()
QT_END_NAMESPACE
+#ifdef Q_OS_WIN
+#pragma pop_macro("MemoryBarrier")
+#endif
diff --git a/src/openglextensions/qopenglextensions.h b/src/openglextensions/qopenglextensions.h
index 439e0e6530..eb473f3699 100644
--- a/src/openglextensions/qopenglextensions.h
+++ b/src/openglextensions/qopenglextensions.h
@@ -66,6 +66,12 @@
#include <QtGui/qopengl.h>
+// MemoryBarrier is a macro on some architectures on Windows
+#ifdef Q_OS_WIN
+#pragma push_macro("MemoryBarrier")
+#undef MemoryBarrier
+#endif
+
QT_BEGIN_NAMESPACE
class QOpenGLContext;
@@ -19473,6 +19479,10 @@ inline void QOpenGLExtension_QCOM_tiled_rendering::glEndTilingQCOM(GLbitfield pr
QT_END_NAMESPACE
+#ifdef Q_OS_WIN
+#pragma pop_macro("MemoryBarrier")
+#endif
+
#endif // QT_NO_OPENGL
#endif
diff --git a/src/plugins/platforms/android/androidjniinput.cpp b/src/plugins/platforms/android/androidjniinput.cpp
index 9cdc5de0e1..56885f2e23 100644
--- a/src/plugins/platforms/android/androidjniinput.cpp
+++ b/src/plugins/platforms/android/androidjniinput.cpp
@@ -195,20 +195,6 @@ namespace QtAndroidInput
angleDelta);
}
- void releaseMouse(int x, int y)
- {
- m_ignoreMouseEvents = true;
- QPoint globalPos(x,y);
- QWindow *tlw = topLevelWindowAt(globalPos);
- QPoint localPos = tlw ? (globalPos-tlw->position()) : globalPos;
-
- // Release left button
- QWindowSystemInterface::handleMouseEvent(tlw,
- localPos,
- globalPos,
- Qt::MouseButtons(Qt::NoButton));
- }
-
static void longPress(JNIEnv */*env*/, jobject /*thiz*/, jint /*winId*/, jint x, jint y)
{
QAndroidInputContext *inputContext = QAndroidInputContext::androidInputContext();
diff --git a/src/plugins/platforms/android/androidjniinput.h b/src/plugins/platforms/android/androidjniinput.h
index 2e2470ae8f..cc3070c4aa 100644
--- a/src/plugins/platforms/android/androidjniinput.h
+++ b/src/plugins/platforms/android/androidjniinput.h
@@ -61,8 +61,6 @@ namespace QtAndroidInput
void updateHandles(int handleCount, QPoint editMenuPos = QPoint(), uint32_t editButtons = 0, QPoint cursor = QPoint(), QPoint anchor = QPoint(), bool rtl = false);
bool registerNatives(JNIEnv *env);
-
- void releaseMouse(int x, int y);
}
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/android/qandroidinputcontext.cpp b/src/plugins/platforms/android/qandroidinputcontext.cpp
index 5614d3b04f..e78c317863 100644
--- a/src/plugins/platforms/android/qandroidinputcontext.cpp
+++ b/src/plugins/platforms/android/qandroidinputcontext.cpp
@@ -827,9 +827,6 @@ void QAndroidInputContext::longPress(int x, int y)
focusObjectStopComposing();
- // Release left button, otherwise the following events will cancel the menu popup
- QtAndroidInput::releaseMouse(x, y);
-
const double pixelDensity =
QGuiApplication::focusWindow()
? QHighDpiScaling::factor(QGuiApplication::focusWindow())
diff --git a/src/plugins/platforms/cocoa/qprintengine_mac.mm b/src/plugins/platforms/cocoa/qprintengine_mac.mm
index 58ad53a6e1..dcb9a85a3c 100644
--- a/src/plugins/platforms/cocoa/qprintengine_mac.mm
+++ b/src/plugins/platforms/cocoa/qprintengine_mac.mm
@@ -59,6 +59,8 @@ QMacPrintEngine::QMacPrintEngine(QPrinter::PrinterMode mode, const QString &devi
QString id = deviceId;
if (id.isEmpty())
id = QCocoaPrinterSupport().defaultPrintDeviceId();
+ else
+ setProperty(QPrintEngine::PPK_PrinterName, deviceId);
d->m_printDevice.reset(new QCocoaPrintDevice(id));
d->m_pageLayout.setPageSize(d->m_printDevice->defaultPageSize());
d->initialize();
diff --git a/src/plugins/platforms/windows/qwindowsinputcontext.cpp b/src/plugins/platforms/windows/qwindowsinputcontext.cpp
index 8054f9fe83..bbfad7d712 100644
--- a/src/plugins/platforms/windows/qwindowsinputcontext.cpp
+++ b/src/plugins/platforms/windows/qwindowsinputcontext.cpp
@@ -280,13 +280,15 @@ void QWindowsInputContext::showInputPanel()
// with Windows 10 if the Windows IME is (re)enabled _after_ the caret is shown.
if (m_caretCreated) {
cursorRectChanged();
- // We only call ShowCaret() on Windows 10 as in earlier versions the caret
- // would actually be visible (QTBUG-74492) and the workaround for the
- // Surface seems unnecessary there anyway. But leave it hidden for IME.
- if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::Windows10)
+ // We only call ShowCaret() on Windows 10 after 1703 as in earlier versions
+ // the caret would actually be visible (QTBUG-74492) and the workaround for
+ // the Surface seems unnecessary there anyway. But leave it hidden for IME.
+ if (QOperatingSystemVersion::current() >=
+ QOperatingSystemVersion(QOperatingSystemVersion::Windows, 10, 0, 16299)) {
ShowCaret(platformWindow->handle());
- else
+ } else {
HideCaret(platformWindow->handle());
+ }
setWindowsImeEnabled(platformWindow, false);
setWindowsImeEnabled(platformWindow, true);
}
diff --git a/src/plugins/platforms/xcb/qxcbdrag.cpp b/src/plugins/platforms/xcb/qxcbdrag.cpp
index 1ce947165d..3d525598ca 100644
--- a/src/plugins/platforms/xcb/qxcbdrag.cpp
+++ b/src/plugins/platforms/xcb/qxcbdrag.cpp
@@ -354,6 +354,11 @@ bool QXcbDrag::findXdndAwareTarget(const QPoint &globalPos, xcb_window_t *target
void QXcbDrag::move(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods)
{
+ // currentDrag() might be deleted while 'drag' is progressing
+ if (!currentDrag()) {
+ cancel();
+ return;
+ }
// The source sends XdndEnter and XdndPosition to the target.
if (source_sameanswer.contains(globalPos) && source_sameanswer.isValid())
return;
@@ -1076,7 +1081,8 @@ void QXcbDrag::cancel()
send_leave();
// remove canceled object
- currentDrag()->deleteLater();
+ if (currentDrag())
+ currentDrag()->deleteLater();
canceled = true;
}
diff --git a/src/plugins/sqldrivers/odbc/qsql_odbc.cpp b/src/plugins/sqldrivers/odbc/qsql_odbc.cpp
index 7f98efccba..7709b13cd1 100644
--- a/src/plugins/sqldrivers/odbc/qsql_odbc.cpp
+++ b/src/plugins/sqldrivers/odbc/qsql_odbc.cpp
@@ -221,18 +221,18 @@ public:
int disconnectCount;
bool hasSQLFetchScroll;
- bool isStmtHandleValid();
+ bool isStmtHandleValid() const;
void updateStmtHandleState();
};
-bool QODBCResultPrivate::isStmtHandleValid()
+bool QODBCResultPrivate::isStmtHandleValid() const
{
- return disconnectCount == drv_d_func()->disconnectCount;
+ return drv_d_func() && disconnectCount == drv_d_func()->disconnectCount;
}
void QODBCResultPrivate::updateStmtHandleState()
{
- disconnectCount = drv_d_func()->disconnectCount;
+ disconnectCount = drv_d_func() ? drv_d_func()->disconnectCount : 0;
}
static QString qWarnODBCHandle(int handleType, SQLHANDLE handle, int *nativeCode = 0)
@@ -975,7 +975,7 @@ QODBCResult::QODBCResult(const QODBCDriver *db)
QODBCResult::~QODBCResult()
{
Q_D(QODBCResult);
- if (d->hStmt && d->isStmtHandleValid() && driver()->isOpen()) {
+ if (d->hStmt && d->isStmtHandleValid() && driver() && driver()->isOpen()) {
SQLRETURN r = SQLFreeHandle(SQL_HANDLE_STMT, d->hStmt);
if (r != SQL_SUCCESS)
qSqlWarning(QLatin1String("QODBCDriver: Unable to free statement handle ")
diff --git a/src/testlib/doc/snippets/code/src_qtestlib_qtestcase.cpp b/src/testlib/doc/snippets/code/src_qtestlib_qtestcase.cpp
index 202f87af52..5f71828595 100644
--- a/src/testlib/doc/snippets/code/src_qtestlib_qtestcase.cpp
+++ b/src/testlib/doc/snippets/code/src_qtestlib_qtestcase.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2019 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
@@ -296,3 +296,31 @@ QTest::keyClick(myWindow, Qt::Key_Escape, Qt::ShiftModifier, 200);
}
+//! [30]
+void TestQLocale::initTestCase_data()
+{
+ QTest::addColumn<QLocale>("locale");
+ QTest::newRow("C") << QLocale::c();
+ QTest::newRow("UKish") << QLocale("en_GB");
+ QTest::newRow("USAish") << QLocale(QLocale::English);
+}
+
+void TestQLocale::roundTripInt_data()
+{
+ QTest::addColumn<int>("number");
+ QTest::newRow("one") << 1;
+ QTest::newRow("two") << 2;
+ QTest::newRow("ten") << 10;
+}
+//! [30]
+
+//! [31]
+void TestQLocale::roundTripInt()
+{
+ QFETCH_GLOBAL(QLocale, locale);
+ QFETCH(int, number);
+ bool ok;
+ QCOMPARE(locale.toInt(locale.toString(number), &ok), number);
+ QVERIFY(ok);
+}
+//! [31]
diff --git a/src/testlib/doc/src/qttestlib-manual.qdoc b/src/testlib/doc/src/qttestlib-manual.qdoc
index 71b4541313..ee7767b5a5 100644
--- a/src/testlib/doc/src/qttestlib-manual.qdoc
+++ b/src/testlib/doc/src/qttestlib-manual.qdoc
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2019 The Qt Company Ltd.
** Copyright (C) 2016 Intel Corporation.
** Contact: https://www.qt.io/licensing/
**
@@ -89,12 +89,14 @@
private slot is a test function in your test. QTest::qExec() can be used to execute
all test functions in the test object.
- In addition, there are four private slots that are \e not treated as test functions.
- They will be executed by the testing framework and can be used to initialize and
- clean up either the entire test or the current test function.
+ In addition, you can define the following private slots that are \e not
+ treated as test functions. When present, they will be executed by the
+ testing framework and can be used to initialize and clean up either the
+ entire test or the current test function.
\list
\li \c{initTestCase()} will be called before the first test function is executed.
+ \li \c{initTestCase_data()} will be called to create a global test data table.
\li \c{cleanupTestCase()} will be called after the last test function was executed.
\li \c{init()} will be called before each test function is executed.
\li \c{cleanup()} will be called after every test function.
@@ -353,18 +355,44 @@
counters can be obtained by running any benchmark executable with the
option \c -perfcounterlist.
- \list
- \li \b Notes:
+ \note
\list
\li Using the performance counter may require enabling access to non-privileged
applications.
\li Devices that do not support high-resolution timers default to
one-millisecond granularity.
\endlist
- \endlist
See \l {Chapter 5: Writing a Benchmark}{Writing a Benchmark} in the Qt Test
Tutorial for more benchmarking examples.
+
+ \section1 Using Global Test Data
+
+ You can define \c{initTestCase_data()} to set up a global test data table.
+ Each test is run once for each row in the global test data table. When the
+ test function itself \l{Chapter 2: Data-driven Testing}{is data-driven},
+ it is run for each local data row, for each global data row. So, if there
+ are \c g rows in the global data table and \c d rows in the test's own
+ data-table, the number of runs of this test is \c g times \c d.
+
+ Global data is fetched from the table using the \l QFETCH_GLOBAL() macro.
+
+ The following are typical use cases for global test data:
+
+ \list
+ \li Selecting among the available database backends in QSql tests to run
+ every test against every database.
+ \li Doing all networking tests with and without SSL (HTTP versus HTTPS)
+ and proxying.
+ \li Testing a timer with a high precision clock and with a coarse one.
+ \li Selecting whether a parser shall read from a QByteArray or from a
+ QIODevice.
+ \endlist
+
+ For example, to test each number provided by \c {roundTripInt_data()} with
+ each locale provided by \c {initTestCase_data()}:
+
+ \snippet code/src_qtestlib_qtestcase.cpp 31
*/
/*!
@@ -508,10 +536,9 @@
QTest::newRow() function. Each set of data will become a
separate row in the test table.
- \l QTest::newRow() takes one argument: a name that will be
- associated with the data set. If the test fails, the name will be
- used in the test log, referencing the failed data. Then we
- stream the data set into the new table row. First an arbitrary
+ \l QTest::newRow() takes one argument: a name that will be associated
+ with the data set and used in the test log to identify the data set.
+ Then we stream the data set into the new table row. First an arbitrary
string, and then the expected result of applying the
QString::toUpper() function to that string.
@@ -543,6 +570,10 @@
\li HELLO
\endtable
+ When data is streamed into the row, each datum is asserted to match
+ the type of the column whose value it supplies. If any assertion fails,
+ the test is aborted.
+
\section1 Rewriting the Test Function
Our test function can now be rewritten:
diff --git a/src/testlib/qsignalspy.qdoc b/src/testlib/qsignalspy.qdoc
index 3352307d69..39639d0a09 100644
--- a/src/testlib/qsignalspy.qdoc
+++ b/src/testlib/qsignalspy.qdoc
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2019 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
@@ -48,7 +48,7 @@
\snippet code/doc_src_qsignalspy.cpp 1
- \b {Note:} Non-standard data types need to be registered, using
+ \note Non-standard data types need to be registered, using
the qRegisterMetaType() function, before you can create a
QSignalSpy. For example:
@@ -57,6 +57,18 @@
To retrieve the instance, you can use qvariant_cast:
\snippet code/doc_src_qsignalspy.cpp 3
+
+ \section1 Verifying Signal Emissions
+
+ The QSignalSpy class provides an elegant mechanism for capturing the list
+ of signals emitted by an object. However, you should verify its validity
+ after construction. The constructor does a number of sanity checks, such as
+ verifying that the signal to be spied upon actually exists. To make the
+ diagnosis of test failures easier, the results of these checks should be
+ checked by calling \c QVERIFY(spy.isValid()) before proceeding further with
+ a test.
+
+ \sa QVERIFY()
*/
/*! \fn QSignalSpy::QSignalSpy(const QObject *object, const char *signal)
diff --git a/src/testlib/qtestcase.qdoc b/src/testlib/qtestcase.qdoc
index 2af016304d..9006d7b401 100644
--- a/src/testlib/qtestcase.qdoc
+++ b/src/testlib/qtestcase.qdoc
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2019 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
@@ -220,8 +220,8 @@
\relates QTest
The fetch macro creates a local variable named \a name with the type \a type
- on the stack. \a name has to match the element name from the test's data.
- If no such element exists, the test will assert.
+ on the stack. The \a name and \a type must match a column from the test's
+ data table. This is asserted and the test will abort if the assertion fails.
Assuming a test has the following data:
@@ -235,10 +235,37 @@
\c aString and \c expected are variables on the stack that are initialized with
the current test data.
- \b {Note:} This macro can only be used in a test function that is invoked
+ \note This macro can only be used in a test function that is invoked
by the test framework. The test function must have a _data function.
*/
+/*! \macro QFETCH_GLOBAL(type, name)
+
+ \relates QTest
+
+ This macro fetches a variable named \a name with the type \a type from
+ a row in the global data table. The \a name and \a type must match a
+ column in the global data table. This is asserted and the test will abort
+ if the assertion fails.
+
+ Assuming a test has the following data:
+
+ \snippet code/src_qtestlib_qtestcase.cpp 30
+
+ The test's own data is a single number per row. In this case,
+ \c initTestCase_data() also supplies a locale per row. Therefore,
+ this test will be run with every combination of locale from the
+ latter and number from the former.
+
+ \snippet code/src_qtestlib_qtestcase.cpp 31
+
+ The locale is read from the global data table using QFETCH_GLOBAL(),
+ and the number is read from the local data table using QFETCH().
+
+ \note This macro can only be used in test methods of a class with an
+ \c initTestCase_data() method.
+*/
+
/*! \macro QWARN(message)
\relates QTest
@@ -255,7 +282,7 @@
This macro can be used to force a test failure. The test stops
executing and the failure \a message is appended to the test log.
- \b {Note:} This macro can only be used in a test function that is invoked
+ \note This macro can only be used in a test function that is invoked
by the test framework.
Example:
@@ -332,7 +359,7 @@
\a mode is a \l QTest::TestFailMode and sets whether the test should
continue to execute or not.
- \b {Note:} This macro can only be used in a test function that is invoked
+ \note This macro can only be used in a test function that is invoked
by the test framework.
Example 1:
@@ -394,13 +421,13 @@
test has been installed, and regardless of whether the test's build tree
is equal to the test's source tree.
- \b {Note:} reliable detection of testdata from the source directory requires
+ \note reliable detection of testdata from the source directory requires
either that qmake is used, or the \c{QT_TESTCASE_BUILDDIR} macro is defined to
point to the working directory from which the compiler is invoked, or only
absolute paths to the source files are passed to the compiler. Otherwise, the
absolute path of the source directory cannot be determined.
- \b {Note:} For tests that use the \l QTEST_APPLESS_MAIN() macro to generate a
+ \note For tests that use the \l QTEST_APPLESS_MAIN() macro to generate a
\c{main()} function, \c{QFINDTESTDATA} will not attempt to find test data
relative to QCoreApplication::applicationDirPath(). In practice, this means that
tests using \c{QTEST_APPLESS_MAIN()} will fail to find their test data
@@ -422,7 +449,7 @@
Similarly, if qmake is used and the configuration includes \c{QT += gui}, then
\c QT_GUI_LIB will be defined automatically.
- \b {Note:} On platforms that have keypad navigation enabled by default,
+ \note On platforms that have keypad navigation enabled by default,
this macro will forcefully disable it if \c QT_WIDGETS_LIB is defined. This is done
to simplify the usage of key events when writing autotests. If you wish to write a
test case that uses keypad navigation, you should enable it either in the
@@ -662,7 +689,7 @@
Simulates pressing a \a key with an optional \a modifier on a \a widget. If \a delay
is larger than 0, the test will wait for \a delay milliseconds before pressing the key.
- \b {Note:} At some point you should release the key using \l keyRelease().
+ \note At some point you should release the key using \l keyRelease().
\sa QTest::keyRelease(), QTest::keyClick()
*/
@@ -674,7 +701,7 @@
If \a delay is larger than 0, the test will wait for \a delay milliseconds
before pressing the key.
- \b {Note:} At some point you should release the key using \l keyRelease().
+ \note At some point you should release the key using \l keyRelease().
\sa QTest::keyRelease(), QTest::keyClick()
*/
@@ -686,7 +713,7 @@
Simulates pressing a \a key with an optional \a modifier on a \a window. If \a delay
is larger than 0, the test will wait for \a delay milliseconds before pressing the key.
- \b {Note:} At some point you should release the key using \l keyRelease().
+ \note At some point you should release the key using \l keyRelease().
\sa QTest::keyRelease(), QTest::keyClick()
*/
@@ -699,7 +726,7 @@
If \a delay is larger than 0, the test will wait for \a delay milliseconds
before pressing the key.
- \b {Note:} At some point you should release the key using \l keyRelease().
+ \note At some point you should release the key using \l keyRelease().
\sa QTest::keyRelease(), QTest::keyClick()
*/
@@ -920,12 +947,12 @@
You can add specializations or overloads of this function to your test to enable
verbose output.
- \b {Note:} Starting with Qt 5.5, you should prefer to provide a toString() function
+ \note Starting with Qt 5.5, you should prefer to provide a toString() function
in the type's namespace instead of specializing this template.
If your code needs to continue to work with the QTestLib from Qt 5.4 or
earlier, you need to continue to use specialization.
- \b {Note:} The caller of toString() must delete the returned data
+ \note The caller of toString() must delete the returned data
using \c{delete[]}. Your implementation should return a string
created with \c{new[]} or qstrdup(). The easiest way to do so is to
create a QByteArray or QString and calling QTest::toString() on it
diff --git a/src/widgets/dialogs/qcolordialog.cpp b/src/widgets/dialogs/qcolordialog.cpp
index 1cb6cb8a2d..197d1d940b 100644
--- a/src/widgets/dialogs/qcolordialog.cpp
+++ b/src/widgets/dialogs/qcolordialog.cpp
@@ -499,7 +499,7 @@ void QWellArray::keyPressEvent(QKeyEvent* e)
// Event filter to be installed on the dialog while in color-picking mode.
class QColorPickingEventFilter : public QObject {
public:
- explicit QColorPickingEventFilter(QColorDialogPrivate *dp, QObject *parent = 0) : QObject(parent), m_dp(dp) {}
+ explicit QColorPickingEventFilter(QColorDialogPrivate *dp, QObject *parent) : QObject(parent), m_dp(dp) {}
bool eventFilter(QObject *, QEvent *event) override
{
@@ -1606,7 +1606,7 @@ void QColorDialogPrivate::_q_pickScreenColor()
{
Q_Q(QColorDialog);
if (!colorPickingEventFilter)
- colorPickingEventFilter = new QColorPickingEventFilter(this);
+ colorPickingEventFilter = new QColorPickingEventFilter(this, q);
q->installEventFilter(colorPickingEventFilter);
// If user pushes Escape, the last color before picking will be restored.
beforeScreenColorPicking = cs->currentColor();
diff --git a/src/widgets/doc/snippets/code/doc_src_stylesheet.qdoc b/src/widgets/doc/snippets/code/doc_src_stylesheet.qdoc
index 098eaf4717..b0d042566f 100644
--- a/src/widgets/doc/snippets/code/doc_src_stylesheet.qdoc
+++ b/src/widgets/doc/snippets/code/doc_src_stylesheet.qdoc
@@ -1107,10 +1107,10 @@ QMenu::indicator:exclusive:checked:selected {
QMenuBar {
background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1,
stop:0 lightgray, stop:1 darkgray);
+ spacing: 3px; /* spacing between menu bar items */
}
QMenuBar::item {
- spacing: 3px; /* spacing between menu bar items */
padding: 1px 4px;
background: transparent;
border-radius: 4px;
diff --git a/src/widgets/graphicsview/qgraphicsscene.cpp b/src/widgets/graphicsview/qgraphicsscene.cpp
index 5238ea2f5c..03717d5d1a 100644
--- a/src/widgets/graphicsview/qgraphicsscene.cpp
+++ b/src/widgets/graphicsview/qgraphicsscene.cpp
@@ -386,7 +386,15 @@ void QGraphicsScenePrivate::_q_emitUpdated()
// Notify the changes to anybody interested.
QList<QRectF> oldUpdatedRects;
- oldUpdatedRects = updateAll ? (QList<QRectF>() << q->sceneRect()) : updatedRects;
+ if (updateAll) {
+ oldUpdatedRects << q->sceneRect();
+ } else {
+ // Switch to a ranged constructor in Qt 6...
+ oldUpdatedRects.reserve(int(updatedRects.size()));
+ std::copy(updatedRects.cbegin(), updatedRects.cend(),
+ std::back_inserter(oldUpdatedRects));
+ }
+
updateAll = false;
updatedRects.clear();
emit q->changed(oldUpdatedRects);
@@ -3219,8 +3227,7 @@ void QGraphicsScene::update(const QRectF &rect)
view->d_func()->updateRectF(rect);
}
} else {
- if (!d->updatedRects.contains(rect))
- d->updatedRects << rect;
+ d->updatedRects.insert(rect);
}
}
diff --git a/src/widgets/graphicsview/qgraphicsscene_p.h b/src/widgets/graphicsview/qgraphicsscene_p.h
index a2d13436fc..14bafe6678 100644
--- a/src/widgets/graphicsview/qgraphicsscene_p.h
+++ b/src/widgets/graphicsview/qgraphicsscene_p.h
@@ -69,6 +69,9 @@
#include <QtWidgets/qstyle.h>
#include <QtWidgets/qstyleoption.h>
+#include <set>
+#include <tuple>
+
QT_REQUIRE_CONFIG(graphicsview);
QT_BEGIN_NAMESPACE
@@ -122,7 +125,19 @@ public:
QRectF growingItemsBoundingRect;
void _q_emitUpdated();
- QList<QRectF> updatedRects;
+
+ struct UpdatedRectsCmp
+ {
+ bool operator() (const QRectF &a, const QRectF &b) const noexcept
+ {
+ return std::make_tuple(a.y(), a.x(), a.height(), a.width())
+ < std::make_tuple(b.y(), b.x(), b.height(), b.width());
+ }
+ };
+
+ // std::set was used here instead of std::unordered_set due to requiring only a comparator and
+ // showing equivalent performance in empirical measurements within the ranges of interest...
+ std::set<QRectF, UpdatedRectsCmp> updatedRects;
QPainterPath selectionArea;
int selectionChanging;
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index 0fa5907744..048a17364b 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -1,4 +1,4 @@
-/****************************************************************************
+/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
** Copyright (C) 2016 Intel Corporation.
@@ -8460,6 +8460,8 @@ void QWidgetPrivate::showChildren(bool spontaneous)
QList<QObject*> childList = children;
for (int i = 0; i < childList.size(); ++i) {
QWidget *widget = qobject_cast<QWidget*>(childList.at(i));
+ if (widget && widget->windowHandle() && !widget->testAttribute(Qt::WA_WState_ExplicitShowHide))
+ widget->setAttribute(Qt::WA_WState_Hidden, false);
if (!widget
|| widget->isWindow()
|| widget->testAttribute(Qt::WA_WState_Hidden))
diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp
index aad505ed29..878e484ab8 100644
--- a/src/widgets/kernel/qwidgetwindow.cpp
+++ b/src/widgets/kernel/qwidgetwindow.cpp
@@ -72,10 +72,18 @@ public:
void setVisible(bool visible) override
{
Q_Q(QWidgetWindow);
- if (QWidget *widget = q->widget())
+ if (QWidget *widget = q->widget()) {
+ // Check if the widget was already hidden, as this indicates it was done
+ // explicitly and not because the parent window in this case made it hidden.
+ // In which case do not automatically show the widget when the parent
+ // window is shown.
+ const bool wasHidden = widget->testAttribute(Qt::WA_WState_Hidden);
QWidgetPrivate::get(widget)->setVisible(visible);
- else
+ if (!wasHidden)
+ widget->setAttribute(Qt::WA_WState_ExplicitShowHide, false);
+ } else {
QWindowPrivate::setVisible(visible);
+ }
}
QWindow *eventReceiver() override {
diff --git a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp
index 1379c788d1..40023d7fea 100644
--- a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp
+++ b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp
@@ -465,16 +465,6 @@ void tst_qstandardpaths::testRuntimeDirectory()
#ifdef Q_XDG_PLATFORM
const QString runtimeDir = QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation);
QVERIFY(!runtimeDir.isEmpty());
-
- // Check that it can automatically fix permissions
- QFile file(runtimeDir);
- const QFile::Permissions wantedPerms = QFile::ReadUser | QFile::WriteUser | QFile::ExeUser;
- const QFile::Permissions additionalPerms = QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner;
- QCOMPARE(file.permissions(), wantedPerms | additionalPerms);
- QVERIFY(file.setPermissions(wantedPerms | QFile::ExeGroup));
- const QString runtimeDirAgain = QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation);
- QCOMPARE(runtimeDirAgain, runtimeDir);
- QCOMPARE(QFile(runtimeDirAgain).permissions(), wantedPerms | additionalPerms);
#endif
}
@@ -516,11 +506,27 @@ void tst_qstandardpaths::testCustomRuntimeDirectory()
const QString runtimeDir = QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation);
QVERIFY2(runtimeDir.isEmpty(), qPrintable(runtimeDir));
- // When $XDG_RUNTIME_DIR points to a non-existing directory, QStandardPaths should warn (QTBUG-48771)
- qputenv("XDG_RUNTIME_DIR", "does_not_exist");
- QTest::ignoreMessage(QtWarningMsg, "QStandardPaths: XDG_RUNTIME_DIR points to non-existing path 'does_not_exist', please create it with 0700 permissions.");
+ // When $XDG_RUNTIME_DIR points to a directory with wrong permissions, QStandardPaths should warn
+ const QByteArray wrongPermissionFileName = "wrong_permissions";
+ QDir::current().mkdir(wrongPermissionFileName);
+ QFile wrongPermissionFile(wrongPermissionFileName);
+ const QFile::Permissions wantedPerms = QFile::ReadUser | QFile::WriteUser | QFile::ExeUser;
+ QVERIFY(wrongPermissionFile.setPermissions(wantedPerms | QFile::ExeGroup));
+
+ qputenv("XDG_RUNTIME_DIR", wrongPermissionFileName);
+ QTest::ignoreMessage(QtWarningMsg,
+ qPrintable(QString::fromLatin1("QStandardPaths: wrong permissions on runtime directory " + wrongPermissionFileName + ", 7710 instead of 7700")));
+ const QString wrongPermissionRuntimeDir = QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation);
+ QVERIFY(wrongPermissionRuntimeDir.isEmpty());
+ QDir::current().rmdir(wrongPermissionFileName);
+
+ // When $XDG_RUNTIME_DIR points to a non-existing directory, QStandardPaths should create it first
+ const QByteArray nonExistingDir = "does_not_exist";
+ qputenv("XDG_RUNTIME_DIR", nonExistingDir);
const QString nonExistingRuntimeDir = QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation);
- QVERIFY2(nonExistingRuntimeDir.isEmpty(), qPrintable(nonExistingRuntimeDir));
+ QVERIFY2(!nonExistingRuntimeDir.compare(nonExistingDir), qPrintable(nonExistingRuntimeDir));
+ QVERIFY(QDir::current().exists(nonExistingRuntimeDir));
+ QDir::current().rmdir(nonExistingRuntimeDir);
// When $XDG_RUNTIME_DIR points to a file, QStandardPaths should warn
const QString file = QFINDTESTDATA("tst_qstandardpaths.cpp");
diff --git a/tests/auto/corelib/serialization/qdatastream_core_pixmap/tst_qdatastream_core_pixmap.cpp b/tests/auto/corelib/serialization/qdatastream_core_pixmap/tst_qdatastream_core_pixmap.cpp
index c931016a61..cf5ead1220 100644
--- a/tests/auto/corelib/serialization/qdatastream_core_pixmap/tst_qdatastream_core_pixmap.cpp
+++ b/tests/auto/corelib/serialization/qdatastream_core_pixmap/tst_qdatastream_core_pixmap.cpp
@@ -27,13 +27,8 @@
****************************************************************************/
#include <QtTest/QtTest>
-#include <QtGui/QBitmap>
-#include <QtGui/QPalette>
#include <QtGui/QPixmap>
-#include <QtGui/QPicture>
-#include <QtGui/QTextLength>
-#include <QtGui/QPainter>
-#include <QtGui/QPen>
+#include <QtGui/QImage>
class tst_QDataStream : public QObject
{
@@ -41,16 +36,20 @@ Q_OBJECT
private slots:
void stream_with_pixmap();
-
};
void tst_QDataStream::stream_with_pixmap()
{
// This is a QVariantMap with a 3x3 red QPixmap and two strings inside
- const QByteArray ba = QByteArray::fromBase64("AAAAAwAAAAIAegAAAAoAAAAACgB0AGgAZQByAGUAAAACAHAAAABBAAAAAAGJUE5HDQoaCgAAAA1JSERSAAAAAwAAAAMIAgAAANlKIugAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAAQSURBVAiZY/zPAAVMDJgsAB1bAQXZn5ieAAAAAElFTkSuQmCCAAAAAgBhAAAACgAAAAAKAGgAZQBsAGwAbw==");
+ const QByteArray ba = QByteArray::fromBase64(
+ "AAAAAwAAAAIAegAAAAoAAAAACgB0AGgAZQByAGUAAAACAHAAAABBAAAAAAGJUE5H"
+ "DQoaCgAAAA1JSERSAAAAAwAAAAMIAgAAANlKIugAAAAJcEhZcwAADsQAAA7EAZUr"
+ "DhsAAAAQSURBVAiZY/zPAAVMDJgsAB1bAQXZn5ieAAAAAElFTkSuQmCCAAAAAgBh"
+ "AAAACgAAAAAKAGgAZQBsAGwAbw==");
QImage dummy; // Needed to make sure qtGui is loaded
- QTest::ignoreMessage(QtWarningMsg, "QPixmap::fromImageInPlace: QPixmap cannot be created without a QGuiApplication");
+ QTest::ignoreMessage(QtWarningMsg, "QPixmap::fromImageInPlace: "
+ "QPixmap cannot be created without a QGuiApplication");
QVariantMap map;
QDataStream d(ba);
@@ -58,11 +57,11 @@ void tst_QDataStream::stream_with_pixmap()
d >> map;
QCOMPARE(map["a"].toString(), QString("hello"));
- QCOMPARE(map["p"].value<QPixmap>(), QPixmap()); // the pixmap is null because this is not a QGuiApplication
+ // The pixmap is null because this is not a QGuiApplication:
+ QCOMPARE(map["p"].value<QPixmap>(), QPixmap());
QCOMPARE(map["z"].toString(), QString("there"));
}
QTEST_GUILESS_MAIN(tst_QDataStream)
#include "tst_qdatastream_core_pixmap.moc"
-
diff --git a/tests/auto/corelib/serialization/serialization.pro b/tests/auto/corelib/serialization/serialization.pro
index 9638178cdc..f4a5a3c5b1 100644
--- a/tests/auto/corelib/serialization/serialization.pro
+++ b/tests/auto/corelib/serialization/serialization.pro
@@ -11,7 +11,8 @@ SUBDIRS = \
qxmlstream
!qtHaveModule(gui): SUBDIRS -= \
- qdatastream
+ qdatastream \
+ qdatastream_core_pixmap
!qtHaveModule(network): SUBDIRS -= \
qtextstream
diff --git a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp
index e97848fb1c..0fe24ed5cb 100644
--- a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp
+++ b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp
@@ -40,6 +40,7 @@
#include "nontracked.h"
#include "wrapper.h"
+#include <array>
#include <memory>
#include <stdlib.h>
#include <time.h>
@@ -105,12 +106,15 @@ private slots:
void sharedFromThis();
void constructorThrow();
+ void overloads();
void threadStressTest_data();
void threadStressTest();
void validConstructs();
void invalidConstructs_data();
void invalidConstructs();
+
+
// let invalidConstructs be the last test, because it's the slowest;
// add new tests above this block
public slots:
@@ -2250,6 +2254,11 @@ void tst_QSharedPointer::invalidConstructs_data()
<< &QTest::QExternalTest::tryCompileFail
<< "QSharedPointer<Data> ptr(new Data, [](int *) {});\n";
#endif
+
+ QTest::newRow("incompatible-overload")
+ << &QTest::QExternalTest::tryCompileFail
+ << "void foo(QSharedPointer<DerivedData>) {}\n"
+ "void bar() { foo(QSharedPointer<Data>()); }\n";
}
void tst_QSharedPointer::invalidConstructs()
@@ -2748,5 +2757,50 @@ void tst_QSharedPointer::reentrancyWhileDestructing()
ReentrancyWhileDestructing::A obj;
}
+namespace {
+struct Base1 {};
+struct Base2 {};
+
+struct Child1 : Base1 {};
+struct Child2 : Base2 {};
+
+template<template<typename> class SmartPtr>
+struct Overloaded
+{
+ std::array<int, 1> call(const SmartPtr<const Base1> &)
+ {
+ return {};
+ }
+ std::array<int, 2> call(const SmartPtr<const Base2> &)
+ {
+ return {};
+ }
+ static const Q_CONSTEXPR uint base1Called = sizeof(std::array<int, 1>);
+ static const Q_CONSTEXPR uint base2Called = sizeof(std::array<int, 2>);
+
+ void test()
+ {
+#define QVERIFY_CALLS(expr, base) Q_STATIC_ASSERT(sizeof(call(expr)) == base##Called)
+ QVERIFY_CALLS(SmartPtr<Base1>{}, base1);
+ QVERIFY_CALLS(SmartPtr<Base2>{}, base2);
+ QVERIFY_CALLS(SmartPtr<const Base1>{}, base1);
+ QVERIFY_CALLS(SmartPtr<const Base2>{}, base2);
+ QVERIFY_CALLS(SmartPtr<Child1>{}, base1);
+ QVERIFY_CALLS(SmartPtr<Child2>{}, base2);
+ QVERIFY_CALLS(SmartPtr<const Child1>{}, base1);
+ QVERIFY_CALLS(SmartPtr<const Child2>{}, base2);
+#undef QVERIFY_CALLS
+ }
+};
+}
+
+void tst_QSharedPointer::overloads()
+{
+ Overloaded<QSharedPointer> sharedOverloaded;
+ sharedOverloaded.test();
+ Overloaded<QWeakPointer> weakOverloaded;
+ weakOverloaded.test();
+}
+
QTEST_MAIN(tst_QSharedPointer)
#include "tst_qsharedpointer.moc"
diff --git a/tests/auto/other/other.pro b/tests/auto/other/other.pro
index c5426202e8..cc6b1887a3 100644
--- a/tests/auto/other/other.pro
+++ b/tests/auto/other/other.pro
@@ -68,7 +68,4 @@ winrt|!qtHaveModule(gui)|!qtConfig(accessibility): SUBDIRS -= qaccessibility
android: SUBDIRS += \
android
-qtConfig(xkbcommon): {
- SUBDIRS += \
- xkbkeyboard
-}
+qtHaveModule(gui):qtConfig(xkbcommon): SUBDIRS += xkbkeyboard
diff --git a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
index 784d0a70d7..fd7f24f308 100644
--- a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+++ b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
@@ -196,8 +196,7 @@ private slots:
void task_250026_data() { generic_data("QODBC"); }
void task_250026();
- void task_205701_data() { generic_data("QMYSQL"); }
- void task_205701();
+ void crashQueryOnCloseDatabase();
void task_233829_data() { generic_data("QPSQL"); }
void task_233829();
@@ -311,6 +310,8 @@ void tst_QSqlQuery::init()
void tst_QSqlQuery::cleanup()
{
+ if (QTest::currentTestFunction() == QLatin1String("crashQueryOnCloseDatabase"))
+ return;
QFETCH( QString, dbName );
QSqlDatabase db = QSqlDatabase::database( dbName );
CHECK_DATABASE( db );
@@ -3448,19 +3449,17 @@ void tst_QSqlQuery::task_250026()
QCOMPARE( q.value( 0 ).toString().length(), data1026.length() );
}
-void tst_QSqlQuery::task_205701()
+void tst_QSqlQuery::crashQueryOnCloseDatabase()
{
- QSqlDatabase qsdb = QSqlDatabase::addDatabase("QMYSQL", "atest");
- qsdb.setHostName("test");
- qsdb.setDatabaseName("test");
- qsdb.setUserName("test");
- qsdb.setPassword("test");
- qsdb.open();
-
-// {
- QSqlQuery query(qsdb);
-// }
- QSqlDatabase::removeDatabase("atest");
+ for (const auto &dbName : qAsConst(dbs.dbNames)) {
+ QSqlDatabase clonedDb = QSqlDatabase::cloneDatabase(
+ QSqlDatabase::database(dbName), "crashTest");
+ qDebug() << "Testing crash in sqlquery dtor for driver" << clonedDb.driverName();
+ QVERIFY(clonedDb.open());
+ QSqlQuery q(clonedDb);
+ clonedDb.close();
+ QSqlDatabase::removeDatabase("crashTest");
+ }
}
#ifdef NOT_READY_YET
diff --git a/tests/auto/widgets/graphicsview/qgraphicspixmapitem/tst_qgraphicspixmapitem.cpp b/tests/auto/widgets/graphicsview/qgraphicspixmapitem/tst_qgraphicspixmapitem.cpp
index 78fe448bdb..843a30df16 100644
--- a/tests/auto/widgets/graphicsview/qgraphicspixmapitem/tst_qgraphicspixmapitem.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicspixmapitem/tst_qgraphicspixmapitem.cpp
@@ -156,6 +156,14 @@ void tst_QGraphicsPixmapItem::contains()
QFETCH(QPointF, point);
QFETCH(bool, contains);
+ // At the time of writing, by default pixmaps will have:
+ // - The same pixel format of the primary screen (which is platform dependent and may contain alpha)
+ // - Uninitialized pixels, potentially including an alpha channel
+ // - A ShapeMode of Mask (which mean it will use the alpha channel as a mask for contains())
+ // This means that in order to prevent undefined behavior in this test, we either need to set
+ // the shapeMode to something else, or set the pixels of the pixmap.
+ pixmap.fill(); // Filling the pixmap to be on the safe side.
+
SubQGraphicsPixmapItem item(pixmap);
QCOMPARE(item.contains(point), contains);
}
diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
index 46f1d5df5c..4f8741a5aa 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
@@ -3685,8 +3685,6 @@ void tst_QGraphicsScene::changedSignal()
qApp->processEvents();
QCOMPARE(cl.changes.size(), 2);
QCOMPARE(cl.changes.at(1).size(), 2);
- QCOMPARE(cl.changes.at(1).first(), QRectF(0, 0, 10, 10));
- QCOMPARE(cl.changes.at(1).last(), QRectF(20, 0, 10, 10));
QCOMPARE(scene.sceneRect(), QRectF(0, 0, 30, 10));
diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
index a95d6e76b3..ebf08883fd 100644
--- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
+++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
@@ -399,6 +399,7 @@ private slots:
void tabletTracking();
void closeEvent();
+ void closeWithChildWindow();
private:
bool ensureScreenSize(int width, int height);
@@ -11115,5 +11116,27 @@ void tst_QWidget::closeEvent()
QCOMPARE(widget.closeCount, 1);
}
+void tst_QWidget::closeWithChildWindow()
+{
+ QWidget widget;
+ auto childWidget = new QWidget(&widget);
+ childWidget->setAttribute(Qt::WA_NativeWindow);
+ childWidget->windowHandle()->create();
+ widget.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&widget));
+ widget.windowHandle()->close();
+ widget.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&widget));
+ // Check that the child window inside the window is now visible
+ QVERIFY(childWidget->isVisible());
+
+ // Now explicitly hide the childWidget
+ childWidget->hide();
+ widget.windowHandle()->close();
+ widget.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&widget));
+ QVERIFY(!childWidget->isVisible());
+}
+
QTEST_MAIN(tst_QWidget)
#include "tst_qwidget.moc"