summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTimur Pocheptsov <timur.pocheptsov@theqtcompany.com>2016-05-18 16:31:52 +0200
committerTimur Pocheptsov <timur.pocheptsov@theqtcompany.com>2016-05-25 12:55:58 +0000
commitf75b78a92a689b90124c79e50525bbc78540c576 (patch)
treeec012a2517a73c44a5d66c274ee6735d3241c047 /src
parente0ab94b5251e732d4bea553f2d6e943f5d714720 (diff)
Cocoa integration - fix QCocoaWindow::setContentView
- QCocoaWindow::setContentView calls -removeFromSuperView and this is not valid for a view that is a content view for a NSWindow: using it will release the view but not clear the window.contentView pointer. Set contentView to nil instead. Fixing this makes visible the second problem: - QNSWindowHelper in its -handleWindowEvent: can access content view and assumes it's QNSView - it is not always guaranteed and can result in invalid message sent to a view, we can use m_qtView instead (it will be nil if it has a type different from QNSView, the call will be noop then). Task-number: QTBUG-53325 Change-Id: I0472eba8165a04b6a3f81b2171b3bb9827ff5681 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
index c5519995b6..c0d5904367 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
@@ -148,7 +148,7 @@ static bool isMouseEvent(NSEvent *ev)
if (NSMouseInRect(loc, windowFrame, NO) &&
!NSMouseInRect(loc, contentFrame, NO))
{
- QNSView *contentView = (QNSView *)pw->contentView();
+ QNSView *contentView = pw->m_qtView;
[contentView handleFrameStrutMouseEvent: theEvent];
}
}
@@ -1173,7 +1173,11 @@ NSView *QCocoaWindow::contentView() const
void QCocoaWindow::setContentView(NSView *contentView)
{
// Remove and release the previous content view
- [m_contentView removeFromSuperview];
+ if (m_nsWindow)
+ [m_nsWindow setContentView:nil];
+ else
+ [m_contentView removeFromSuperview];
+
[m_contentView release];
// Insert and retain the new content view