summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-01-21 13:03:09 +0100
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-01-21 13:03:09 +0100
commitf94ca82e0ff6345648b499911411f2dcc1849267 (patch)
treebc5acac8bfecaf5bccc612f5b009bf249bc69ef1 /src/corelib
parentfe29a6a6ebbf28505df7cdf1de24fa540fd3745e (diff)
parentb1092a7d4240d419cc2b5f3f5c326a1cb680bbdd (diff)
Merge remote-tracking branch 'origin/5.12' into dev
Conflicts: .qmake.conf Change-Id: Ibfcb30053f3aacb8ec2ec480e146538c9bf440ea
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/kernel/qcoreapplication.cpp4
-rw-r--r--src/corelib/kernel/qobject.cpp4
-rw-r--r--src/corelib/kernel/qtestsupport_core.h8
-rw-r--r--src/corelib/tools/qlocale.cpp2
6 files changed, 33 insertions, 11 deletions
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index c0d46b73d9..055455c431 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -2933,18 +2933,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
@@ -2967,7 +2967,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);
@@ -3008,11 +3008,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 e3073d80ec..1e4ccae65b 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -1054,14 +1054,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/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index e100ec8186..e5098b8415 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -2104,9 +2104,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 5989fbd1ef..600a801fe0 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.
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 51b886b0e0..86b73bf634 100644
--- a/src/corelib/tools/qlocale.cpp
+++ b/src/corelib/tools/qlocale.cpp
@@ -2371,6 +2371,8 @@ QString QLocale::toString(double i, char f, int prec) const
QLocale QLocale::system()
{
QT_PREPEND_NAMESPACE(systemData)(); // trigger updating of the system data if necessary
+ if (systemLocalePrivate.isDestroyed())
+ return QLocale(QLocale::C);
return QLocale(*systemLocalePrivate->data());
}