Cocoa: don't animate window transitions for 0 width/height windows
authorTeemu Katajisto <teemu.katajisto@digia.com>
Fri, 5 Oct 2012 11:20:03 +0000 (14:20 +0300)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Mon, 8 Oct 2012 06:50:09 +0000 (08:50 +0200)
Task-number: QTBUG-26617

Change-Id: I6dfc3f208368ddf6be65259218aee88db9692cfe
Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
src/plugins/platforms/cocoa/qcocoawindow.mm

index 4902e31..6e105ee 100644 (file)
@@ -726,6 +726,15 @@ void QCocoaWindow::syncWindowState(Qt::WindowState newState)
     if (!m_nsWindow)
         return;
 
+    // if content view width or height is 0 then the window animations will crash so
+    // do nothing except set the new state
+    NSRect contentRect = [contentView() frame];
+    if (contentRect.size.width <= 0 || contentRect.size.height <= 0) {
+        qWarning() << Q_FUNC_INFO << "invalid window content view size, check your window geometry";
+        m_synchedWindowState = newState;
+        return;
+    }
+
     if ((m_synchedWindowState & Qt::WindowMaximized) != (newState & Qt::WindowMaximized)) {
         [m_nsWindow performZoom : m_nsWindow]; // toggles
     }