Merge pull request #691 from winbinar/master

fixed #626: Fix bug #626
This commit is contained in:
minggo 2012-02-05 23:00:31 -08:00
commit babbd64f0d
1 changed files with 8 additions and 3 deletions

View File

@ -64,6 +64,7 @@ static pthread_mutex_t s_asyncStructQueueMutex;
static pthread_mutex_t s_ImageInfoMutex;
static sem_t s_sem;
static bool need_quit;
static std::queue<AsyncStruct*> *s_pAsyncStructQueue;
static std::queue<ImageInfo*> *s_pImageQueue;
@ -103,7 +104,10 @@ static void* loadImage(void* data)
if (pQueue->empty())
{
pthread_mutex_unlock(&s_asyncStructQueueMutex);
continue;
if (need_quit)
break;
else
continue;
}
else
{
@ -171,7 +175,8 @@ CCTextureCache::CCTextureCache()
CCTextureCache::~CCTextureCache()
{
CCLOGINFO("cocos2d: deallocing CCTextureCache.");
need_quit = true;
sem_post(&s_sem);
CC_SAFE_RELEASE(m_pTextures);
}
@ -231,7 +236,7 @@ void CCTextureCache::addImageAsync(const char *path, CCObject *target, SEL_CallF
pthread_create(&s_loadingThread, NULL, loadImage, NULL);
CCScheduler::sharedScheduler()->scheduleSelector(schedule_selector(CCTextureCache::addImageAsyncCallBack), this, 0, false);
need_quit = false;
firstRun = false;
}