mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-10 01:09:50 +00:00
Changed: Destructor for CApplicationContext to display singletons still in memory
--HG-- branch : develop
This commit is contained in:
parent
bbcd14cecb
commit
ba35109fe4
2 changed files with 22 additions and 0 deletions
|
@ -108,6 +108,7 @@ namespace NLMISC
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CApplicationContext();
|
CApplicationContext();
|
||||||
|
virtual ~CApplicationContext();
|
||||||
|
|
||||||
virtual void *getSingletonPointer(const std::string &singletonName);
|
virtual void *getSingletonPointer(const std::string &singletonName);
|
||||||
virtual void setSingletonPointer(const std::string &singletonName, void *ptr);
|
virtual void setSingletonPointer(const std::string &singletonName, void *ptr);
|
||||||
|
|
|
@ -124,6 +124,27 @@ CApplicationContext::CApplicationContext()
|
||||||
contextReady();
|
contextReady();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CApplicationContext::~CApplicationContext()
|
||||||
|
{
|
||||||
|
#ifdef NL_DEBUG
|
||||||
|
TSingletonRegistry::iterator it = _SingletonRegistry.begin(), iend = _SingletonRegistry.end();
|
||||||
|
|
||||||
|
while (it != iend)
|
||||||
|
{
|
||||||
|
// can't use nldebug there because it'll create new displayers
|
||||||
|
std::string message = toString("Instance '%s' still allocated at %p", it->first.c_str(), it->second);
|
||||||
|
|
||||||
|
#ifdef NL_OS_WINDOWS
|
||||||
|
OutputDebugStringW(utf8ToWide(message));
|
||||||
|
#else
|
||||||
|
printf("%s\n", message.c_str());
|
||||||
|
#endif
|
||||||
|
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void *CApplicationContext::getSingletonPointer(const std::string &singletonName)
|
void *CApplicationContext::getSingletonPointer(const std::string &singletonName)
|
||||||
{
|
{
|
||||||
TSingletonRegistry::iterator it(_SingletonRegistry.find(singletonName));
|
TSingletonRegistry::iterator it(_SingletonRegistry.find(singletonName));
|
||||||
|
|
Loading…
Reference in a new issue