Skip to content
Permalink
Browse files

Avoid some unnecessary dynamic_casts in QgsProject

...fixes Coverity warning
  • Loading branch information
nyalldawson committed Feb 18, 2015
1 parent b0657b0 commit 8ee8fc54d9aadb5335921997c909b30e0c771aef
Showing with 8 additions and 10 deletions.
  1. +7 −8 src/core/qgsproject.cpp
  2. +1 −2 src/core/qgsprojectproperty.cpp
@@ -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() )
{
@@ -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() )
{
@@ -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 )
{
@@ -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;
}
@@ -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() )
{

0 comments on commit 8ee8fc5

Please sign in to comment.
You can’t perform that action at this time.