mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-07-31 03:10:12 +02:00
Don't create qpixmaps on the stack as this struct is created after QCoreApplication exist sometimes
This commit is contained in:
@@ -39,6 +39,7 @@ AtticaManager* AtticaManager::s_instance = 0;
|
||||
|
||||
|
||||
AtticaManager::AtticaManager( QObject* parent )
|
||||
: QObject( parent )
|
||||
{
|
||||
connect( &m_manager, SIGNAL( providerAdded( Attica::Provider ) ), this, SLOT( providerAdded( Attica::Provider ) ) );
|
||||
|
||||
@@ -71,7 +72,7 @@ AtticaManager::loadPixmapsFromCache()
|
||||
continue;
|
||||
}
|
||||
|
||||
QPixmap icon( cacheDir.absoluteFilePath( file ) );
|
||||
QPixmap* icon = new QPixmap( cacheDir.absoluteFilePath( file ) );
|
||||
m_resolverStates[ info.baseName() ].pixmap = icon;
|
||||
}
|
||||
}
|
||||
@@ -89,8 +90,11 @@ AtticaManager::savePixmapsToCache()
|
||||
|
||||
foreach( const QString& id, m_resolverStates.keys() )
|
||||
{
|
||||
if ( !m_resolverStates[ id ].pixmap )
|
||||
continue;
|
||||
|
||||
const QString filename = cacheDir.absoluteFilePath( QString( "%1.png" ).arg( id ) );
|
||||
if ( !m_resolverStates[ id ].pixmap.save( filename ) )
|
||||
if ( !m_resolverStates[ id ].pixmap->save( filename ) )
|
||||
{
|
||||
tLog() << "Failed to open cache file for writing:" << filename;
|
||||
continue;
|
||||
@@ -102,7 +106,10 @@ AtticaManager::savePixmapsToCache()
|
||||
QPixmap
|
||||
AtticaManager::iconForResolver( const Content& resolver )
|
||||
{
|
||||
return m_resolverStates.value( resolver.id() ).pixmap;
|
||||
if ( !m_resolverStates[ resolver.id() ].pixmap )
|
||||
return QPixmap();
|
||||
|
||||
return *m_resolverStates.value( resolver.id() ).pixmap;
|
||||
}
|
||||
|
||||
|
||||
@@ -170,7 +177,7 @@ AtticaManager::resolversList( BaseJob* j )
|
||||
if ( !m_resolverStates.contains( resolver.id() ) )
|
||||
m_resolverStates.insert( resolver.id(), Resolver() );
|
||||
|
||||
if ( m_resolverStates.value( resolver.id() ).pixmap.isNull() && !resolver.icons().isEmpty() && !resolver.icons().first().url().isEmpty() )
|
||||
if ( !m_resolverStates.value( resolver.id() ).pixmap && !resolver.icons().isEmpty() && !resolver.icons().first().url().isEmpty() )
|
||||
{
|
||||
QNetworkReply* fetch = TomahawkUtils::nam()->get( QNetworkRequest( resolver.icons().first().url() ) );
|
||||
fetch->setProperty( "resolverId", resolver.id() );
|
||||
@@ -198,8 +205,8 @@ AtticaManager::resolverIconFetched()
|
||||
}
|
||||
|
||||
QByteArray data = reply->readAll();
|
||||
QPixmap icon;
|
||||
icon.loadFromData( data );
|
||||
QPixmap* icon = new QPixmap;
|
||||
icon->loadFromData( data );
|
||||
m_resolverStates[ resolverId ].pixmap = icon;
|
||||
}
|
||||
|
||||
|
@@ -49,11 +49,11 @@ public:
|
||||
struct Resolver {
|
||||
QString version, scriptPath;
|
||||
ResolverState state;
|
||||
QPixmap pixmap;
|
||||
QPixmap* pixmap;
|
||||
|
||||
Resolver( const QString& v, const QString& path, ResolverState s )
|
||||
: version( v ), scriptPath( path ), state( s ) {}
|
||||
Resolver() : state( Uninstalled ) {}
|
||||
: version( v ), scriptPath( path ), state( s ), pixmap( 0 ) {}
|
||||
Resolver() : state( Uninstalled ), pixmap( 0 ) {}
|
||||
};
|
||||
|
||||
typedef QHash< QString, AtticaManager::Resolver > StateHash;
|
||||
|
Reference in New Issue
Block a user