mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-13 17:43:59 +02:00
MPRIS: create a new temp file for each new cover, deleting previous. Prevents caching on client side.
This commit is contained in:
@@ -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";
|
||||
|
Reference in New Issue
Block a user