diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.mm b/src/plugins/platforms/cocoa/qcocoaglcontext.mm index a7cc19b3bf..9e688f4d1b 100644 --- a/src/plugins/platforms/cocoa/qcocoaglcontext.mm +++ b/src/plugins/platforms/cocoa/qcocoaglcontext.mm @@ -255,7 +255,8 @@ void QCocoaGLContext::setActiveWindow(QWindow *window) QCocoaWindow *cocoaWindow = static_cast(window->handle()); cocoaWindow->setCurrentContext(this); - [(QNSView *) cocoaWindow->view() setQCocoaGLContext:this]; + Q_ASSERT(!cocoaWindow->isForeignWindow()); + [qnsview_cast(cocoaWindow->view()) setQCocoaGLContext:this]; } void QCocoaGLContext::updateSurfaceFormat() diff --git a/src/plugins/platforms/cocoa/qcocoamenu.mm b/src/plugins/platforms/cocoa/qcocoamenu.mm index e177a24e73..8e47974d12 100644 --- a/src/plugins/platforms/cocoa/qcocoamenu.mm +++ b/src/plugins/platforms/cocoa/qcocoamenu.mm @@ -581,8 +581,8 @@ void QCocoaMenu::showPopup(const QWindow *parentWindow, const QRect &targetRect, // The calls above block, and also swallow any mouse release event, // so we need to clear any mouse button that triggered the menu popup. - if ([view isKindOfClass:[QNSView class]]) - [(QNSView *)view resetMouseButtons]; + if (!cocoaWindow->isForeignWindow()) + [qnsview_cast(view) resetMouseButtons]; } void QCocoaMenu::dismiss()