Skip to content

Commit 601e430

Browse files
committedApr 12, 2016
Only cache QIcons if a QgsApplication is present
1 parent 30df95a commit 601e430

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed
 

‎src/core/qgsapplication.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -412,8 +412,8 @@ QString QgsApplication::iconPath( const QString& iconFile )
412412

413413
QIcon QgsApplication::getThemeIcon( const QString &theName )
414414
{
415-
QgsApplication* app = static_cast<QgsApplication*>( instance() );
416-
if ( app->mIconCache.contains( theName ) )
415+
QgsApplication* app = qobject_cast<QgsApplication*>( instance() );
416+
if ( app && app->mIconCache.contains( theName ) )
417417
return app->mIconCache.value( theName );
418418

419419
QIcon icon;
@@ -435,7 +435,8 @@ QIcon QgsApplication::getThemeIcon( const QString &theName )
435435
icon = QIcon();
436436
}
437437

438-
app->mIconCache.insert( theName, icon );
438+
if ( app )
439+
app->mIconCache.insert( theName, icon );
439440
return icon;
440441
}
441442

0 commit comments

Comments
 (0)
Please sign in to comment.