mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-13 17:43:59 +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 )
|
AtticaManager::AtticaManager( QObject* parent )
|
||||||
|
: QObject( parent )
|
||||||
{
|
{
|
||||||
connect( &m_manager, SIGNAL( providerAdded( Attica::Provider ) ), this, SLOT( providerAdded( Attica::Provider ) ) );
|
connect( &m_manager, SIGNAL( providerAdded( Attica::Provider ) ), this, SLOT( providerAdded( Attica::Provider ) ) );
|
||||||
|
|
||||||
@@ -71,7 +72,7 @@ AtticaManager::loadPixmapsFromCache()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPixmap icon( cacheDir.absoluteFilePath( file ) );
|
QPixmap* icon = new QPixmap( cacheDir.absoluteFilePath( file ) );
|
||||||
m_resolverStates[ info.baseName() ].pixmap = icon;
|
m_resolverStates[ info.baseName() ].pixmap = icon;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -89,8 +90,11 @@ AtticaManager::savePixmapsToCache()
|
|||||||
|
|
||||||
foreach( const QString& id, m_resolverStates.keys() )
|
foreach( const QString& id, m_resolverStates.keys() )
|
||||||
{
|
{
|
||||||
|
if ( !m_resolverStates[ id ].pixmap )
|
||||||
|
continue;
|
||||||
|
|
||||||
const QString filename = cacheDir.absoluteFilePath( QString( "%1.png" ).arg( id ) );
|
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;
|
tLog() << "Failed to open cache file for writing:" << filename;
|
||||||
continue;
|
continue;
|
||||||
@@ -102,7 +106,10 @@ AtticaManager::savePixmapsToCache()
|
|||||||
QPixmap
|
QPixmap
|
||||||
AtticaManager::iconForResolver( const Content& resolver )
|
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() ) )
|
if ( !m_resolverStates.contains( resolver.id() ) )
|
||||||
m_resolverStates.insert( resolver.id(), Resolver() );
|
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() ) );
|
QNetworkReply* fetch = TomahawkUtils::nam()->get( QNetworkRequest( resolver.icons().first().url() ) );
|
||||||
fetch->setProperty( "resolverId", resolver.id() );
|
fetch->setProperty( "resolverId", resolver.id() );
|
||||||
@@ -198,8 +205,8 @@ AtticaManager::resolverIconFetched()
|
|||||||
}
|
}
|
||||||
|
|
||||||
QByteArray data = reply->readAll();
|
QByteArray data = reply->readAll();
|
||||||
QPixmap icon;
|
QPixmap* icon = new QPixmap;
|
||||||
icon.loadFromData( data );
|
icon->loadFromData( data );
|
||||||
m_resolverStates[ resolverId ].pixmap = icon;
|
m_resolverStates[ resolverId ].pixmap = icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -49,11 +49,11 @@ public:
|
|||||||
struct Resolver {
|
struct Resolver {
|
||||||
QString version, scriptPath;
|
QString version, scriptPath;
|
||||||
ResolverState state;
|
ResolverState state;
|
||||||
QPixmap pixmap;
|
QPixmap* pixmap;
|
||||||
|
|
||||||
Resolver( const QString& v, const QString& path, ResolverState s )
|
Resolver( const QString& v, const QString& path, ResolverState s )
|
||||||
: version( v ), scriptPath( path ), state( s ) {}
|
: version( v ), scriptPath( path ), state( s ), pixmap( 0 ) {}
|
||||||
Resolver() : state( Uninstalled ) {}
|
Resolver() : state( Uninstalled ), pixmap( 0 ) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef QHash< QString, AtticaManager::Resolver > StateHash;
|
typedef QHash< QString, AtticaManager::Resolver > StateHash;
|
||||||
|
Reference in New Issue
Block a user