1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-03-15 07:29:15 +01:00

LP-32 workaround lost texture when switching tab

This commit is contained in:
Philippe Renon 2016-06-25 16:21:54 +02:00 committed by Philippe Renon
parent 33b052947b
commit 4cd817fe3a

View File

@ -181,6 +181,8 @@ public:
bool busy;
static osg::ref_ptr<osg::GraphicsContext> dummyGC;
static QtKeyboardMap keyMap;
Hidden(OSGViewport *self) : QObject(self), self(self), window(NULL), frameTimer(-1),
@ -188,6 +190,13 @@ public:
{
OsgEarth::initialize();
// workaround to avoid using GraphicsContext #0
// when switching tabs textures are not rebound (see https://librepilot.atlassian.net/secure/attachment/11500/lost_textures.png)
// so we create and retain GraphicsContext #0 so it won't be used elsewhere
if (!dummyGC.valid()) {
dummyGC = createGraphicsContext();
}
createViewer();
connect(self, &OSGViewport::windowChanged, this, &Hidden::onWindowChanged);
@ -491,7 +500,7 @@ private:
traits->x = 0;
traits->y = 0;
int dpr = self->window()->devicePixelRatio();
int dpr = self->window() ? self->window()->devicePixelRatio() : 1;
traits->width = self->width() * dpr;
traits->height = self->height() * dpr;
@ -699,6 +708,8 @@ public:
QtKeyboardMap OSGViewport::Hidden::keyMap = QtKeyboardMap();
osg::ref_ptr<osg::GraphicsContext> OSGViewport::Hidden::dummyGC;
/* class OSGViewport */
OSGViewport::OSGViewport(QQuickItem *parent) : Inherited(parent), h(new Hidden(this))