mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-22 03:40:49 +00:00
Cope with scene widgets being destroyed in a weird order
I can't actually test this as the CS still doesn't get far enough with this MR.
This commit is contained in:
parent
53afa6b185
commit
ec4731d454
@ -4,16 +4,29 @@ namespace SceneUtil
|
|||||||
{
|
{
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
osg::observer_ptr<osg::GLExtensions> sGLExtensions;
|
std::set<osg::observer_ptr<osg::GLExtensions>> sGLExtensions;
|
||||||
|
|
||||||
|
class GLExtensionsObserver : public osg::Observer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static GLExtensionsObserver sInstance;
|
||||||
|
|
||||||
|
void objectDeleted(void* referenced) override
|
||||||
|
{
|
||||||
|
sGLExtensions.erase(static_cast<osg::GLExtensions*>(referenced));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
GLExtensionsObserver GLExtensionsObserver::sInstance{};
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::GLExtensions& getGLExtensions()
|
osg::GLExtensions& getGLExtensions()
|
||||||
{
|
{
|
||||||
if (!sGLExtensions)
|
if (sGLExtensions.empty())
|
||||||
throw std::runtime_error(
|
throw std::runtime_error(
|
||||||
"GetGLExtensionsOperation was not used when the current context was created or there is no current "
|
"GetGLExtensionsOperation was not used when the current context was created or there is no current "
|
||||||
"context");
|
"context");
|
||||||
return *sGLExtensions;
|
return **sGLExtensions.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
GetGLExtensionsOperation::GetGLExtensionsOperation()
|
GetGLExtensionsOperation::GetGLExtensionsOperation()
|
||||||
@ -23,6 +36,7 @@ namespace SceneUtil
|
|||||||
|
|
||||||
void GetGLExtensionsOperation::operator()(osg::GraphicsContext* graphicsContext)
|
void GetGLExtensionsOperation::operator()(osg::GraphicsContext* graphicsContext)
|
||||||
{
|
{
|
||||||
sGLExtensions = graphicsContext->getState()->get<osg::GLExtensions>();
|
auto [itr, _] = sGLExtensions.emplace(graphicsContext->getState()->get<osg::GLExtensions>());
|
||||||
|
(*itr)->addObserver(&GLExtensionsObserver::sInstance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user