Skip to content

Commit 8ee8fc5

Browse files
committed
Avoid some unnecessary dynamic_casts in QgsProject
...fixes Coverity warning
1 parent b0657b0 commit 8ee8fc5

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

src/core/qgsproject.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ QgsProperty *findKey_( QString const &scope,
113113
{
114114
if ( nextProperty->isKey() )
115115
{
116-
currentProperty = dynamic_cast<QgsPropertyKey*>( nextProperty );
116+
currentProperty = static_cast<QgsPropertyKey*>( nextProperty );
117117
}
118118
else if ( nextProperty->isValue() && 1 == keySequence.count() )
119119
{
@@ -164,7 +164,8 @@ QgsProperty *addKey_( QString const &scope,
164164

165165
// cursor through property key/value hierarchy
166166
QgsPropertyKey *currentProperty = rootProperty;
167-
QgsProperty *newProperty; // link to next property down hiearchy
167+
QgsProperty *nextProperty; // link to next property down hiearchy
168+
QgsPropertyKey* newPropertyKey;
168169

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

191192
return currentProperty;
192193
}
193-
else if (( newProperty = currentProperty->find( keySequence.first() ) ) )
194+
else if ( nextProperty = currentProperty->find( keySequence.first() ) )
194195
{
195-
currentProperty = dynamic_cast<QgsPropertyKey*>( newProperty );
196+
currentProperty = dynamic_cast<QgsPropertyKey*>( nextProperty );
196197

197198
if ( currentProperty )
198199
{
@@ -205,11 +206,9 @@ QgsProperty *addKey_( QString const &scope,
205206
}
206207
else // the next subkey doesn't exist, so add it
207208
{
208-
newProperty = currentProperty->addKey( keySequence.first() );
209-
210-
if ( newProperty )
209+
if ( newPropertyKey = currentProperty->addKey( keySequence.first() ) )
211210
{
212-
currentProperty = dynamic_cast<QgsPropertyKey*>( newProperty );
211+
currentProperty = newPropertyKey;
213212
}
214213
continue;
215214
}

src/core/qgsprojectproperty.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,7 @@ void QgsPropertyKey::dump( int tabs ) const
305305
{
306306
if ( i.next().value()->isValue() )
307307
{
308-
QgsPropertyValue * propertyValue =
309-
dynamic_cast<QgsPropertyValue*>( i.value() );
308+
QgsPropertyValue * propertyValue = static_cast<QgsPropertyValue*>( i.value() );
310309

311310
if ( QVariant::StringList == propertyValue->value().type() )
312311
{

0 commit comments

Comments
 (0)