1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-01-17 06:18:17 +01:00

Protect m_formats access with mutex in Result

This commit is contained in:
Dominik Schmidt 2016-02-10 00:21:31 +01:00
parent e7d83835d2
commit cb3ccd5a76
2 changed files with 13 additions and 2 deletions

View File

@ -529,12 +529,23 @@ Result::track() const
}
QList< DownloadFormat >
Result::downloadFormats() const
{
QMutexLocker lock( &s_mutex );
return m_formats;
}
void
Result::setDownloadFormats( const QList<DownloadFormat>& formats )
{
if ( formats.isEmpty() )
return;
QMutexLocker lock( &s_mutex );
m_formats.clear();
foreach ( const DownloadFormat& format, formats )
{
@ -562,7 +573,7 @@ Result::setDownloadFormats( const QList<DownloadFormat>& formats )
void
Result::onSettingsChanged()
{
if ( TomahawkSettings::instance()->downloadsPreferredFormat().toLower() != m_formats.first().extension.toLower() )
if ( TomahawkSettings::instance()->downloadsPreferredFormat().toLower() != downloadFormats().first().extension.toLower() )
{
setDownloadFormats( downloadFormats() );
emit updated();

View File

@ -131,7 +131,7 @@ public:
track_ptr track() const;
QList<DownloadFormat> downloadFormats() const { return m_formats; }
QList< DownloadFormat > downloadFormats() const;
void setDownloadFormats( const QList<DownloadFormat>& formats );
downloadjob_ptr downloadJob() const { return m_downloadJob; }