From b37b635a7ccf30b6dd06e07917b665b923c30931 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 25 Jul 2017 15:58:27 +0100 Subject: [PATCH] Merged GLExtension deletion mechanism from master to avoid GLEXtension being deleted when shared contexts are used and osg::State is deleted when a context is deleted. --- src/osg/State.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/osg/State.cpp b/src/osg/State.cpp index abd0ddb90..778be2f3e 100644 --- a/src/osg/State.cpp +++ b/src/osg/State.cpp @@ -139,8 +139,12 @@ State::~State() // delete the GLExtensions object associated with this osg::State. if (_glExtensions) { - GLExtensions::Set(_contextID, 0); _glExtensions = 0; + GLExtensions* glExtensions = GLExtensions::Get(_contextID, false); + if (glExtensions && glExtensions->referenceCount() == 1) { + // the only reference left to the extension is in the static map itself, so we clean it up now + GLExtensions::Set(_contextID, 0); + } } //_texCoordArrayList.clear();