Fix assert in painting demos when switching to OpenGL.

Fix creation order. The ArthurFrame receives a paint
event with OpenGL set to true when the glw-member is still 0.

Task-number: QTBUG-26084
Change-Id: Ib4b568d22ae925542e3a775403e4c983ea0b4de5
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@digia.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
This commit is contained in:
Friedemann Kleint 2012-06-08 13:45:43 +02:00 committed by Qt by Nokia
parent e03d1ae953
commit e454000abc

View File

@ -87,19 +87,22 @@ ArthurFrame::ArthurFrame(QWidget *parent)
#ifdef QT_OPENGL_SUPPORT #ifdef QT_OPENGL_SUPPORT
void ArthurFrame::enableOpenGL(bool use_opengl) void ArthurFrame::enableOpenGL(bool use_opengl)
{ {
m_use_opengl = use_opengl; if (m_use_opengl == use_opengl)
return;
if (!glw) { if (!glw && use_opengl) {
glw = new GLWidget(this); glw = new GLWidget(this);
glw->setAutoFillBackground(false); glw->setAutoFillBackground(false);
glw->disableAutoBufferSwap(); glw->disableAutoBufferSwap();
QApplication::postEvent(this, new QResizeEvent(size(), size())); QApplication::postEvent(this, new QResizeEvent(size(), size()));
} }
m_use_opengl = use_opengl;
if (use_opengl) { if (use_opengl) {
glw->show(); glw->show();
} else { } else {
glw->hide(); if (glw)
glw->hide();
} }
update(); update();