summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa/qnswindow.mm
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/platforms/cocoa/qnswindow.mm')
-rw-r--r--src/plugins/platforms/cocoa/qnswindow.mm25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/plugins/platforms/cocoa/qnswindow.mm b/src/plugins/platforms/cocoa/qnswindow.mm
index 799704a407..e846fa043c 100644
--- a/src/plugins/platforms/cocoa/qnswindow.mm
+++ b/src/plugins/platforms/cocoa/qnswindow.mm
@@ -46,6 +46,8 @@
#include <qpa/qwindowsysteminterface.h>
#include <qoperatingsystemversion.h>
+Q_LOGGING_CATEGORY(lcCocoaEvents, "qt.qpa.cocoa.events");
+
static bool isMouseEvent(NSEvent *ev)
{
switch ([ev type]) {
@@ -116,6 +118,22 @@ static bool isMouseEvent(NSEvent *ev)
return qnsview_cast(self.contentView).platformWindow;
}
+- (NSString *)description
+{
+ NSMutableString *description = [NSMutableString stringWithString:qt_objcDynamicSuper()];
+
+#ifndef QT_NO_DEBUG_STREAM
+ QString contentViewDescription;
+ QDebug debug(&contentViewDescription);
+ debug.nospace() << "; contentView=" << qnsview_cast(self.contentView) << ">";
+
+ NSRange lastCharacter = [description rangeOfComposedCharacterSequenceAtIndex:description.length - 1];
+ [description replaceCharactersInRange:lastCharacter withString:contentViewDescription.toNSString()];
+#endif
+
+ return description;
+}
+
- (BOOL)canBecomeKeyWindow
{
QCocoaWindow *pw = self.platformWindow;
@@ -177,6 +195,8 @@ static bool isMouseEvent(NSEvent *ev)
- (void)sendEvent:(NSEvent*)theEvent
{
+ qCDebug(lcCocoaEvents) << "Sending" << theEvent << "to" << self;
+
// We might get events for a NSWindow after the corresponding platform
// window has been deleted, as the NSWindow can outlive the QCocoaWindow
// e.g. if being retained by other parts of AppKit, or in an auto-release
@@ -185,6 +205,10 @@ static bool isMouseEvent(NSEvent *ev)
if (!self.platformWindow)
return;
+ // Prevent deallocation of this NSWindow during event delivery, as we
+ // have logic further below that depends on the window being alive.
+ [[self retain] autorelease];
+
const char *eventType = object_getClassName(theEvent);
if (QWindowSystemInterface::handleNativeEvent(self.platformWindow->window(),
QByteArray::fromRawData(eventType, qstrlen(eventType)), theEvent, nullptr)) {
@@ -221,6 +245,7 @@ static bool isMouseEvent(NSEvent *ev)
#pragma clang diagnostic ignored "-Wobjc-missing-super-calls"
- (void)dealloc
{
+ qCDebug(lcQpaCocoaWindow) << "dealloc" << self;
qt_objcDynamicSuper();
}
#pragma clang diagnostic pop