the size of bytes read from jpg image is wrong when using CCImage::initWithImageFileThreadSafe(...) in a separate thread


i need to load images in a separate thread. this code i used is copied from the function loadImage in CCTextureCache.cpp,
@ @ // generate image@
@ CCImage *pImage = new CCImage();@
@ if (pImage && !pImage->initWithImageFileThreadSafe(filename, imageType))@
@ {@
@ CCLOG (“can not load %s”, filename);@
@ continue;@
@ }@
everything is OK when i run it on iphone4. But when i run it on android device, it reports an error “cocos2d-x debug info(24717): Assert failed: the file size is wrong”, i find the code generate this error in function ZipFile::getFileData in cocos2dx/support/zip_support/ZipUtils.cpp. i print the nSize and fileInfo.uncompressed_size, nSize is 81920, fileInfo.uncompressed_size is 113794 which is right. Can anyone give me some infomation about this error? Thanks!


anyone who has thoughts of this problem?


finally i find the problem, CCImage::initWithImageFileThreadSafe is not thread safe if you use more than 1 thread on android because it uses ZipUtil::getFileData. i have to say the implementation of CCImage::initWithImageFileThreadSafe is not completed. you can find the discussion