diff --git a/src/libtomahawk/audio/AudioEngine.cpp b/src/libtomahawk/audio/AudioEngine.cpp index bb01d372b..c29fb7c0d 100644 --- a/src/libtomahawk/audio/AudioEngine.cpp +++ b/src/libtomahawk/audio/AudioEngine.cpp @@ -45,7 +45,6 @@ #include #include #include -#include using namespace Tomahawk; @@ -72,6 +71,7 @@ AudioEngine::AudioEngine() , m_expectStop( false ) , m_waitingOnNewTrack( false ) , m_state( Stopped ) + , m_coverTempFile( 0 ) { s_instance = this; tDebug() << "Init AudioEngine"; @@ -394,25 +394,23 @@ AudioEngine::onNowPlayingInfoReady( const Tomahawk::InfoSystem::InfoType type ) { playInfo["cover"] = cover; - //FIXME! - QTemporaryFile* coverTempFile = new QTemporaryFile( QDir::toNativeSeparators( QDir::tempPath() + "/" + m_currentTrack->track()->artist() + "_" + m_currentTrack->track()->album() + "_tomahawk_cover.png" ) ); - if ( !coverTempFile->open() ) + delete m_coverTempFile; + m_coverTempFile = new QTemporaryFile( QDir::toNativeSeparators( QDir::tempPath() + "/" + m_currentTrack->track()->artist() + "_" + m_currentTrack->track()->album() + "_tomahawk_cover.png" ) ); + if ( !m_coverTempFile->open() ) { tDebug() << Q_FUNC_INFO << "WARNING: could not write temporary file for cover art!"; } else { // Finally, save the image to the new temp file - coverTempFile->setAutoRemove( false ); - if ( cover.save( coverTempFile, "PNG" ) ) + if ( cover.save( m_coverTempFile, "PNG" ) ) { - tDebug() << Q_FUNC_INFO << "Saving cover image to:" << QFileInfo( *coverTempFile ).absoluteFilePath(); - playInfo["coveruri"] = QFileInfo( *coverTempFile ).absoluteFilePath(); + tDebug() << Q_FUNC_INFO << "Saving cover image to:" << QFileInfo( *m_coverTempFile ).absoluteFilePath(); + playInfo["coveruri"] = QFileInfo( *m_coverTempFile ).absoluteFilePath(); } else tDebug() << Q_FUNC_INFO << "Failed to save cover image!"; } - delete coverTempFile; } else tDebug() << Q_FUNC_INFO << "Cover from query is null!"; diff --git a/src/libtomahawk/audio/AudioEngine.h b/src/libtomahawk/audio/AudioEngine.h index 99d22c0a6..444fef465 100644 --- a/src/libtomahawk/audio/AudioEngine.h +++ b/src/libtomahawk/audio/AudioEngine.h @@ -35,6 +35,7 @@ #include #include #include +#include class DLLEXPORT AudioEngine : public QObject @@ -178,6 +179,8 @@ private: uint_fast8_t m_underrunCount; bool m_underrunNotified; + QTemporaryFile* m_coverTempFile; + static AudioEngine* s_instance; };