Minor code clean, standard "new" does not need to be null checked

Because it will bad_alloc exception you instead :D
Silence PVS Studio V668 Warnings
This commit is contained in:
Marek Roszko 2021-02-16 18:24:19 -05:00
parent b959378d58
commit 2370ca1b0e
9 changed files with 100 additions and 155 deletions

View File

@ -234,14 +234,6 @@ SGNODE* S3D::ReadCache( const char* aFileName, void* aPluginMgr,
SGNODE* np = new SCENEGRAPH( nullptr );
if( nullptr == np )
{
wxLogTrace( MASK_3D_SG, "%s:%s:%d * [INFO] failed to instantiate SCENEGRAPH",
__FILE__, __FUNCTION__, __LINE__ );
return nullptr;
}
OPEN_ISTREAM( file, aFileName );
if( file.fail() )

View File

@ -43,8 +43,7 @@ IFSG_APPEARANCE::IFSG_APPEARANCE( bool create )
m_node = new SGAPPEARANCE( nullptr );
if( m_node )
m_node->AssociateWrapper( &m_node );
m_node->AssociateWrapper( &m_node );
}
@ -52,20 +51,17 @@ IFSG_APPEARANCE::IFSG_APPEARANCE( SGNODE* aParent )
{
m_node = new SGAPPEARANCE( nullptr );
if( m_node )
if( !m_node->SetParent( aParent ) )
{
if( !m_node->SetParent( aParent ) )
{
delete m_node;
m_node = nullptr;
delete m_node;
m_node = nullptr;
wxLogTrace( MASK_3D_SG, "%s:%s:%d %s", __FILE__, __FUNCTION__, __LINE__, WrongParent );
wxLogTrace( MASK_3D_SG, "%s:%s:%d %s", __FILE__, __FUNCTION__, __LINE__, WrongParent );
return;
}
m_node->AssociateWrapper( &m_node );
return;
}
m_node->AssociateWrapper( &m_node );
}
@ -82,20 +78,17 @@ IFSG_APPEARANCE::IFSG_APPEARANCE( IFSG_NODE& aParent )
m_node = new SGAPPEARANCE( nullptr );
if( m_node )
if( !m_node->SetParent( pp ) )
{
if( !m_node->SetParent( pp ) )
{
delete m_node;
m_node = nullptr;
delete m_node;
m_node = nullptr;
wxLogTrace( MASK_3D_SG, "%s:%s:%d %s", __FILE__, __FUNCTION__, __LINE__, WrongParent );
wxLogTrace( MASK_3D_SG, "%s:%s:%d %s", __FILE__, __FUNCTION__, __LINE__, WrongParent );
return;
}
m_node->AssociateWrapper( &m_node );
return;
}
m_node->AssociateWrapper( &m_node );
}

View File

@ -43,8 +43,7 @@ IFSG_COLORS::IFSG_COLORS( bool create )
m_node = new SGCOLORS( nullptr );
if( m_node )
m_node->AssociateWrapper( &m_node );
m_node->AssociateWrapper( &m_node );
}
@ -52,20 +51,17 @@ IFSG_COLORS::IFSG_COLORS( SGNODE* aParent )
{
m_node = new SGCOLORS( nullptr );
if( m_node )
if( !m_node->SetParent( aParent ) )
{
if( !m_node->SetParent( aParent ) )
{
delete m_node;
m_node = nullptr;
delete m_node;
m_node = nullptr;
wxLogTrace( MASK_3D_SG, "%s:%s:%d", __FILE__, __FUNCTION__, __LINE__ );
wxLogTrace( MASK_3D_SG, "%s:%s:%d", __FILE__, __FUNCTION__, __LINE__ );
return;
}
m_node->AssociateWrapper( &m_node );
return;
}
m_node->AssociateWrapper( &m_node );
}
@ -83,21 +79,18 @@ IFSG_COLORS::IFSG_COLORS( IFSG_NODE& aParent )
m_node = new SGCOLORS( nullptr );
if( m_node )
if( !m_node->SetParent( pp ) )
{
if( !m_node->SetParent( pp ) )
{
delete m_node;
m_node = nullptr;
delete m_node;
m_node = nullptr;
wxLogTrace( MASK_3D_SG, "%s:%s:%d %s", __FILE__, __FUNCTION__, __LINE__,
WrongParent );
wxLogTrace( MASK_3D_SG, "%s:%s:%d %s", __FILE__, __FUNCTION__, __LINE__,
WrongParent );
return;
}
m_node->AssociateWrapper( &m_node );
return;
}
m_node->AssociateWrapper( &m_node );
}

