From 5adacde9013da68bddd089b1c2851ce25b66c855 Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Sat, 17 Dec 2016 03:27:25 +0000 Subject: [PATCH] stfu clang --- .../src/shared/DataResourceList.h | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/engine/shared/library/sharedFoundation/src/shared/DataResourceList.h b/engine/shared/library/sharedFoundation/src/shared/DataResourceList.h index f2476eeb..1af4b29f 100755 --- a/engine/shared/library/sharedFoundation/src/shared/DataResourceList.h +++ b/engine/shared/library/sharedFoundation/src/shared/DataResourceList.h @@ -7,6 +7,9 @@ // //======================================================================== +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wundefined-var-template" + #ifndef _INCLUDED_DataResourceList_H #define _INCLUDED_DataResourceList_H @@ -82,10 +85,13 @@ private: template inline void DataResourceList::install() { - auto static *ms_bindings = new CreateDataResourceMap(); - auto static *ms_loaded = new LoadedDataResourceMap(); + if (ms_bindings == nullptr) + { + ms_bindings = new CreateDataResourceMap(); + ms_loaded = new LoadedDataResourceMap(); - ExitChain::add (remove, "DataResourceList::remove"); + ExitChain::add (remove, "DataResourceList::remove"); + } } // DataResourceList::install //---------------------------------------------------------------------- @@ -97,9 +103,6 @@ inline void DataResourceList::install() template inline void DataResourceList::remove(void) { - auto static *ms_bindings = new CreateDataResourceMap(); - auto static *ms_loaded = new LoadedDataResourceMap(); - if (ms_loaded != nullptr) { #ifdef _DEBUG @@ -122,11 +125,13 @@ inline void DataResourceList::remove(void) #endif // _DEBUG delete ms_loaded; + ms_loaded = nullptr; } if (ms_bindings != nullptr) { delete ms_bindings; + ms_bindings = nullptr; } } // DataResourceList::remove @@ -142,9 +147,6 @@ template inline void DataResourceList::registerTemplate(Tag id, CreateDataResourceFunc createFunc) { - auto static *ms_bindings = new CreateDataResourceMap(); - auto static *ms_loaded = new LoadedDataResourceMap(); - if (ms_bindings == nullptr) install(); @@ -198,6 +200,8 @@ template inline typename DataResourceList::CreateDataResourceFunc DataResourceList::removeBinding( Tag id) { + NOT_NULL(ms_bindings); + CreateDataResourceFunc oldFunc = (*ms_bindings)[id]; ms_bindings->erase(id); return oldFunc; @@ -232,8 +236,7 @@ inline const T * DataResourceList::fetch(const char * filename) template inline T * DataResourceList::fetch(Tag id) { - auto static *ms_bindings = new CreateDataResourceMap(); - auto static *ms_loaded = new LoadedDataResourceMap(); + NOT_NULL(ms_bindings); typename CreateDataResourceMap::iterator iter = ms_bindings->find(id); if (iter == ms_bindings->end()) @@ -254,8 +257,7 @@ inline T * DataResourceList::fetch(Tag id) template inline const T * DataResourceList::fetch(Iff &source) { - auto static *ms_bindings = new CreateDataResourceMap(); - auto static *ms_loaded = new LoadedDataResourceMap(); + NOT_NULL(ms_bindings); #ifdef _DEBUG DataLint::pushAsset(source.getFileName()); @@ -298,8 +300,7 @@ inline const T * DataResourceList::fetch(Iff &source) template inline const T * DataResourceList::fetch(const CrcString &filename) { - auto static *ms_bindings = new CreateDataResourceMap(); - auto static *ms_loaded = new LoadedDataResourceMap(); + NOT_NULL(ms_loaded); // see if we already have loaded the template typename LoadedDataResourceMap::iterator iter = ms_loaded->find(&filename); @@ -337,18 +338,17 @@ inline const T * DataResourceList::fetch(const CrcString &filename) template inline void DataResourceList::release(const T & dataResource) { - auto static *ms_bindings = new CreateDataResourceMap(); - auto static *ms_loaded = new LoadedDataResourceMap(); + NOT_NULL(ms_loaded); if (ms_loaded != nullptr && dataResource.getReferenceCount() == 0) { typename LoadedDataResourceMap::iterator iter = ms_loaded->find(&dataResource.getCrcName()); if (iter != ms_loaded->end()) { - delete (*iter).second; + const T * const temp = (*iter).second; (*iter).second = nullptr; - - iter = ms_loaded->erase(iter); + ms_loaded->erase(iter); + delete temp; } } } // DataResourceList::release @@ -422,5 +422,5 @@ void DataResourceList::garbageCollect () } //---------------------------------------------------------------------- - +#pragma clang diagnostic pop #endif // _INCLUDED_DataResourceList_H