Fix QGLWidget segfault on Android

...and other platforms that do not support WA_NativeWindow.

Task-number: QTBUG-33523
Change-Id: I4ab043e8b3c3369aec41b44275fb3099d90e55b4
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
This commit is contained in:
Paul Olav Tvete 2013-09-17 10:36:57 +02:00 committed by The Qt Project
parent 85708e7377
commit 61e0534aff
2 changed files with 7 additions and 4 deletions

View File

@ -269,6 +269,7 @@ QWidgetPrivate::QWidgetPrivate(int version)
, isScrolled(0)
, isMoved(0)
, usesDoubleBufferedGLContext(0)
, mustHaveWindowHandle(0)
#ifndef QT_NO_IM
, inheritsInputMethodHints(0)
#endif
@ -1148,9 +1149,10 @@ void QWidgetPrivate::init(QWidget *parentWidget, Qt::WindowFlags f)
data.in_destructor = false;
// Widgets with Qt::MSWindowsOwnDC (typically QGLWidget) must have a window handle.
if (f & Qt::MSWindowsOwnDC)
if (f & Qt::MSWindowsOwnDC) {
mustHaveWindowHandle = 1;
q->setAttribute(Qt::WA_NativeWindow);
}
//#ifdef Q_WS_MAC
// q->setAttribute(Qt::WA_NativeWindow);
//#endif
@ -10072,8 +10074,8 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on)
}
#endif
// Don't set WA_NativeWindow on platforms that don't support it
if (attribute == Qt::WA_NativeWindow) {
// Don't set WA_NativeWindow on platforms that don't support it -- except for QGLWidget, which depends on it
if (attribute == Qt::WA_NativeWindow && !d->mustHaveWindowHandle) {
QPlatformIntegration *platformIntegration = QGuiApplicationPrivate::platformIntegration();
if (!platformIntegration->hasCapability(QPlatformIntegration::NativeWidgets))
return;

View File

@ -693,6 +693,7 @@ public:
uint isScrolled : 1;
uint isMoved : 1;
uint usesDoubleBufferedGLContext : 1;
uint mustHaveWindowHandle : 1;
#ifndef QT_NO_IM
uint inheritsInputMethodHints : 1;
#endif