File tree Expand file tree Collapse file tree 3 files changed +18
-9
lines changed Expand file tree Collapse file tree 3 files changed +18
-9
lines changed Original file line number Diff line number Diff line change @@ -4297,16 +4297,19 @@ bool QGLWidget::event(QEvent *e)
4297
4297
// if we've reparented a window that has the current context
4298
4298
// bound, we need to rebind that context to the new window id
4299
4299
if (d->glcx == QGLContext::currentContext ())
4300
- makeCurrent ();
4300
+ makeCurrent (); // Shouldn't happen but keep it here just for sure
4301
4301
4302
4302
if (testAttribute (Qt::WA_TranslucentBackground))
4303
4303
setContext (new QGLContext (d->glcx ->requestedFormat (), this ));
4304
4304
}
4305
4305
4306
4306
// A re-parent is likely to destroy the Symbian window and re-create it. It is important
4307
4307
// that we free the EGL surface _before_ the winID changes - otherwise we can leak.
4308
- if (e->type () == QEvent::ParentAboutToChange)
4308
+ if (e->type () == QEvent::ParentAboutToChange) {
4309
+ if (d->glcx == QGLContext::currentContext ())
4310
+ d->glcx ->doneCurrent ();
4309
4311
d->glcx ->d_func ()->destroyEglSurfaceForDevice ();
4312
+ }
4310
4313
4311
4314
if ((e->type () == QEvent::ParentChange) || (e->type () == QEvent::WindowStateChange)) {
4312
4315
// The window may have been re-created during re-parent or state change - if so, the EGL
Original file line number Diff line number Diff line change @@ -175,6 +175,7 @@ class QGLWidgetPrivate : public QWidgetPrivate
175
175
#endif
176
176
#if defined(Q_OS_SYMBIAN)
177
177
, eglSurfaceWindowId(0 )
178
+ , surfaceSizeInitialized(false )
178
179
#endif
179
180
{
180
181
isGLWidget = 1 ;
@@ -220,6 +221,7 @@ class QGLWidgetPrivate : public QWidgetPrivate
220
221
#ifdef Q_OS_SYMBIAN
221
222
void recreateEglSurface ();
222
223
WId eglSurfaceWindowId;
224
+ bool surfaceSizeInitialized : 1 ;
223
225
#endif
224
226
};
225
227
Original file line number Diff line number Diff line change @@ -259,7 +259,7 @@ bool QGLContext::chooseContext(const QGLContext* shareContext) // almost same as
259
259
return true ;
260
260
}
261
261
262
- void QGLWidget::resizeEvent (QResizeEvent *)
262
+ void QGLWidget::resizeEvent (QResizeEvent *e )
263
263
{
264
264
Q_D (QGLWidget);
265
265
if (!isValid ())
@@ -270,17 +270,18 @@ void QGLWidget::resizeEvent(QResizeEvent *)
270
270
if (this == qt_gl_share_widget ())
271
271
return ;
272
272
273
- if (QGLContext::currentContext ())
274
- doneCurrent ();
275
-
276
- // Symbian needs to recreate the surface on resize.
277
- d-> recreateEglSurface ();
273
+ if (!d-> surfaceSizeInitialized || e-> oldSize () != e-> size ()) {
274
+ // On Symbian we need to recreate the surface on resize.
275
+ d-> recreateEglSurface ();
276
+ d-> surfaceSizeInitialized = true ;
277
+ }
278
278
279
279
makeCurrent ();
280
+
280
281
if (!d->glcx ->initialized ())
281
282
glInit ();
283
+
282
284
resizeGL (width (), height ());
283
- // handle overlay
284
285
}
285
286
286
287
const QGLContext* QGLWidget::overlayContext () const
@@ -363,6 +364,9 @@ void QGLWidgetPrivate::recreateEglSurface()
363
364
WId currentId = q->winId ();
364
365
365
366
if (glcx->d_func ()->eglSurface != EGL_NO_SURFACE) {
367
+ if (glcx == QGLContext::currentContext ())
368
+ glcx->doneCurrent ();
369
+
366
370
eglDestroySurface (glcx->d_func ()->eglContext ->display (),
367
371
glcx->d_func ()->eglSurface );
368
372
}
You can’t perform that action at this time.
0 commit comments