Changeset 8712

Show
Ignore:
Timestamp:
08/04/08 11:05:29 (6 years ago)
Author:
robert
Message:

From Ulrich Hertlien, "attached is a patch to src/osgPlugins/quicktime/QTImportExport.cpp that fixes loading images using the quicktime loader. Also fixes some minor bugs like uninitialized variables and incorrect deletes.

I'm a bit puzzled why this didn't pop up for more people as it's quite severe: basically the filename was never set!""

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/src/osgPlugins/quicktime/QTImportExport.cpp

    r8132 r8712  
    248248     // Convert From CString in filename to a PascalString in pstr 
    249249     if (filename.length() > 255) { 
    250          CopyCStringToPascal(filename.c_str(), pstr); 
    251250         //hmm...not good, pascal string limit is 255! 
    252251         //do some error handling maybe?! 
     252         throw QTImportExportException(0, "filename length limit exceeded"); 
    253253     } 
     254     CopyCStringToPascal(filename.c_str(), pstr); 
    254255  
    255256    // Add filename extension 
     
    283284    int depth = 32; 
    284285    unsigned int xsize, ysize; 
    285     unsigned char* imageData; 
     286    unsigned char* imageData = 0; 
    286287     
    287288    // Data Handle for file data ( & load data from file ) 
     
    360361        DisposeHandle(dataRef); 
    361362    }  
    362     catch (QTImportExportException e)  
     363    catch (QTImportExportException& e)  
    363364    { 
    364365        setError(e.what()); 
     
    384385 
    385386     
     387    unsigned int bytesPerPixel = depth / 8; 
    386388    unsigned int glpixelFormat; 
    387              
    388     switch(depth >> 3) { 
     389    switch(bytesPerPixel) { 
    389390        case 3 : 
    390391            glpixelFormat = GL_RGB; 
     
    394395            break; 
    395396        default : 
    396             delete imageData; 
     397            delete[] imageData; 
    397398            setError("unknown pixelformat"); 
    398399            return NULL; 
     
    400401    } 
    401402     
    402     unsigned char* swizzled = pepareBufferForOSG(imageData, depth >> 3, xsize, ysize); 
     403    unsigned char* swizzled = pepareBufferForOSG(imageData, bytesPerPixel, xsize, ysize); 
    403404     
    404405    delete[] imageData; 
     
    407408    image->setFileName(fileTypeHint.c_str()); 
    408409    image->setImage(xsize,ysize,1, 
    409         depth >> 3, 
     410        bytesPerPixel, 
    410411        glpixelFormat, 
    411412        GL_UNSIGNED_BYTE, 
     
    511512     
    512513     
    513     catch (QTImportExportException e)  
     514    catch (QTImportExportException& e)  
    514515    { 
    515516        setError(e.what());