Cocoa: Prevent "Invalid Drawable" GL warnings.

Worst case this can cause the various OpenGL
initialization functions to fail due to the lack
of a valid GL context.

Task-number: QTBUG-35342
Task-number: QTBUG-31451

Change-Id: I08256ad51acb5370c8c6d44b556572eadd6a9c1d
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
This commit is contained in:
Morten Johan Sørvig 2014-02-18 07:52:32 +01:00 committed by The Qt Project
parent 72ba4cd385
commit 2f76a30ee1

View File

@ -1153,6 +1153,10 @@ void QCocoaWindow::recreateWindow(const QPlatformWindow *parentWindow)
// Child windows have no NSWindow, link the NSViews instead.
[m_parentCocoaWindow->m_contentView addSubview : m_contentView];
QRect rect = window()->geometry();
// Prevent setting a (0,0) window size; causes opengl context
// "Invalid Drawable" warnings.
if (rect.isNull())
rect.setSize(QSize(1, 1));
NSRect frame = NSMakeRect(rect.x(), rect.y(), rect.width(), rect.height());
[m_contentView setFrame:frame];
[m_contentView setHidden: YES];