View File

@ -44,8 +44,7 @@ IFSG_COORDINDEX::IFSG_COORDINDEX( bool create )
m_node = new SGCOORDINDEX( nullptr );
if( m_node )
m_node->AssociateWrapper( &m_node );
m_node->AssociateWrapper( &m_node );
}

View File

@ -43,8 +43,7 @@ IFSG_COORDS::IFSG_COORDS( bool create )
m_node = new SGCOORDS( nullptr );
if( m_node )
m_node->AssociateWrapper( &m_node );
m_node->AssociateWrapper( &m_node );
}
@ -52,20 +51,17 @@ IFSG_COORDS::IFSG_COORDS( SGNODE* aParent )
{
m_node = new SGCOORDS( nullptr );
if( m_node )
if( !m_node->SetParent( aParent ) )
{
if( !m_node->SetParent( aParent ) )
{
delete m_node;
m_node = nullptr;
delete m_node;
m_node = nullptr;
wxLogTrace( MASK_3D_SG, "%s:%s:%d %s", __FILE__, __FUNCTION__, __LINE__, WrongParent );
wxLogTrace( MASK_3D_SG, "%s:%s:%d %s", __FILE__, __FUNCTION__, __LINE__, WrongParent );
return;
}
m_node->AssociateWrapper( &m_node );
return;
}
m_node->AssociateWrapper( &m_node );
}
@ -82,20 +78,17 @@ IFSG_COORDS::IFSG_COORDS( IFSG_NODE& aParent )
m_node = new SGCOORDS( nullptr );
if( m_node )
if( !m_node->SetParent( pp ) )
{
if( !m_node->SetParent( pp ) )
{
delete m_node;
m_node = nullptr;
delete m_node;
m_node = nullptr;
wxLogTrace( MASK_3D_SG, "%s:%s:%d %s", __FILE__, __FUNCTION__, __LINE__, WrongParent );
wxLogTrace( MASK_3D_SG, "%s:%s:%d %s", __FILE__, __FUNCTION__, __LINE__, WrongParent );
return;
}
m_node->AssociateWrapper( &m_node );
return;
}
m_node->AssociateWrapper( &m_node );
}

View File

@ -44,8 +44,7 @@ IFSG_FACESET::IFSG_FACESET( bool create )
m_node = new SGFACESET( nullptr );
if( m_node )
m_node->AssociateWrapper( &m_node );
m_node->AssociateWrapper( &m_node );
}
@ -53,20 +52,17 @@ IFSG_FACESET::IFSG_FACESET( SGNODE* aParent )
{
m_node = new SGFACESET( nullptr );
if( m_node )
if( !m_node->SetParent( aParent ) )
{
if( !m_node->SetParent( aParent ) )
{
delete m_node;
m_node = nullptr;
delete m_node;
m_node = nullptr;
wxLogTrace( MASK_3D_SG, "%s:%s:%d %s", __FILE__, __FUNCTION__, __LINE__, WrongParent );
wxLogTrace( MASK_3D_SG, "%s:%s:%d %s", __FILE__, __FUNCTION__, __LINE__, WrongParent );
return;
}
m_node->AssociateWrapper( &m_node );
return;
}
m_node->AssociateWrapper( &m_node );
}
@ -83,20 +79,17 @@ IFSG_FACESET::IFSG_FACESET( IFSG_NODE& aParent )
m_node = new SGFACESET( nullptr );
if( m_node )
if( !m_node->SetParent( pp ) )
{
if( !m_node->SetParent( pp ) )
{
delete m_node;
m_node = nullptr;
delete m_node;
m_node = nullptr;
wxLogTrace( MASK_3D_SG, "%s:%s:%d %s", __FILE__, __FUNCTION__, __LINE__, WrongParent );
wxLogTrace( MASK_3D_SG, "%s:%s:%d %s", __FILE__, __FUNCTION__, __LINE__, WrongParent );
return;
}
m_node->AssociateWrapper( &m_node );
return;
}
m_node->AssociateWrapper( &m_node );
}

View File

