Jump to content

Missing Filesystem::getFile() failure check


photo

Recommended Posts

Problem

 

mesh/texture load fails with error message "wrong magic"

 

Cause

 

error message is just a symptom for failed FileSystem background load operation (FileThread.data/size = 0). During Filesystem::getFile() this condition is not checked and a FileInterface with invalid data is returned.

 

Fix

 

FileSystem.cpp

FileInterface *FileSystem::getFile(const char *n,const char *mode) {
....

   /////////////////////////////////
   // thread file
   /////////////////////////////////

   if(engine.threads) {
       ....		
if(it != loaded_files.end()) {

            FileInterface *file = NULL;

            // CHECK FOR NON-NULL DATA
            if( it->data.size > 0 ) {
                file = new FileMemory(name,it->data.data,it->data.size,1);
     }	

            loaded_files.remove(it);

            engine.threads->unlockFileSystem();

            return file;
        }
        .....	

Link to comment
  • 3 weeks later...

That's really odd, we'll re-check it tomorrow.

 

I think the bug which caused failed background loads in previous release is fixed, so in most cases the missing failure test does not show up. Nevertheless if background load fails for some other reasons getFile() should return NULL to signal failure as documented.

Link to comment

FileSystem::getFile() returns an empty file if file can't be opened. File is checked in cached files list before background loading. So file should really exist and if we can't open it in filesystem thread an empty file will be returned. The incorrect behavior is not likely to happen. I will add NULL return in the next update.

Link to comment
×
×
  • Create New...