diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 5e573c1e4..3bedb5d5e 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -1098,11 +1098,7 @@ namespace MWGui else if (it->first == "GUI" && it->second == "subtitles") mSubtitlesEnabled = Settings::Manager::getBool ("subtitles", "GUI"); else if (it->first == "GUI" && it->second == "menu transparency") - { - mViewer->stopThreading(); setMenuTransparency(Settings::Manager::getFloat("menu transparency", "GUI")); - mViewer->startThreading(); - } } } diff --git a/components/myguiplatform/myguitexture.cpp b/components/myguiplatform/myguitexture.cpp index 7de7ebfb0..68408dd3a 100644 --- a/components/myguiplatform/myguitexture.cpp +++ b/components/myguiplatform/myguitexture.cpp @@ -141,11 +141,21 @@ namespace osgMyGUI if (!mLockedImage.valid()) throw std::runtime_error("Texture not locked"); + // mTexture might be in use by the draw thread, so create a new texture instead and use that. + osg::ref_ptr newTexture = new osg::Texture2D; + newTexture->setTextureSize(getWidth(), getHeight()); + newTexture->setSourceFormat(mTexture->getSourceFormat()); + newTexture->setSourceType(mTexture->getSourceType()); + newTexture->setFilter(osg::Texture::MIN_FILTER, mTexture->getFilter(osg::Texture::MIN_FILTER)); + newTexture->setFilter(osg::Texture::MAG_FILTER, mTexture->getFilter(osg::Texture::MAG_FILTER)); + newTexture->setWrap(osg::Texture::WRAP_S, mTexture->getWrap(osg::Texture::WRAP_S)); + newTexture->setWrap(osg::Texture::WRAP_T, mTexture->getWrap(osg::Texture::WRAP_T)); + newTexture->setImage(mLockedImage.get()); // Tell the texture it can get rid of the image for static textures (since // they aren't expected to update much at all). - mTexture->setImage(mLockedImage.get()); - mTexture->setUnRefImageDataAfterApply(mUsage.isValue(MyGUI::TextureUsage::Static) ? true : false); - mTexture->dirtyTextureObject(); + newTexture->setUnRefImageDataAfterApply(mUsage.isValue(MyGUI::TextureUsage::Static) ? true : false); + + mTexture = newTexture; mLockedImage = nullptr; } diff --git a/components/myguiplatform/myguitexture.hpp b/components/myguiplatform/myguitexture.hpp index 109858bc8..de385e94d 100644 --- a/components/myguiplatform/myguitexture.hpp +++ b/components/myguiplatform/myguitexture.hpp @@ -42,8 +42,6 @@ namespace osgMyGUI virtual void destroy(); - /// @warning If you intend to change a texture during the frame update, you must either declare the texture with DataVariance::DYNAMIC - /// or temporarily stop the viewer threading, to prevent race conditions with the draw thread. virtual void* lock(MyGUI::TextureUsage access); virtual void unlock(); virtual bool isLocked();