summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/corelib/global/qnamespace.qdoc2
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp8
-rw-r--r--src/plugins/platforms/cocoa/qcocoaapplication.mm10
3 files changed, 19 insertions, 1 deletions
diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc
index a47f2e2945..50697e82a7 100644
--- a/src/corelib/global/qnamespace.qdoc
+++ b/src/corelib/global/qnamespace.qdoc
@@ -125,7 +125,7 @@
to author a plugin. This includes avoiding loading our nib for the main
menu and not taking possession of the native menu bar. When setting this
attribute to true will also set the AA_DontUseNativeMenuBar attribute
- to true.
+ to true. It also disables native event filters.
\value AA_DontUseNativeMenuBar All menubars created while this attribute is
set to true won't be used as a native menubar (e.g, the menubar at
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index 6868eb6a1e..82c157ee7f 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -2528,6 +2528,9 @@ void QCoreApplication::removeLibraryPath(const QString &path)
\note The filter function set here receives native messages,
i.e. MSG or XCB event structs.
+ \note Native event filters will be disabled when the application the
+ Qt::AA_MacPluginApplication attribute is set.
+
For maximum portability, you should always try to use QEvents
and QObject::installEventFilter() whenever possible.
@@ -2537,6 +2540,11 @@ void QCoreApplication::removeLibraryPath(const QString &path)
*/
void QCoreApplication::installNativeEventFilter(QAbstractNativeEventFilter *filterObj)
{
+ if (QCoreApplication::testAttribute(Qt::AA_MacPluginApplication)) {
+ qWarning("Native event filters are not applied when the Qt::AA_MacPluginApplication attribute is set");
+ return;
+ }
+
QAbstractEventDispatcher *eventDispatcher = QAbstractEventDispatcher::instance(QCoreApplicationPrivate::theMainThread);
if (!filterObj || !eventDispatcher)
return;
diff --git a/src/plugins/platforms/cocoa/qcocoaapplication.mm b/src/plugins/platforms/cocoa/qcocoaapplication.mm
index 551a59823c..bac76357da 100644
--- a/src/plugins/platforms/cocoa/qcocoaapplication.mm
+++ b/src/plugins/platforms/cocoa/qcocoaapplication.mm
@@ -189,6 +189,12 @@ QT_BEGIN_NAMESPACE
void qt_redirectNSApplicationSendEvent()
{
+ if (QCoreApplication::testAttribute(Qt::AA_MacPluginApplication))
+ // In a plugin we cannot chain sendEvent hooks: a second plugin could
+ // store the implementation of the first, which during the program flow
+ // can be unloaded.
+ return;
+
if ([NSApp isMemberOfClass:[QNSApplication class]]) {
// No need to change implementation since Qt
// already controls a subclass of NSApplication
@@ -209,6 +215,10 @@ void qt_redirectNSApplicationSendEvent()
void qt_resetNSApplicationSendEvent()
{
+ if (QCoreApplication::testAttribute(Qt::AA_MacPluginApplication))
+ return;
+
+
qt_cocoa_change_back_implementation([NSApplication class],
@selector(sendEvent:),
@selector(QT_MANGLE_NAMESPACE(qt_sendEvent_original):));