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
|
||||
IRRImporter::IRRImporter()
|
||||
: fps(),
|
||||
configSpeedFlag()
|
||||
{}
|
||||
: fps()
|
||||
, configSpeedFlag(){
|
||||
// empty
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Destructor, private as well
|
||||
IRRImporter::~IRRImporter()
|
||||
{}
|
||||
IRRImporter::~IRRImporter() {
|
||||
// empty
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// 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) {
|
||||
/* If CanRead() is called in order to check whether we
|
||||
* 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;
|
||||
}
|
||||
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 ) );
|
||||
}
|
||||
|
||||
|
@ -310,7 +312,7 @@ inline void FindSuitableMultiple(int& angle)
|
|||
// ------------------------------------------------------------------------------------------------
|
||||
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
|
||||
// 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.
|
||||
ASSIMP_LOG_WARN("IRR: Spline animators with no points defined");
|
||||
|
||||
delete anim;anim = nullptr;
|
||||
delete anim;
|
||||
anim = nullptr;
|
||||
break;
|
||||
}
|
||||
else if (size == 1) {
|
||||
|
@ -905,8 +908,9 @@ void IRRImporter::InternReadFile( const std::string& pFile,
|
|||
std::unique_ptr<IOStream> file( pIOHandler->Open( pFile));
|
||||
|
||||
// Check whether we can read from the file
|
||||
if( file.get() == NULL)
|
||||
throw DeadlyImportError( "Failed to open IRR file " + pFile + "");
|
||||
if (file.get() == nullptr) {
|
||||
throw DeadlyImportError("Failed to open IRR file " + pFile + "");
|
||||
}
|
||||
|
||||
// Construct the irrXML parser
|
||||
CIrrXML_IOStreamReader st(file.get());
|
||||
|
@ -914,14 +918,14 @@ void IRRImporter::InternReadFile( const std::string& pFile,
|
|||
|
||||
// The root node of the scene
|
||||
Node* root = new Node(Node::DUMMY);
|
||||
root->parent = NULL;
|
||||
root->parent = nullptr;
|
||||
root->name = "<IRRSceneRoot>";
|
||||
|
||||
// Current node parent
|
||||
Node* curParent = root;
|
||||
|
||||
// Scenegraph node we're currently working on
|
||||
Node* curNode = NULL;
|
||||
Node* curNode = nullptr;
|
||||
|
||||
// List of output cameras
|
||||
std::vector<aiCamera*> cameras;
|
||||
|
@ -1048,7 +1052,7 @@ void IRRImporter::InternReadFile( const std::string& pFile,
|
|||
continue;
|
||||
}
|
||||
|
||||
Animator* curAnim = NULL;
|
||||
Animator* curAnim = nullptr;
|
||||
|
||||
// Materials can occur for nearly any type of node
|
||||
if (inMaterials && curNode->type != Node::DUMMY) {
|
||||
|
@ -1353,7 +1357,7 @@ void IRRImporter::InternReadFile( const std::string& pFile,
|
|||
}
|
||||
else curParent = curParent->parent;
|
||||
}
|
||||
else curNode = NULL;
|
||||
else curNode = nullptr;
|
||||
}
|
||||
// clear all flags
|
||||
else if (!ASSIMP_stricmp(reader->getNodeName(),"materials")) {
|
||||
|
@ -1479,7 +1483,8 @@ void IRRImporter::InternReadFile( const std::string& pFile,
|
|||
/* Finished ... everything destructs automatically and all
|
||||
* temporary scenes have already been deleted by MergeScenes()
|
||||
*/
|
||||
return;
|
||||
|
||||
delete root;
|
||||
}
|
||||
|
||||
#endif // !! ASSIMP_BUILD_NO_IRR_IMPORTER
|
||||
|
|
Loading…
Reference in New Issue