From 653bdcca8e683f5a3d485df885c0bed217a02a6b Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Fri, 27 Feb 2015 18:17:52 +0100 Subject: Cocoa integration - do not report invalid coordinates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit setStyleMask with NSBorderlessWindow will call (indirectly) windowDidResize (window.delegate's method) and view's updateGeometry. At this point view.window can be nil (Cocoa is re-parenting the content view (?). If this is the case, do not set this updated geometry on a QWindow/platform window (since window is nil, self.window.frame is returned as {{0, 0} {0, 0}} by Cocoa). Found by tst_QWidget::setGeometry. Change-Id: Ic3cc0d944b5a8a5095c7fd0fdf2df7c9ea602b2a Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoawindow.mm | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/plugins/platforms/cocoa/qcocoawindow.mm') diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 64e599ae08..984d39ea81 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -374,6 +374,7 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw) , m_inConstructor(true) , m_inSetVisible(false) , m_inSetGeometry(false) + , m_inSetStyleMask(false) #ifndef QT_NO_OPENGL , m_glContext(0) #endif @@ -869,7 +870,11 @@ void QCocoaWindow::setWindowFlags(Qt::WindowFlags flags) if (m_nsWindow && !m_isNSWindowChild) { NSUInteger styleMask = windowStyleMask(flags); NSInteger level = this->windowLevel(flags); + // While setting style mask we can have -updateGeometry calls on a content + // view with null geometry, reporting an invalid coordinates as a result. + m_inSetStyleMask = true; [m_nsWindow setStyleMask:styleMask]; + m_inSetStyleMask = false; [m_nsWindow setLevel:level]; setWindowShadow(flags); if (!(styleMask & NSBorderlessWindowMask)) { -- cgit v1.2.3