Fix a crash on startup with QOpenGLWidget

After c4aabeb2b8 we now try to access
q_ptr in QWidgetPrivate::setRenderToTexture. QOpenGLWidget needs to
delay this call after the QObject constructor is done to make sure
that setTextureChildSeen doesn't dereference q_ptr before it has
been initialized.

Change-Id: Icaee82c8b806f42bc7614b0ac6fe4e6026331750
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
bb10
Jocelyn Turcotte 2014-04-04 18:28:20 +02:00 committed by The Qt Project
parent b5eb850e0d
commit f4f1f597d4
1 changed files with 2 additions and 1 deletions

View File

@ -60,7 +60,6 @@ public:
QOpenGLWidgetPrivate()
: fbo(0), uninitialized(true)
{
setRenderToTexture();
}
GLuint textureId() const { return fbo ? fbo->texture() : 0; }
@ -91,6 +90,8 @@ void QOpenGLWidgetPrivate::initialize()
QOpenGLWidget::QOpenGLWidget(QWidget *parent, Qt::WindowFlags f)
: QWidget(*(new QOpenGLWidgetPrivate), parent, f)
{
Q_D(QOpenGLWidget);
d->setRenderToTexture();
}
QOpenGLWidget::~QOpenGLWidget()