Make sure we don't delete child QWindows if they have WA_NativeWindow set
Deleting a QWindow automatically deletes its child windows because they are in the QObject hierarchy. However, if the user sets both WA_NativeWindow and WA_DontCreateNativeAncestors, we can't just delete that widget's QWindow. First because the widget doesn't get notified (and maybe it should be), and then because we may invalidate any reference to the QWindow the user may have kept. Our solution is to reparent the child QWindows into the new parent's closest QWindow. We must, however, take the precaution of not keeping any reference to the backing store in the platform window. Reparenting operations can trigger repaints on the platform window, but the backing store is not set and flushed until later. Task-number: QTBUG-38377 Change-Id: I353f5528f227a227b6d10419367cbe1d5d07a94e Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>bb10
parent
87fbfe074b
commit
65a991e57e
|
|
@ -580,6 +580,8 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil;
|
|||
CGImageRelease(subMask);
|
||||
|
||||
[self invalidateWindowShadowIfNeeded];
|
||||
|
||||
m_backingStore = 0;
|
||||
}
|
||||
|
||||
- (BOOL) isFlipped
|
||||
|
|
|
|||
|
|
@ -284,6 +284,22 @@ void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f)
|
|||
if (wasCreated && !(f & Qt::Window) && (oldFlags & Qt::Window) && !q->testAttribute(Qt::WA_NativeWindow)) {
|
||||
if (extra && extra->hasWindowContainer)
|
||||
QWindowContainer::toplevelAboutToBeDestroyed(q);
|
||||
|
||||
QWindow *newParentWindow = newparent->windowHandle();
|
||||
if (!newParentWindow)
|
||||
if (QWidget *npw = newparent->nativeParentWidget())
|
||||
newParentWindow = npw->windowHandle();
|
||||
|
||||
Q_FOREACH (QObject *child, q->windowHandle()->children()) {
|
||||
QWindow *childWindow = qobject_cast<QWindow *>(child);
|
||||
if (!childWindow)
|
||||
continue;
|
||||
|
||||
QWidgetWindow *childWW = qobject_cast<QWidgetWindow *>(childWindow);
|
||||
QWidget *childWidget = childWW ? childWW->widget() : 0;
|
||||
if (!childWW || (childWidget && childWidget->testAttribute(Qt::WA_NativeWindow)))
|
||||
childWindow->setParent(newParentWindow);
|
||||
}
|
||||
q->destroy();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue