summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r--src/corelib/kernel/qbasictimer.cpp2
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp2
-rw-r--r--src/corelib/kernel/qcoreevent.cpp4
-rw-r--r--src/corelib/kernel/qdeadlinetimer.cpp2
-rw-r--r--src/corelib/kernel/qjnihelpers.cpp42
-rw-r--r--src/corelib/kernel/qmetaobject.cpp2
-rw-r--r--src/corelib/kernel/qmetatype.cpp24
-rw-r--r--src/corelib/kernel/qobject.cpp6
-rw-r--r--src/corelib/kernel/qobject_p.h2
-rw-r--r--src/corelib/kernel/qtranslator.cpp11
10 files changed, 72 insertions, 25 deletions
diff --git a/src/corelib/kernel/qbasictimer.cpp b/src/corelib/kernel/qbasictimer.cpp
index 623ecb9b8b..eceaa0fb7f 100644
--- a/src/corelib/kernel/qbasictimer.cpp
+++ b/src/corelib/kernel/qbasictimer.cpp
@@ -79,7 +79,7 @@ QT_BEGIN_NAMESPACE
/*!
\fn QBasicTimer::QBasicTimer()
- Contructs a basic timer.
+ Constructs a basic timer.
\sa start()
*/
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index 2a2dcc72ca..d671f70bd3 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -1157,7 +1157,7 @@ static bool doNotify(QObject *receiver, QEvent *event)
bool QCoreApplicationPrivate::sendThroughApplicationEventFilters(QObject *receiver, QEvent *event)
{
// We can't access the application event filters outside of the main thread (race conditions)
- Q_ASSERT(receiver->d_func()->threadData.loadRelaxed()->thread.loadAcquire() == mainThread());
+ Q_ASSERT(receiver->d_func()->threadData.loadAcquire()->thread.loadRelaxed() == mainThread());
if (extraData) {
// application event filters are only called for objects in the GUI thread
diff --git a/src/corelib/kernel/qcoreevent.cpp b/src/corelib/kernel/qcoreevent.cpp
index b497532008..fb3a5c4ec9 100644
--- a/src/corelib/kernel/qcoreevent.cpp
+++ b/src/corelib/kernel/qcoreevent.cpp
@@ -250,7 +250,7 @@ QT_BEGIN_NAMESPACE
\value WindowStateChange The \l{QWindow::windowState()}{window's state} (minimized, maximized or full-screen) has changed (QWindowStateChangeEvent).
\value WindowTitleChange The window title has changed.
\value WindowUnblocked The window is unblocked after a modal dialog exited.
- \value WinIdChange The window system identifer for this native widget has changed.
+ \value WinIdChange The window system identifier for this native widget has changed.
\value ZOrderChange The widget's z-order has changed. This event is never sent to top level windows.
User events should have values between \c User and \c{MaxUser}:
@@ -292,7 +292,7 @@ QT_BEGIN_NAMESPACE
*/
/*!
- Contructs an event object of type \a type.
+ Constructs an event object of type \a type.
*/
QEvent::QEvent(Type type)
: d(nullptr), t(type), posted(false), spont(false), m_accept(true)
diff --git a/src/corelib/kernel/qdeadlinetimer.cpp b/src/corelib/kernel/qdeadlinetimer.cpp
index 520153b2e5..a627590c7c 100644
--- a/src/corelib/kernel/qdeadlinetimer.cpp
+++ b/src/corelib/kernel/qdeadlinetimer.cpp
@@ -891,7 +891,7 @@ QDeadlineTimer QDeadlineTimer::addNSecs(QDeadlineTimer dt, qint64 nsecs) noexcep
\relates QDeadlineTimer
Returns true if the deadline on \a d1 and the deadline in \a d2 are
- diferent, false otherwise. The timer type used to create the two deadlines
+ different, false otherwise. The timer type used to create the two deadlines
is ignored. This function is equivalent to:
\snippet code/src_corelib_kernel_qdeadlinetimer.cpp 9
diff --git a/src/corelib/kernel/qjnihelpers.cpp b/src/corelib/kernel/qjnihelpers.cpp
index 7d278c69f2..817effe742 100644
--- a/src/corelib/kernel/qjnihelpers.cpp
+++ b/src/corelib/kernel/qjnihelpers.cpp
@@ -48,6 +48,7 @@
#include "qcoreapplication.h"
#include <QtCore/qrunnable.h>
+#include <QReadWriteLock>
#include <deque>
#include <memory>
@@ -80,6 +81,7 @@ Q_GLOBAL_STATIC_WITH_ARGS(QtAndroidPrivate::OnBindListener*, g_onBindListener, (
Q_GLOBAL_STATIC(QMutex, g_onBindListenerMutex);
Q_GLOBAL_STATIC(QSemaphore, g_waitForServiceSetupSemaphore);
Q_GLOBAL_STATIC(QAtomicInt, g_serviceSetupLockers);
+Q_GLOBAL_STATIC(QReadWriteLock, g_updateMutex);
class PermissionsResultClass : public QObject
{
@@ -326,6 +328,41 @@ static void setNativeActivity(JNIEnv *env, jclass, jobject activity)
}
}
+static jboolean updateNativeActivity(JNIEnv *env, jclass = nullptr)
+{
+
+ jclass jQtNative = env->FindClass("org/qtproject/qt5/android/QtNative");
+ if (exceptionCheck(env))
+ return JNI_FALSE;
+
+ jmethodID activityMethodID =
+ env->GetStaticMethodID(jQtNative, "activity", "()Landroid/app/Activity;");
+ if (exceptionCheck(env))
+ return JNI_FALSE;
+
+ jobject activity = env->CallStaticObjectMethod(jQtNative, activityMethodID);
+ if (exceptionCheck(env))
+ return JNI_FALSE;
+
+ QWriteLocker locker(g_updateMutex());
+
+ if (g_jActivity) {
+ env->DeleteGlobalRef(g_jActivity);
+ g_jActivity = nullptr;
+ }
+
+ if (activity) {
+ g_jActivity = env->NewGlobalRef(activity);
+ env->DeleteLocalRef(activity);
+ }
+
+ env->DeleteLocalRef(jQtNative);
+ if (exceptionCheck(env))
+ return JNI_FALSE;
+
+ return JNI_TRUE;
+}
+
static void setNativeService(JNIEnv *env, jclass, jobject service)
{
if (g_jService != 0)
@@ -402,6 +439,7 @@ jint QtAndroidPrivate::initJNI(JavaVM *vm, JNIEnv *env)
{"setNativeActivity", "(Landroid/app/Activity;)V", reinterpret_cast<void *>(setNativeActivity)},
{"setNativeService", "(Landroid/app/Service;)V", reinterpret_cast<void *>(setNativeService)},
{"sendRequestPermissionsResult", "(I[Ljava/lang/String;[I)V", reinterpret_cast<void *>(sendRequestPermissionsResult)},
+ {"updateNativeActivity", "()Z", reinterpret_cast<void *>(updateNativeActivity) },
};
const bool regOk = (env->RegisterNatives(jQtNative, methods, sizeof(methods) / sizeof(methods[0])) == JNI_OK);
@@ -423,6 +461,7 @@ jint QtAndroidPrivate::initJNI(JavaVM *vm, JNIEnv *env)
jobject QtAndroidPrivate::activity()
{
+ QReadLocker locker(g_updateMutex());
return g_jActivity;
}
@@ -433,12 +472,13 @@ jobject QtAndroidPrivate::service()
jobject QtAndroidPrivate::context()
{
+ QReadLocker locker(g_updateMutex());
if (g_jActivity)
return g_jActivity;
if (g_jService)
return g_jService;
- return 0;
+ return nullptr;
}
JavaVM *QtAndroidPrivate::javaVM()
diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp
index 7761ab7886..b33987c2f0 100644
--- a/src/corelib/kernel/qmetaobject.cpp
+++ b/src/corelib/kernel/qmetaobject.cpp
@@ -3213,7 +3213,7 @@ QVariant QMetaProperty::read(const QObject *object) const
If \a value is not of the same type type as the property, a conversion
is attempted. An empty QVariant() is equivalent to a call to reset()
- if this property is resetable, or setting a default-constructed object
+ if this property is resettable, or setting a default-constructed object
otherwise.
\sa read(), reset(), isWritable()
diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp
index 21254108e3..33240dd335 100644
--- a/src/corelib/kernel/qmetatype.cpp
+++ b/src/corelib/kernel/qmetatype.cpp
@@ -414,19 +414,21 @@ struct DefinedTypesFilter {
\fn const QMetaObject *QMetaType::metaObject() const
\since 5.5
- return a QMetaObject relative to this type.
+ Returns a QMetaObject relative to this type.
If the type is a pointer type to a subclass of QObject, flags() contains
- QMetaType::PointerToQObject and this function returns the corresponding QMetaObject. This can
- be used to in combinaison with QMetaObject::construct to create QObject of this type.
-
- If the type is a Q_GADGET, flags() contains QMetaType::IsGadget, and this function returns its
- QMetaObject. This can be used to retrieve QMetaMethod and QMetaProperty and use them on a
- pointer of this type. (given by QVariant::data for example)
-
- If the type is an enumeration, flags() contains QMetaType::IsEnumeration, and this function
- returns the QMetaObject of the enclosing object if the enum was registered as a Q_ENUM or
- \nullptr otherwise
+ QMetaType::PointerToQObject and this function returns the corresponding QMetaObject.
+ This can be used in combination with QMetaObject::newInstance() to create QObjects of this type.
+
+ If the type is a Q_GADGET, flags() contains QMetaType::IsGadget.
+ If the type is a pointer to a Q_GADGET, flags() contains QMetaType::PointerToGadget.
+ In both cases, this function returns its QMetaObject.
+ This can be used to retrieve QMetaMethod and QMetaProperty and use them on a
+ pointer of this type for example, as given by QVariant::data().
+
+ If the type is an enumeration, flags() contains QMetaType::IsEnumeration.
+ In this case, this function returns the QMetaObject of the enclosing
+ object if the enum was registered as a Q_ENUM or \nullptr otherwise.
\sa QMetaType::metaObjectForType(), QMetaType::flags()
*/
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index d57bcc31cc..4fccf8dd56 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -1010,7 +1010,7 @@ QObject::~QObject()
emit destroyed(this);
}
- if (d->declarativeData) {
+ if (!d->isDeletingChildren && d->declarativeData) {
if (static_cast<QAbstractDeclarativeDataImpl*>(d->declarativeData)->ownedByQml1) {
if (QAbstractDeclarativeData::destroyed_qml1)
QAbstractDeclarativeData::destroyed_qml1(d->declarativeData, this);
@@ -1580,7 +1580,7 @@ void QObject::moveToThread(QThread *targetThread)
QThreadData *currentData = QThreadData::current();
QThreadData *targetData = targetThread ? QThreadData::get2(targetThread) : nullptr;
- QThreadData *thisThreadData = d->threadData.loadRelaxed();
+ QThreadData *thisThreadData = d->threadData.loadAcquire();
if (!thisThreadData->thread.loadAcquire() && currentData == targetData) {
// one exception to the rule: we allow moving objects with no thread affinity to the current thread
currentData = d->threadData;
@@ -2622,7 +2622,7 @@ int QObject::receivers(const char *signal) const
if (!d->isSignalConnected(signal_index))
return receivers;
- if (d->declarativeData && QAbstractDeclarativeData::receivers) {
+ if (!d->isDeletingChildren && d->declarativeData && QAbstractDeclarativeData::receivers) {
receivers += QAbstractDeclarativeData::receivers(d->declarativeData, this,
signal_index);
}
diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h
index 0b827a52ca..13ffb88999 100644
--- a/src/corelib/kernel/qobject_p.h
+++ b/src/corelib/kernel/qobject_p.h
@@ -444,7 +444,7 @@ inline void QObjectPrivate::checkForIncompatibleLibraryVersion(int version) cons
inline bool QObjectPrivate::isDeclarativeSignalConnected(uint signal_index) const
{
- return declarativeData && QAbstractDeclarativeData::isSignalConnected
+ return !isDeletingChildren && declarativeData && QAbstractDeclarativeData::isSignalConnected
&& QAbstractDeclarativeData::isSignalConnected(declarativeData, q_func(), signal_index);
}
diff --git a/src/corelib/kernel/qtranslator.cpp b/src/corelib/kernel/qtranslator.cpp
index 2812ffb7ea..bdcd016630 100644
--- a/src/corelib/kernel/qtranslator.cpp
+++ b/src/corelib/kernel/qtranslator.cpp
@@ -655,15 +655,20 @@ static QString find_translation(const QLocale & locale,
// see http://www.unicode.org/reports/tr35/#LanguageMatching for inspiration
+ // For each language_country returned by locale.uiLanguages(), add
+ // also a lowercase version to the list. Since these languages are
+ // used to create file names, this is important on case-sensitive
+ // file systems, where otherwise a file called something like
+ // "prefix_en_us.qm" won't be found under the "en_US" locale. Note
+ // that the Qt resource system is always case-sensitive, even on
+ // Windows (in other words: this codepath is *not* UNIX-only).
QStringList languages = locale.uiLanguages();
-#if defined(Q_OS_UNIX)
for (int i = languages.size()-1; i >= 0; --i) {
QString lang = languages.at(i);
QString lowerLang = lang.toLower();
if (lang != lowerLang)
languages.insert(i+1, lowerLang);
}
-#endif
for (QString localeName : qAsConst(languages)) {
localeName.replace(QLatin1Char('-'), QLatin1Char('_'));
@@ -1109,7 +1114,7 @@ void QTranslatorPrivate::clear()
If \a n is not -1, it is used to choose an appropriate form for
the translation (e.g. "%n file found" vs. "%n files found").
- If you need to programatically insert translations into a
+ If you need to programmatically insert translations into a
QTranslator, this function can be reimplemented.
\sa load()