Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Avoid some unnecessary dynamic_casts in QgsProject
...fixes Coverity warning
  • Loading branch information
nyalldawson committed Feb 18, 2015
1 parent b0657b0 commit 8ee8fc5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
15 changes: 7 additions & 8 deletions src/core/qgsproject.cpp
Expand Up @@ -113,7 +113,7 @@ QgsProperty *findKey_( QString const &scope,
{
if ( nextProperty->isKey() )
{
currentProperty = dynamic_cast<QgsPropertyKey*>( nextProperty );
currentProperty = static_cast<QgsPropertyKey*>( nextProperty );
}
else if ( nextProperty->isValue() && 1 == keySequence.count() )
{
Expand Down Expand Up @@ -164,7 +164,8 @@ QgsProperty *addKey_( QString const &scope,

// cursor through property key/value hierarchy
QgsPropertyKey *currentProperty = rootProperty;
QgsProperty *newProperty; // link to next property down hiearchy
QgsProperty *nextProperty; // link to next property down hiearchy
QgsPropertyKey* newPropertyKey;

while ( ! keySequence.isEmpty() )
{
Expand All @@ -190,9 +191,9 @@ QgsProperty *addKey_( QString const &scope,

return currentProperty;
}
else if (( newProperty = currentProperty->find( keySequence.first() ) ) )
else if ( nextProperty = currentProperty->find( keySequence.first() ) )
{
currentProperty = dynamic_cast<QgsPropertyKey*>( newProperty );
currentProperty = dynamic_cast<QgsPropertyKey*>( nextProperty );

if ( currentProperty )
{
Expand All @@ -205,11 +206,9 @@ QgsProperty *addKey_( QString const &scope,
}
else // the next subkey doesn't exist, so add it
{
newProperty = currentProperty->addKey( keySequence.first() );

if ( newProperty )
if ( newPropertyKey = currentProperty->addKey( keySequence.first() ) )
{
currentProperty = dynamic_cast<QgsPropertyKey*>( newProperty );
currentProperty = newPropertyKey;
}
continue;
}
Expand Down
3 changes: 1 addition & 2 deletions src/core/qgsprojectproperty.cpp
Expand Up @@ -305,8 +305,7 @@ void QgsPropertyKey::dump( int tabs ) const
{
if ( i.next().value()->isValue() )
{
QgsPropertyValue * propertyValue =
dynamic_cast<QgsPropertyValue*>( i.value() );
QgsPropertyValue * propertyValue = static_cast<QgsPropertyValue*>( i.value() );

if ( QVariant::StringList == propertyValue->value().type() )
{
Expand Down

0 comments on commit 8ee8fc5

Please sign in to comment.