Cocoa: Unregister view from window's notifications only

Otherwise the view will miss its own frame change notifications.
And we must unregister from all the notifications during dealloc.

This would also reveal a bug where we would expose an NSView before
its super view is visible, leading to those "invalid drawable" warnings
when using QQuickViews. Therefore, we add this extra check in
QCocoaWindow::exposeWindow().

Task-number: QTBUG-32826
Change-Id: I69018cb6f199b242768d114b2aa34c7f2d243196
Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
This commit is contained in:
Gabriel de Dietrich 2013-08-20 16:55:17 +02:00 committed by The Qt Project
parent a2bdda8e3b
commit 8fd71914b4
2 changed files with 6 additions and 8 deletions

View File

@ -911,7 +911,8 @@ void QCocoaWindow::clearNSWindow(NSWindow *window)
[window setContentView:nil];
[window setDelegate:nil];
[window clearPlatformWindow];
[[NSNotificationCenter defaultCenter] removeObserver:m_contentView];
[[NSNotificationCenter defaultCenter] removeObserver:m_contentView
name:nil object:window];
}
// Returns the current global screen geometry for the nswindow associated with this window.
@ -1023,7 +1024,7 @@ qreal QCocoaWindow::devicePixelRatio() const
void QCocoaWindow::exposeWindow()
{
if (!m_isExposed) {
if (!m_isExposed && ![[m_contentView superview] isHidden]) {
m_isExposed = true;
QWindowSystemInterface::handleExposeEvent(window(), QRegion(geometry()));
}

View File

@ -107,12 +107,9 @@ static QTouchDevice *touchDevice = 0;
m_maskImage = 0;
m_maskData = 0;
m_window = 0;
if (m_subscribesForGlobalFrameNotifications) {
m_subscribesForGlobalFrameNotifications = false;
[[NSNotificationCenter defaultCenter] removeObserver:self
name:NSViewGlobalFrameDidChangeNotification
object:self];
}
m_subscribesForGlobalFrameNotifications = false;
[[NSNotificationCenter defaultCenter] removeObserver:self];
delete currentCustomDragTypes;
[super dealloc];