CCTextureCache. Application don't quit.

When I use CCTextureCache::sharedTextureCache()>addImageAsync, my application don’t quit and freeze.
When I write code like this:
void TestController::closeCallback
{
CCTextureCache::sharedTextureCache
>removeAllTextures;
CCTextureCache::sharedTextureCache~~>purgeSharedTextureCache;
}
have exception in module CCScheduler.cpp:
void CCScheduler::removeHashElement
{
ccArrayFree;
pElement~~>target~~>selectorProtocolRelease; // <<<<<<<<<< Here exception
pElement~~>target = NULL;
HASH_DEL(m_pHashForSelectors, pElement);
free(pElement);
}
Can anyone encountered a similar problem?

P.S. I have this problem in Windows version of Marmalade simulator. When run on the Android device, application quit without errors.
After run TextureCacheTest scene on android device, test application need to kill by task manager… :frowning:

I resolve this problem.
I’am using Cocos2d-x 0.11.0 build.
Changed CCTextureCache.cpp file attached in this post.
This file commitee in github repository.

Hi Alex,

please may you briefly describe what you did?
Does it apply only to Marmalade?

Thanks,
G.

I think, this fix may be solve problems on all platforms, because caching thread stay in semaphore wait mode (sem_wait). When application need for terminate, Windows enter to infinite loop in WaitForSingleObject function. To prevent this, I send semaphore to the thread caching before exit, which does wake-up of the thread and it does termination correctly.