From 73722eedf3591f261d038c5969670097fef7469b Mon Sep 17 00:00:00 2001 From: AnyOldName3 Date: Thu, 30 Jan 2020 23:12:54 +0000 Subject: [PATCH] Add default font releaseGLObjects workaround for OSG <3.65 This resolves https://gitlab.com/OpenMW/openmw/issues/4704 I've not compiled this or anything and I'm going off my memory from around ten or eleven months ago, so if this fails CI or causes more problems, that's why. The most likely issue is that we'll need to make the context current before releasing the program. --- apps/opencs/view/render/scenewidget.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/apps/opencs/view/render/scenewidget.cpp b/apps/opencs/view/render/scenewidget.cpp index 8ae9d8a62e..ed232722de 100644 --- a/apps/opencs/view/render/scenewidget.cpp +++ b/apps/opencs/view/render/scenewidget.cpp @@ -100,6 +100,14 @@ RenderWidget::~RenderWidget() try { CompositeViewer::get().removeView(mView); + +#if OSG_VERSION_LESS_THAN(3,6,5) + // before OSG 3.6.4, the default font was a static object, and if it wasn't attached to the scene when a graphics context was destroyed, it's program wouldn't be released. + // 3.6.4 moved it into the object cache, which meant it usually got released, but not here. + // 3.6.5 improved cleanup with osgViewer::CompositeViewer::removeView so it more reliably released associated state for objects in the object cache. + osg::ref_ptr graphicsContext = mView->getCamera()->getGraphicsContext(); + osgText::Font::getDefaultFont()->releaseGLObjects(graphicsContext->getState()); +#endif } catch(const std::exception& e) {