macOS: don’t crash when wrapping foreign views

window.contentView can be of any NSView subclass.
Get to the QCocoaWindow via QCocoaNSWindow instead.

Change-Id: I8c761fd22e6078b075d8dd035ad767b9e4cb6da2
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
bb10
Morten Johan Sørvig 2019-03-29 17:33:11 +01:00 committed by Tor Arne Vestbø
parent fc9baeeb9f
commit 24eb0b33a4
1 changed files with 3 additions and 1 deletions

View File

@ -51,7 +51,9 @@ static QRegExp whitespaceRegex = QRegExp(QStringLiteral("\\s*"));
static QCocoaWindow *toPlatformWindow(NSWindow *window)
{
return qnsview_cast(window.contentView).platformWindow;
if ([window conformsToProtocol:@protocol(QNSWindowProtocol)])
return static_cast<QCocoaNSWindow *>(window).platformWindow;
return nullptr;
}
@implementation QNSWindowDelegate