Commit c9cc9814 authored by Michael Pyne's avatar Michael Pyne
Browse files

Don't leave stray temporary cover files laying around. It introduces race...

Don't leave stray temporary cover files laying around.  It introduces race conditions I suppose but it's the
80/20 solution (sometimes it really is true that worse is better...)

svn path=/trunk/KDE/kdemultimedia/juk/; revision=923035
parent 1d76434d
......@@ -38,6 +38,13 @@ DBusCollectionProxy::DBusCollectionProxy (QObject *parent, PlaylistCollection *c
QDBusConnection::sessionBus().registerObject("/Collection",this);
}
DBusCollectionProxy::~DBusCollectionProxy()
{
// Clean's the way to be
if(!m_lastCover.isEmpty())
QFile::remove(m_lastCover);
}
void DBusCollectionProxy::openFile(const QString &file)
{
m_collection->open(QStringList(file));
......@@ -136,6 +143,12 @@ QString DBusCollectionProxy::trackCover(const QString &track)
return QString();
}
// Save last file name cover, remove it if it's there so that we don't fill
// the temp directory with pixmaps.
if(!m_lastCover.isEmpty())
QFile::remove(m_lastCover);
m_lastCover = tempFile.fileName();
cover.save(&tempFile, "PNG");
return tempFile.fileName();
}
......
......@@ -19,7 +19,6 @@
#include <QtCore/QStringList> // Required for Q_CLASSINFO ?
class PlaylistCollection;
class QString;
class DBusCollectionProxy : public QObject
{
......@@ -28,6 +27,7 @@ class DBusCollectionProxy : public QObject
public:
DBusCollectionProxy (QObject *parent, PlaylistCollection *collection);
~DBusCollectionProxy();
public slots: // Expose to D-Bus
void openFile(const QString &file);
......@@ -56,6 +56,7 @@ public slots: // Expose to D-Bus
private:
PlaylistCollection *m_collection;
QString m_lastCover;
};
#endif /* DBUS_COLLECTION_PROXY_H */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment