Fix crash-on-exit when embedding QNView
The QWindow and QCocoaWindow may be deleted before the QNSView (which Cocoa keeps a reference to). Clear pointers to the Qt windows on QCocoaWindow destruction and add null-pointer check to QNView::isOpaque. Change-Id: I71764886c27bf1d14fb4e684c15e7c72e1c0a17c Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@theqtcompany.com>
This commit is contained in:
parent
20598f53df
commit
1b79d1cfe2
@ -446,6 +446,14 @@ QCocoaWindow::~QCocoaWindow()
|
||||
name:nil object:m_nsWindow];
|
||||
}
|
||||
|
||||
// The QNSView object may outlive the corresponding QCocoaWindow object,
|
||||
// for example during app shutdown when the QNSView is embedded in a
|
||||
// foregin NSView hiearchy. Clear the pointers to the QWindow/QCocoaWindow
|
||||
// here to make sure QNSView does not dereference stale pointers.
|
||||
if (m_qtView) {
|
||||
[m_qtView clearQWindowPointers];
|
||||
}
|
||||
|
||||
foreach (QCocoaWindow *child, m_childWindows) {
|
||||
[m_nsWindow removeChildWindow:child->m_nsWindow];
|
||||
child->m_parentCocoaWindow = 0;
|
||||
|
@ -80,6 +80,7 @@ Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper));
|
||||
|
||||
- (id)init;
|
||||
- (id)initWithQWindow:(QWindow *)window platformWindow:(QCocoaWindow *) platformWindow;
|
||||
- (void) clearQWindowPointers;
|
||||
#ifndef QT_NO_OPENGL
|
||||
- (void)setQCocoaGLContext:(QCocoaGLContext *)context;
|
||||
#endif
|
||||
|
@ -214,6 +214,12 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) clearQWindowPointers
|
||||
{
|
||||
m_window = 0;
|
||||
m_platformWindow = 0;
|
||||
}
|
||||
|
||||
#ifndef QT_NO_OPENGL
|
||||
- (void) setQCocoaGLContext:(QCocoaGLContext *)context
|
||||
{
|
||||
@ -481,6 +487,8 @@ QT_WARNING_POP
|
||||
|
||||
- (BOOL) isOpaque
|
||||
{
|
||||
if (!m_platformWindow)
|
||||
return true;
|
||||
return m_platformWindow->isOpaque();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user