From 61e0534aff440809f3388245f36e482c22912832 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Tue, 17 Sep 2013 10:36:57 +0200 Subject: 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 --- src/widgets/kernel/qwidget.cpp | 10 ++++++---- src/widgets/kernel/qwidget_p.h | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index eea44300e8..76c4cbcb97 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -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; diff --git a/src/widgets/kernel/qwidget_p.h b/src/widgets/kernel/qwidget_p.h index 0580f72e11..88aff2b65d 100644 --- a/src/widgets/kernel/qwidget_p.h +++ b/src/widgets/kernel/qwidget_p.h @@ -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 -- cgit v1.2.3