Revamp exception handling. ImportErrorException renamed to DeadlyImportError to avoid silent regressions. Exceptions now thrown by value, and caught by reference. Put guards in all C++ and C API functions to avoid unwanted exception propagation across module and language boundaries.
PLEASE TEST CAREFULLY IF THIS SHOULD CAUSE REGRESSIONS. git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@617 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
This commit is contained in:
@@ -105,10 +105,10 @@ void LWOImporter::InternReadFile( const std::string& pFile,
|
||||
|
||||
// Check whether we can read from the file
|
||||
if( file.get() == NULL)
|
||||
throw new ImportErrorException( "Failed to open LWO file " + pFile + ".");
|
||||
throw DeadlyImportError( "Failed to open LWO file " + pFile + ".");
|
||||
|
||||
if((this->fileSize = (unsigned int)file->FileSize()) < 12)
|
||||
throw new ImportErrorException("LWO: The file is too small to contain the IFF header");
|
||||
throw DeadlyImportError("LWO: The file is too small to contain the IFF header");
|
||||
|
||||
// Allocate storage and copy the contents of the file to a memory buffer
|
||||
std::vector< uint8_t > mBuffer(fileSize);
|
||||
@@ -118,7 +118,7 @@ void LWOImporter::InternReadFile( const std::string& pFile,
|
||||
// Determine the type of the file
|
||||
uint32_t fileType;
|
||||
const char* sz = IFF::ReadHeader(&mBuffer[0],fileType);
|
||||
if (sz)throw new ImportErrorException(sz);
|
||||
if (sz)throw DeadlyImportError(sz);
|
||||
|
||||
mFileBuffer = &mBuffer[0] + 12;
|
||||
fileSize -= 12;
|
||||
@@ -168,7 +168,7 @@ void LWOImporter::InternReadFile( const std::string& pFile,
|
||||
szBuff[1] = (char)(fileType >> 16u);
|
||||
szBuff[2] = (char)(fileType >> 8u);
|
||||
szBuff[3] = (char)(fileType);
|
||||
throw new ImportErrorException(std::string("Unknown LWO sub format: ") + szBuff);
|
||||
throw DeadlyImportError(std::string("Unknown LWO sub format: ") + szBuff);
|
||||
}
|
||||
|
||||
if (AI_LWO_FOURCC_LWOB != fileType) {
|
||||
@@ -179,10 +179,10 @@ void LWOImporter::InternReadFile( const std::string& pFile,
|
||||
// loader that just one layer is used. If this is the case
|
||||
// we need to check now whether the requested layer has been found.
|
||||
if (0xffffffff != configLayerIndex && configLayerIndex > mLayers->size())
|
||||
throw new ImportErrorException("LWO2: The requested layer was not found");
|
||||
throw DeadlyImportError("LWO2: The requested layer was not found");
|
||||
|
||||
if (configLayerName.length() && !hasNamedLayer) {
|
||||
throw new ImportErrorException("LWO2: Unable to find the requested layer: "
|
||||
throw DeadlyImportError("LWO2: Unable to find the requested layer: "
|
||||
+ configLayerName);
|
||||
}
|
||||
}
|
||||
@@ -388,7 +388,7 @@ void LWOImporter::InternReadFile( const std::string& pFile,
|
||||
}
|
||||
|
||||
if (apcNodes.empty() || apcMeshes.empty())
|
||||
throw new ImportErrorException("LWO: No meshes loaded");
|
||||
throw DeadlyImportError("LWO: No meshes loaded");
|
||||
|
||||
// The RemoveRedundantMaterials step will clean this up later
|
||||
pScene->mMaterials = new aiMaterial*[pScene->mNumMaterials = (unsigned int)mSurfaces->size()];
|
||||
@@ -586,7 +586,7 @@ void LWOImporter::GenerateNodeGraph(std::vector<aiNode*>& apcNodes)
|
||||
root->mNumChildren = newSize;
|
||||
}
|
||||
if (!pScene->mRootNode->mNumChildren)
|
||||
throw new ImportErrorException("LWO: Unable to build a valid node graph");
|
||||
throw DeadlyImportError("LWO: Unable to build a valid node graph");
|
||||
|
||||
// Remove a single root node with no meshes assigned to it ...
|
||||
if (1 == pScene->mRootNode->mNumChildren) {
|
||||
@@ -800,7 +800,7 @@ void LWOImporter::CopyFaceIndicesLWO2(FaceList::iterator& it,
|
||||
}
|
||||
}
|
||||
}
|
||||
else throw new ImportErrorException("LWO2: Encountered invalid face record with zero indices");
|
||||
else throw DeadlyImportError("LWO2: Encountered invalid face record with zero indices");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1151,7 +1151,7 @@ void LWOImporter::LoadLWO2Envelope(unsigned int length)
|
||||
LE_NCONST IFF::SubChunkHeader* const head = IFF::LoadSubChunk(mFileBuffer);
|
||||
|
||||
if (mFileBuffer + head->length > end)
|
||||
throw new ImportErrorException("LWO2: Invalid envelope chunk length");
|
||||
throw DeadlyImportError("LWO2: Invalid envelope chunk length");
|
||||
|
||||
uint8_t* const next = mFileBuffer+head->length;
|
||||
switch (head->type)
|
||||
@@ -1244,7 +1244,7 @@ void LWOImporter::LoadLWO2File()
|
||||
|
||||
if (mFileBuffer + head->length > end)
|
||||
{
|
||||
throw new ImportErrorException("LWO2: Chunk length points behind the file");
|
||||
throw DeadlyImportError("LWO2: Chunk length points behind the file");
|
||||
break;
|
||||
}
|
||||
uint8_t* const next = mFileBuffer+head->length;
|
||||
|
||||
Reference in New Issue
Block a user