@ -44,8 +44,7 @@ IFSG_NORMALS::IFSG_NORMALS( bool create )
m_node = new SGNORMALS( nullptr );
if( m_node )
m_node->AssociateWrapper( &m_node );
m_node->AssociateWrapper( &m_node );
}
@ -53,20 +52,17 @@ IFSG_NORMALS::IFSG_NORMALS( SGNODE* aParent )
{
m_node = new SGNORMALS( nullptr );
if( m_node )
if( !m_node->SetParent( aParent ) )
{
if( !m_node->SetParent( aParent ) )
{
delete m_node;
m_node = nullptr;
delete m_node;
m_node = nullptr;
wxLogTrace( MASK_3D_SG, "%s:%s:%d %s", __FILE__, __FUNCTION__, __LINE__, WrongParent );
wxLogTrace( MASK_3D_SG, "%s:%s:%d %s", __FILE__, __FUNCTION__, __LINE__, WrongParent );
return;
}
m_node->AssociateWrapper( &m_node );
return;
}
m_node->AssociateWrapper( &m_node );
}
@ -83,20 +79,17 @@ IFSG_NORMALS::IFSG_NORMALS( IFSG_NODE& aParent )
m_node = new SGNORMALS( nullptr );
if( m_node )
if( !m_node->SetParent( pp ) )
{
if( !m_node->SetParent( pp ) )
{
delete m_node;
m_node = nullptr;
delete m_node;
m_node = nullptr;
wxLogTrace( MASK_3D_SG, "%s:%s:%d %s", __FILE__, __FUNCTION__, __LINE__, WrongParent );
wxLogTrace( MASK_3D_SG, "%s:%s:%d %s", __FILE__, __FUNCTION__, __LINE__, WrongParent );
return;
}
m_node->AssociateWrapper( &m_node );
return;
}
m_node->AssociateWrapper( &m_node );
}

View File

@ -44,8 +44,7 @@ IFSG_SHAPE::IFSG_SHAPE( bool create )
m_node = new SGSHAPE( nullptr );
if( m_node )
m_node->AssociateWrapper( &m_node );
m_node->AssociateWrapper( &m_node );
}
@ -53,20 +52,17 @@ IFSG_SHAPE::IFSG_SHAPE( SGNODE* aParent )
{
m_node = new SGSHAPE( nullptr );
if( m_node )
if( !m_node->SetParent( aParent ) )
{
if( !m_node->SetParent( aParent ) )
{
delete m_node;
m_node = nullptr;
delete m_node;
m_node = nullptr;
wxLogTrace( MASK_3D_SG, "%s:%s:%d %s", __FILE__, __FUNCTION__, __LINE__, WrongParent );
wxLogTrace( MASK_3D_SG, "%s:%s:%d %s", __FILE__, __FUNCTION__, __LINE__, WrongParent );
return;
}
m_node->AssociateWrapper( &m_node );
return;
}
m_node->AssociateWrapper( &m_node );
}
@ -83,20 +79,17 @@ IFSG_SHAPE::IFSG_SHAPE( IFSG_NODE& aParent )
m_node = new SGSHAPE( nullptr );
if( m_node )
if( !m_node->SetParent( pp ) )
{
if( !m_node->SetParent( pp ) )
{
delete m_node;
m_node = nullptr;
delete m_node;
m_node = nullptr;
wxLogTrace( MASK_3D_SG, "%s:%s:%d %s", __FILE__, __FUNCTION__, __LINE__, WrongParent );
wxLogTrace( MASK_3D_SG, "%s:%s:%d %s", __FILE__, __FUNCTION__, __LINE__, WrongParent );
return;
}
m_node->AssociateWrapper( &m_node );
return;
}
m_node->AssociateWrapper( &m_node );
}

View File

@ -43,8 +43,7 @@ IFSG_TRANSFORM::IFSG_TRANSFORM( bool create )
m_node = new SCENEGRAPH( nullptr );
if( m_node )
m_node->AssociateWrapper( &m_node );
m_node->AssociateWrapper( &m_node );
}
@ -52,20 +51,17 @@ IFSG_TRANSFORM::IFSG_TRANSFORM( SGNODE* aParent )
{
m_node = new SCENEGRAPH( nullptr );
if( m_node )
if( !m_node->SetParent( aParent ) )
{
if( !m_node->SetParent( aParent ) )
{
delete m_node;
m_node = nullptr;
delete m_node;
m_node = nullptr;
wxLogTrace( MASK_3D_SG, "%s:%s:%d %s", __FILE__, __FUNCTION__, __LINE__, WrongParent );
wxLogTrace( MASK_3D_SG, "%s:%s:%d %s", __FILE__, __FUNCTION__, __LINE__, WrongParent );
return;
}
m_node->AssociateWrapper( &m_node );
return;
}
m_node->AssociateWrapper( &m_node );
}