summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/global/qglobal.cpp12
-rw-r--r--src/corelib/global/qglobal.h14
-rw-r--r--src/corelib/io/qfilesystemengine_win.cpp3
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp4
-rw-r--r--src/corelib/kernel/qobject.cpp18
-rw-r--r--src/corelib/kernel/qtestsupport_core.h8
-rw-r--r--src/corelib/tools/qlocale.cpp2
-rw-r--r--src/corelib/tools/qsimd.cpp2
8 files changed, 48 insertions, 15 deletions
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index b17125d4ab..8d80a32ad5 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -2901,18 +2901,18 @@ enum {
QByteArray QSysInfo::machineUniqueId()
{
#ifdef Q_OS_BSD4
- char uuid[UuidStringLen];
+ char uuid[UuidStringLen + 1];
size_t uuidlen = sizeof(uuid);
# ifdef KERN_HOSTUUID
int name[] = { CTL_KERN, KERN_HOSTUUID };
if (sysctl(name, sizeof name / sizeof name[0], &uuid, &uuidlen, nullptr, 0) == 0
&& uuidlen == sizeof(uuid))
- return QByteArray(uuid, uuidlen);
+ return QByteArray(uuid, uuidlen - 1);
# else
// Darwin: no fixed value, we need to search by name
if (sysctlbyname("kern.uuid", uuid, &uuidlen, nullptr, 0) == 0 && uuidlen == sizeof(uuid))
- return QByteArray(uuid, uuidlen);
+ return QByteArray(uuid, uuidlen - 1);
# endif
#elif defined(Q_OS_UNIX)
// The modern name on Linux is /etc/machine-id, but that path is
@@ -2935,7 +2935,7 @@ QByteArray QSysInfo::machineUniqueId()
#elif defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
// Let's poke at the registry
HKEY key = NULL;
- if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Cryptography", 0, KEY_READ, &key)
+ if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Cryptography", 0, KEY_READ | KEY_WOW64_64KEY, &key)
== ERROR_SUCCESS) {
wchar_t buffer[UuidStringLen + 1];
DWORD size = sizeof(buffer);
@@ -2976,11 +2976,11 @@ QByteArray QSysInfo::bootUniqueId()
}
#elif defined(Q_OS_DARWIN)
// "kern.bootsessionuuid" is only available by name
- char uuid[UuidStringLen];
+ char uuid[UuidStringLen + 1];
size_t uuidlen = sizeof(uuid);
if (sysctlbyname("kern.bootsessionuuid", uuid, &uuidlen, nullptr, 0) == 0
&& uuidlen == sizeof(uuid))
- return QByteArray(uuid, uuidlen);
+ return QByteArray(uuid, uuidlen - 1);
#endif
return QByteArray();
};
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index b608489576..ccab228804 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -1037,14 +1037,20 @@ for (auto _container_ = QtPrivate::qMakeForeachContainer(container); \
template <typename T> inline T *qGetPtrHelper(T *ptr) { return ptr; }
template <typename Ptr> inline auto qGetPtrHelper(const Ptr &ptr) -> decltype(ptr.operator->()) { return ptr.operator->(); }
+// The body must be a statement:
+#define Q_CAST_IGNORE_ALIGN(body) QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Wcast-align") body QT_WARNING_POP
#define Q_DECLARE_PRIVATE(Class) \
- inline Class##Private* d_func() { return reinterpret_cast<Class##Private *>(qGetPtrHelper(d_ptr)); } \
- inline const Class##Private* d_func() const { return reinterpret_cast<const Class##Private *>(qGetPtrHelper(d_ptr)); } \
+ inline Class##Private* d_func() \
+ { Q_CAST_IGNORE_ALIGN(return reinterpret_cast<Class##Private *>(qGetPtrHelper(d_ptr));) } \
+ inline const Class##Private* d_func() const \
+ { Q_CAST_IGNORE_ALIGN(return reinterpret_cast<const Class##Private *>(qGetPtrHelper(d_ptr));) } \
friend class Class##Private;
#define Q_DECLARE_PRIVATE_D(Dptr, Class) \
- inline Class##Private* d_func() { return reinterpret_cast<Class##Private *>(qGetPtrHelper(Dptr)); } \
- inline const Class##Private* d_func() const { return reinterpret_cast<const Class##Private *>(qGetPtrHelper(Dptr)); } \
+ inline Class##Private* d_func() \
+ { Q_CAST_IGNORE_ALIGN(return reinterpret_cast<Class##Private *>(qGetPtrHelper(Dptr));) } \
+ inline const Class##Private* d_func() const \
+ { Q_CAST_IGNORE_ALIGN(return reinterpret_cast<const Class##Private *>(qGetPtrHelper(Dptr));) } \
friend class Class##Private;
#define Q_DECLARE_PUBLIC(Class) \
diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp
index a796fd005a..3f4b46573b 100644
--- a/src/corelib/io/qfilesystemengine_win.cpp
+++ b/src/corelib/io/qfilesystemengine_win.cpp
@@ -1038,8 +1038,7 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM
if (what & QFileSystemMetaData::Permissions)
fillPermissions(fname, data, what);
- if ((what & QFileSystemMetaData::LinkType)
- && data.missingFlags(QFileSystemMetaData::LinkType)) {
+ if (what & QFileSystemMetaData::LinkType) {
data.knownFlagsMask |= QFileSystemMetaData::LinkType;
if (data.fileAttribute_ & FILE_ATTRIBUTE_REPARSE_POINT) {
WIN32_FIND_DATA findData;
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index 3c8b0f947c..b6b4da3885 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -2097,9 +2097,13 @@ static void replacePercentN(QString *result, int n)
int len = 0;
while ((percentPos = result->indexOf(QLatin1Char('%'), percentPos + len)) != -1) {
len = 1;
+ if (percentPos + len == result->length())
+ break;
QString fmt;
if (result->at(percentPos + len) == QLatin1Char('L')) {
++len;
+ if (percentPos + len == result->length())
+ break;
fmt = QLatin1String("%L1");
} else {
fmt = QLatin1String("%1");
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index 14af9ac8ef..42c39f18e3 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -1374,6 +1374,10 @@ void QObject::customEvent(QEvent * /* event */)
might have reimplemented eventFilter() for its own internal
purposes.
+ Some events, such as \l QEvent::ShortcutOverride must be explicitly
+ accepted (by calling \l {QEvent::}{accept()} on them) in order to prevent
+ propagation.
+
\warning If you delete the receiver object in this function, be
sure to return true. Otherwise, Qt will forward the event to the
deleted object and the program might crash.
@@ -4334,6 +4338,12 @@ QDebug operator<<(QDebug dbg, const QObject *o)
in a QVariant, you can convert them to strings. Likewise, passing them to
QDebug will print out their names.
+ Mind that the enum values are stored as signed \c int in the meta object system.
+ Registering enumerations with values outside the range of values valid for \c int
+ will lead to overflows and potentially undefined behavior when accessing them through
+ the meta object system. QML, for example, does access registered enumerations through
+ the meta object system.
+
\sa {Qt's Property System}
*/
@@ -4385,6 +4395,12 @@ QDebug operator<<(QDebug dbg, const QObject *o)
used in a QVariant, you can convert them to strings. Likewise, passing them
to QDebug will print out their names.
+ Mind that the enum values are stored as signed \c int in the meta object system.
+ Registering enumerations with values outside the range of values valid for \c int
+ will lead to overflows and potentially undefined behavior when accessing them through
+ the meta object system. QML, for example, does access registered enumerations through
+ the meta object system.
+
\sa {Qt's Property System}
*/
@@ -4442,7 +4458,7 @@ QDebug operator<<(QDebug dbg, const QObject *o)
macro, it must appear in the private section of a class definition.
Q_GADGETs can have Q_ENUM, Q_PROPERTY and Q_INVOKABLE, but they cannot have
- signals or slots
+ signals or slots.
Q_GADGET makes a class member, \c{staticMetaObject}, available.
\c{staticMetaObject} is of type QMetaObject and provides access to the
diff --git a/src/corelib/kernel/qtestsupport_core.h b/src/corelib/kernel/qtestsupport_core.h
index c8b664b6d3..c8209b5ae4 100644
--- a/src/corelib/kernel/qtestsupport_core.h
+++ b/src/corelib/kernel/qtestsupport_core.h
@@ -67,7 +67,13 @@ Q_REQUIRED_RESULT static bool qWaitFor(Functor predicate, int timeout = 5000)
QDeadlineTimer deadline(remaining, Qt::PreciseTimer);
do {
- QCoreApplication::processEvents(QEventLoop::AllEvents, remaining);
+ // We explicitly do not pass the remaining time to processEvents, as
+ // that would keep spinning processEvents for the whole duration if
+ // new events were posted as part of processing events, and we need
+ // to return back to this function to check the predicate between
+ // each pass of processEvents. Our own timer will take care of the
+ // timeout.
+ QCoreApplication::processEvents(QEventLoop::AllEvents);
QCoreApplication::sendPostedEvents(nullptr, QEvent::DeferredDelete);
remaining = deadline.remainingTime();
diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp
index 1f5d5f0dc6..63499ab93f 100644
--- a/src/corelib/tools/qlocale.cpp
+++ b/src/corelib/tools/qlocale.cpp
@@ -2367,6 +2367,8 @@ QLocale QLocale::system()
{
// this function is NOT thread-safe!
QT_PREPEND_NAMESPACE(systemData)(); // trigger updating of the system data if necessary
+ if (systemLocalePrivate.isDestroyed())
+ return QLocale(QLocale::C);
return QLocale(*systemLocalePrivate->data());
}
diff --git a/src/corelib/tools/qsimd.cpp b/src/corelib/tools/qsimd.cpp
index 07a8b022bc..1b51b591f7 100644
--- a/src/corelib/tools/qsimd.cpp
+++ b/src/corelib/tools/qsimd.cpp
@@ -293,7 +293,7 @@ static void cpuidFeatures07_00(uint &ebx, uint &ecx, uint &edx)
#endif
}
-#ifdef Q_OS_WIN
+#if defined(Q_OS_WIN) && !(defined(Q_CC_GNU) || defined(Q_CC_GHS))
// fallback overload in case this intrinsic does not exist: unsigned __int64 _xgetbv(unsigned int);
inline quint64 _xgetbv(__int64) { return 0; }
#endif