mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-30 10:15:38 +00:00
Merge branch 'loading_screen_race_condition' into 'master'
Fix a race condition in loading screen. See merge request OpenMW/openmw!568
This commit is contained in:
commit
87d80b3d0a
2 changed files with 2 additions and 49 deletions
|
@ -45,8 +45,6 @@ namespace MWGui
|
|||
, mNestedLoadingCount(0)
|
||||
, mProgress(0)
|
||||
, mShowWallpaper(true)
|
||||
, mOldCallback(nullptr)
|
||||
, mHasCallback(false)
|
||||
{
|
||||
mMainWidget->setSize(MyGUI::RenderManager::getInstance().getViewSize());
|
||||
|
||||
|
@ -147,35 +145,11 @@ namespace MWGui
|
|||
|
||||
void operator () (osg::RenderInfo& renderInfo) const override
|
||||
{
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(mMutex);
|
||||
mOneshot = false;
|
||||
}
|
||||
mSignal.notify_all();
|
||||
|
||||
int w = renderInfo.getCurrentCamera()->getViewport()->width();
|
||||
int h = renderInfo.getCurrentCamera()->getViewport()->height();
|
||||
mTexture->copyTexImage2D(*renderInfo.getState(), 0, 0, w, h);
|
||||
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(mMutex);
|
||||
mOneshot = false;
|
||||
}
|
||||
mSignal.notify_all();
|
||||
}
|
||||
|
||||
void wait()
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(mMutex);
|
||||
while (mOneshot)
|
||||
mSignal.wait(lock);
|
||||
}
|
||||
|
||||
void waitUntilInvoked()
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(mMutex);
|
||||
while (mOneshot)
|
||||
mSignal.wait(lock);
|
||||
mOneshot = false;
|
||||
}
|
||||
|
||||
void reset()
|
||||
|
@ -185,8 +159,6 @@ namespace MWGui
|
|||
|
||||
private:
|
||||
mutable bool mOneshot;
|
||||
mutable std::mutex mMutex;
|
||||
mutable std::condition_variable mSignal;
|
||||
osg::ref_ptr<osg::Texture2D> mTexture;
|
||||
};
|
||||
|
||||
|
@ -362,14 +334,12 @@ namespace MWGui
|
|||
}
|
||||
|
||||
#if OSG_VERSION_GREATER_OR_EQUAL(3, 5, 10)
|
||||
mViewer->getCamera()->removeInitialDrawCallback(mCopyFramebufferToTextureCallback);
|
||||
mViewer->getCamera()->addInitialDrawCallback(mCopyFramebufferToTextureCallback);
|
||||
#else
|
||||
// TODO: Remove once we officially end support for OSG versions pre 3.5.10
|
||||
mOldCallback = mViewer->getCamera()->getInitialDrawCallback();
|
||||
mViewer->getCamera()->setInitialDrawCallback(mCopyFramebufferToTextureCallback);
|
||||
#endif
|
||||
mCopyFramebufferToTextureCallback->reset();
|
||||
mHasCallback = true;
|
||||
|
||||
mBackgroundImage->setBackgroundImage("");
|
||||
mBackgroundImage->setVisible(false);
|
||||
|
@ -412,21 +382,6 @@ namespace MWGui
|
|||
mViewer->renderingTraversals();
|
||||
mViewer->advance(mViewer->getFrameStamp()->getSimulationTime());
|
||||
|
||||
if (mHasCallback)
|
||||
{
|
||||
mCopyFramebufferToTextureCallback->waitUntilInvoked();
|
||||
|
||||
// Note that we are removing the callback before the draw thread has returned from it.
|
||||
// This is OK as we are retaining the ref_ptr.
|
||||
#if OSG_VERSION_GREATER_OR_EQUAL(3, 5, 10)
|
||||
mViewer->getCamera()->removeInitialDrawCallback(mCopyFramebufferToTextureCallback);
|
||||
#else
|
||||
// TODO: Remove once we officially end support for OSG versions pre 3.5.10
|
||||
mViewer->getCamera()->setInitialDrawCallback(mOldCallback);
|
||||
#endif
|
||||
mHasCallback = false;
|
||||
}
|
||||
|
||||
mLastRenderTime = mTimer.time_m();
|
||||
}
|
||||
|
||||
|
|
|
@ -87,8 +87,6 @@ namespace MWGui
|
|||
|
||||
osg::ref_ptr<osg::Texture2D> mTexture;
|
||||
osg::ref_ptr<CopyFramebufferToTextureCallback> mCopyFramebufferToTextureCallback;
|
||||
osg::ref_ptr<osg::Camera::DrawCallback> mOldCallback;
|
||||
bool mHasCallback;
|
||||
std::unique_ptr<MyGUI::ITexture> mGuiTexture;
|
||||
|
||||
void changeWallpaper();
|
||||
|
|
Loading…
Reference in a new issue