mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-08-03 15:27:13 -04:00
Merge branch 'thread_safe_static_init' into 'master'
Do thread safe local static based initialization See merge request OpenMW/openmw!4822
This commit is contained in:
commit
3781485edd
@ -774,12 +774,10 @@ namespace MWGui
|
||||
, mGlobalMapRender(std::make_unique<MWRender::GlobalMap>(localMapRender->getRoot(), workQueue))
|
||||
, mEditNoteDialog()
|
||||
{
|
||||
static bool registered = false;
|
||||
if (!registered)
|
||||
{
|
||||
[[maybe_unused]] static const bool registered = [] {
|
||||
MyGUI::FactoryManager::getInstance().registerFactory<MarkerWidget>("Widget");
|
||||
registered = true;
|
||||
}
|
||||
return true;
|
||||
}();
|
||||
|
||||
mEditNoteDialog.setVisible(false);
|
||||
mEditNoteDialog.eventOkClicked += MyGUI::newDelegate(this, &MapWindow::onNoteEditOk);
|
||||
|
@ -401,14 +401,12 @@ namespace MWRender
|
||||
{
|
||||
if (mViewMode == VM_FirstPerson)
|
||||
{
|
||||
static bool prototypeAdded = false;
|
||||
if (!prototypeAdded)
|
||||
{
|
||||
[[maybe_unused]] static const bool prototypeAdded = [&] {
|
||||
osg::ref_ptr<osgUtil::RenderBin> depthClearBin(new osgUtil::RenderBin);
|
||||
depthClearBin->setDrawCallback(new DepthClearCallback());
|
||||
osgUtil::RenderBin::addRenderBinPrototype("DepthClear", depthClearBin);
|
||||
prototypeAdded = true;
|
||||
}
|
||||
return true;
|
||||
}();
|
||||
mObjectRoot->getOrCreateStateSet()->setRenderBinDetails(
|
||||
RenderBin_FirstPerson, "DepthClear", osg::StateSet::OVERRIDE_RENDERBIN_DETAILS);
|
||||
}
|
||||
|
@ -88,14 +88,13 @@ namespace MWRender
|
||||
|
||||
if (mProgramBlobber != nullptr)
|
||||
{
|
||||
static bool pipelineLogged = [&] {
|
||||
[[maybe_unused]] static const bool pipelineLogged = [&] {
|
||||
if (mUseCompute)
|
||||
Log(Debug::Info) << "Initialized compute shader pipeline for water ripples";
|
||||
else
|
||||
Log(Debug::Info) << "Initialized fallback fragment shader pipeline for water ripples";
|
||||
return true;
|
||||
}();
|
||||
(void)pipelineLogged;
|
||||
}
|
||||
|
||||
setCullCallback(new osg::NodeCallback);
|
||||
|
@ -522,16 +522,14 @@ namespace MWSound
|
||||
|
||||
/* We need to make sure ffmpeg is initialized. Optionally silence warning
|
||||
* output from the lib */
|
||||
static bool done_init = false;
|
||||
if (!done_init)
|
||||
{
|
||||
[[maybe_unused]] static const bool doneInit = [] {
|
||||
// This is not needed anymore above FFMpeg version 4.0
|
||||
#if LIBAVCODEC_VERSION_INT < 3805796
|
||||
av_register_all();
|
||||
#endif
|
||||
av_log_set_level(AV_LOG_ERROR);
|
||||
done_init = true;
|
||||
}
|
||||
return true;
|
||||
}();
|
||||
}
|
||||
|
||||
FFmpegDecoder::~FFmpegDecoder()
|
||||
|
@ -1273,13 +1273,12 @@ namespace MWWorld
|
||||
const std::size_t leftCapacity = mPreloader->getMaxCacheSize() - mPreloader->getCacheSize();
|
||||
if (cells.size() > leftCapacity)
|
||||
{
|
||||
static bool logged = [&] {
|
||||
[[maybe_unused]] static const bool logged = [&] {
|
||||
Log(Debug::Warning) << "Not enough cell preloader cache capacity to preload exterior cells, consider "
|
||||
"increasing \"preload cell cache max\" up to "
|
||||
<< (mPreloader->getCacheSize() + cells.size());
|
||||
return true;
|
||||
}();
|
||||
(void)logged;
|
||||
cells.resize(leftCapacity);
|
||||
}
|
||||
|
||||
|
@ -95,13 +95,10 @@ namespace SceneUtil
|
||||
|
||||
static void setReversed(bool reverseZ)
|
||||
{
|
||||
static bool init = false;
|
||||
|
||||
if (!init)
|
||||
{
|
||||
[[maybe_unused]] static const bool init = [&] {
|
||||
AutoDepth::sReversed = reverseZ;
|
||||
init = true;
|
||||
}
|
||||
return true;
|
||||
}();
|
||||
}
|
||||
|
||||
static bool isReversed()
|
||||
|
Loading…
x
Reference in New Issue
Block a user