This corrects two issues:
1. Recreating the fbo twice when the widget is shown. Calling
createFramebufferObject() is not necessary in this case since createContext()
will trigger this anyhow due to scenegraphInitialized().
2. Avoid recreating the fbo when the size is the same as before. Some platforms
are keen on sending resize events with the same size. These should be ignored.
What's worse, some platforms (cocoa) generate a resize on exitting (Cmd-Q)
and not ignoring the resize at that stage is dangerous since the scenegraph
is already invalidated.
Task-number: QTBUG-40505
Change-Id: I21ff418fde449aa15eef4d6593e7a518861fcde1
Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
d->renderControl->sync();
}
- d->createContext();
- createFramebufferObject();
+ if (d->context) {
+ // Bail out in the special case of receiving a resize after
+ // scenegraph invalidation during application exit.
+ if (!d->fbo && !d->offscreenWindow->openglContext())
+ return;
+ if (!d->fbo || d->fbo->size() != size() * devicePixelRatio())
+ createFramebufferObject();
+ } else {
+ // This will result in a scenegraphInitialized() signal which
+ // is connected to createFramebufferObject().
+ d->createContext();
+ }
+
d->offscreenWindow->resizeEvent(e);
d->offscreenWindow->setGeometry(0, 0, e->size().width(), e->size().height());