1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-13 09:34:53 +02:00

MPRIS: create a new temp file for each new cover, deleting previous. Prevents caching on client side.

This commit is contained in:
Alejandro Wainzinger
2011-08-16 19:17:58 -07:00
parent 24febc1066
commit 0bddfe3f0d

View File

@@ -566,12 +566,25 @@ MprisPlugin::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData,
return;
}
// Pull image data into byte array
QVariantMap returnedData = output.value< QVariantMap >();
const QByteArray ba = returnedData["imgbytes"].toByteArray();
if ( ba.length() )
{
// Load from byte array to image
QImage image;
image.loadFromData( ba );
// delete the old tempfile and make new one, to avoid caching of filename by mpris clients
delete m_coverTempFile;
m_coverTempFile = new QTemporaryFile( "tomahawk_curtrack_cover.png" );
if( !m_coverTempFile->open() )
{
qDebug() << "WARNING: could not write temporary file for cover art!";
}
m_coverTempFile->close();
// Finally, save the image to the new temp file
if( image.save( QFileInfo( *m_coverTempFile ).absoluteFilePath(), "PNG" ) )
{
qDebug() << Q_FUNC_INFO << "Image saving successful, notifying";