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>bb10
parent
e0ab94b525
commit
f75b78a92a
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue