fix review finding: fix resource leak.
parent
3596c822a5
commit
92bb0febdf
|
@ -89,14 +89,16 @@ static const aiImporterDesc desc = {
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Constructor to be privately used by Importer
|
// Constructor to be privately used by Importer
|
||||||
IRRImporter::IRRImporter()
|
IRRImporter::IRRImporter()
|
||||||
: fps(),
|
: fps()
|
||||||
configSpeedFlag()
|
, configSpeedFlag(){
|
||||||
{}
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Destructor, private as well
|
// Destructor, private as well
|
||||||
IRRImporter::~IRRImporter()
|
IRRImporter::~IRRImporter() {
|
||||||
{}
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Returns whether the class can handle the format of the given file.
|
// Returns whether the class can handle the format of the given file.
|
||||||
|
@ -107,9 +109,9 @@ bool IRRImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool
|
||||||
} else if (extension == "xml" || checkSig) {
|
} else if (extension == "xml" || checkSig) {
|
||||||
/* If CanRead() is called in order to check whether we
|
/* If CanRead() is called in order to check whether we
|
||||||
* support a specific file extension in general pIOHandler
|
* support a specific file extension in general pIOHandler
|
||||||
* might be NULL and it's our duty to return true here.
|
* might be nullptr and it's our duty to return true here.
|
||||||
*/
|
*/
|
||||||
if ( nullptr == pIOHandler ) {
|
if (nullptr == pIOHandler ) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
const char* tokens[] = {"irr_scene"};
|
const char* tokens[] = {"irr_scene"};
|
||||||
|
@ -290,8 +292,8 @@ void IRRImporter::CopyMaterial(std::vector<aiMaterial*>& materials,
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
inline int ClampSpline(int idx, int size)
|
inline
|
||||||
{
|
int ClampSpline(int idx, int size) {
|
||||||
return ( idx<0 ? size+idx : ( idx>=size ? idx-size : idx ) );
|
return ( idx<0 ? size+idx : ( idx>=size ? idx-size : idx ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -310,7 +312,7 @@ inline void FindSuitableMultiple(int& angle)
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void IRRImporter::ComputeAnimations(Node* root, aiNode* real, std::vector<aiNodeAnim*>& anims)
|
void IRRImporter::ComputeAnimations(Node* root, aiNode* real, std::vector<aiNodeAnim*>& anims)
|
||||||
{
|
{
|
||||||
ai_assert(NULL != root && NULL != real);
|
ai_assert(nullptr != root && nullptr != real);
|
||||||
|
|
||||||
// XXX totally WIP - doesn't produce proper results, need to evaluate
|
// XXX totally WIP - doesn't produce proper results, need to evaluate
|
||||||
// whether there's any use for Irrlicht's proprietary scene format
|
// whether there's any use for Irrlicht's proprietary scene format
|
||||||
|
@ -521,7 +523,8 @@ void IRRImporter::ComputeAnimations(Node* root, aiNode* real, std::vector<aiNode
|
||||||
// We have no point in the spline. That's bad. Really bad.
|
// We have no point in the spline. That's bad. Really bad.
|
||||||
ASSIMP_LOG_WARN("IRR: Spline animators with no points defined");
|
ASSIMP_LOG_WARN("IRR: Spline animators with no points defined");
|
||||||
|
|
||||||
delete anim;anim = nullptr;
|
delete anim;
|
||||||
|
anim = nullptr;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (size == 1) {
|
else if (size == 1) {
|
||||||
|
@ -905,8 +908,9 @@ void IRRImporter::InternReadFile( const std::string& pFile,
|
||||||
std::unique_ptr<IOStream> file( pIOHandler->Open( pFile));
|
std::unique_ptr<IOStream> file( pIOHandler->Open( pFile));
|
||||||
|
|
||||||
// Check whether we can read from the file
|
// Check whether we can read from the file
|
||||||
if( file.get() == NULL)
|
if (file.get() == nullptr) {
|
||||||
throw DeadlyImportError( "Failed to open IRR file " + pFile + "");
|
throw DeadlyImportError("Failed to open IRR file " + pFile + "");
|
||||||
|
}
|
||||||
|
|
||||||
// Construct the irrXML parser
|
// Construct the irrXML parser
|
||||||
CIrrXML_IOStreamReader st(file.get());
|
CIrrXML_IOStreamReader st(file.get());
|
||||||
|
@ -914,14 +918,14 @@ void IRRImporter::InternReadFile( const std::string& pFile,
|
||||||
|
|
||||||
// The root node of the scene
|
// The root node of the scene
|
||||||
Node* root = new Node(Node::DUMMY);
|
Node* root = new Node(Node::DUMMY);
|
||||||
root->parent = NULL;
|
root->parent = nullptr;
|
||||||
root->name = "<IRRSceneRoot>";
|
root->name = "<IRRSceneRoot>";
|
||||||
|
|
||||||
// Current node parent
|
// Current node parent
|
||||||
Node* curParent = root;
|
Node* curParent = root;
|
||||||
|
|
||||||
// Scenegraph node we're currently working on
|
// Scenegraph node we're currently working on
|
||||||
Node* curNode = NULL;
|
Node* curNode = nullptr;
|
||||||
|
|
||||||
// List of output cameras
|
// List of output cameras
|
||||||
std::vector<aiCamera*> cameras;
|
std::vector<aiCamera*> cameras;
|
||||||
|
@ -1048,7 +1052,7 @@ void IRRImporter::InternReadFile( const std::string& pFile,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Animator* curAnim = NULL;
|
Animator* curAnim = nullptr;
|
||||||
|
|
||||||
// Materials can occur for nearly any type of node
|
// Materials can occur for nearly any type of node
|
||||||
if (inMaterials && curNode->type != Node::DUMMY) {
|
if (inMaterials && curNode->type != Node::DUMMY) {
|
||||||
|
@ -1353,7 +1357,7 @@ void IRRImporter::InternReadFile( const std::string& pFile,
|
||||||
}
|
}
|
||||||
else curParent = curParent->parent;
|
else curParent = curParent->parent;
|
||||||
}
|
}
|
||||||
else curNode = NULL;
|
else curNode = nullptr;
|
||||||
}
|
}
|
||||||
// clear all flags
|
// clear all flags
|
||||||
else if (!ASSIMP_stricmp(reader->getNodeName(),"materials")) {
|
else if (!ASSIMP_stricmp(reader->getNodeName(),"materials")) {
|
||||||
|
@ -1479,7 +1483,8 @@ void IRRImporter::InternReadFile( const std::string& pFile,
|
||||||
/* Finished ... everything destructs automatically and all
|
/* Finished ... everything destructs automatically and all
|
||||||
* temporary scenes have already been deleted by MergeScenes()
|
* temporary scenes have already been deleted by MergeScenes()
|
||||||
*/
|
*/
|
||||||
return;
|
|
||||||
|
delete root;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // !! ASSIMP_BUILD_NO_IRR_IMPORTER
|
#endif // !! ASSIMP_BUILD_NO_IRR_IMPORTER
|
||||||
|
|
Loading…
Reference in New Issue