lastfm: use sink argument and fix possible usage of m_service after delete
This commit is contained in:
1
NEWS
1
NEWS
@@ -5,6 +5,7 @@ ncmpcpp-0.6.5 (????-??-??)
|
|||||||
* Searching in text fields now respects regular expression configuration.
|
* Searching in text fields now respects regular expression configuration.
|
||||||
* When numbering tracks in tag editor all the other track tags are discarded.
|
* When numbering tracks in tag editor all the other track tags are discarded.
|
||||||
* Xiph tag DESCRIPTION is now rewritten as COMMENT when updating tags.
|
* Xiph tag DESCRIPTION is now rewritten as COMMENT when updating tags.
|
||||||
|
* Possible access of already freed memory when downloading artist info is fixed.
|
||||||
|
|
||||||
ncmpcpp-0.6.4 (2015-05-02)
|
ncmpcpp-0.6.4 (2015-05-02)
|
||||||
|
|
||||||
|
|||||||
@@ -2314,7 +2314,7 @@ void ShowArtistInfo::run()
|
|||||||
|
|
||||||
if (!artist.empty())
|
if (!artist.empty())
|
||||||
{
|
{
|
||||||
myLastfm->queueJob(LastFm::ArtistInfo(artist, Config.lastfm_preferred_language));
|
myLastfm->queueJob(new LastFm::ArtistInfo(artist, Config.lastfm_preferred_language));
|
||||||
myLastfm->switchTo();
|
myLastfm->switchTo();
|
||||||
}
|
}
|
||||||
# endif // HAVE_CURL_CURL_H
|
# endif // HAVE_CURL_CURL_H
|
||||||
|
|||||||
20
src/lastfm.h
20
src/lastfm.h
@@ -51,27 +51,25 @@ struct Lastfm: Screen<NC::Scrollpad>, Tabbable
|
|||||||
virtual bool isMergable() OVERRIDE { return true; }
|
virtual bool isMergable() OVERRIDE { return true; }
|
||||||
|
|
||||||
template <typename ServiceT>
|
template <typename ServiceT>
|
||||||
void queueJob(ServiceT &&service)
|
void queueJob(ServiceT *service)
|
||||||
{
|
{
|
||||||
typedef typename std::remove_reference<ServiceT>::type ServiceNoRef;
|
auto old_service = dynamic_cast<ServiceT *>(m_service.get());
|
||||||
|
|
||||||
auto old_service = dynamic_cast<ServiceNoRef *>(m_service.get());
|
|
||||||
// if the same service and arguments were used, leave old info
|
// if the same service and arguments were used, leave old info
|
||||||
if (old_service != nullptr && *old_service == service)
|
if (old_service != nullptr && *old_service == *service)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_service = std::make_shared<ServiceNoRef>(std::forward<ServiceT>(service));
|
m_service = std::shared_ptr<ServiceT>(service);
|
||||||
m_worker = boost::async(boost::launch::async, boost::bind(&LastFm::Service::fetch, m_service.get()));
|
m_worker = boost::async(boost::launch::async, std::bind(&LastFm::Service::fetch, m_service));
|
||||||
|
|
||||||
w.clear();
|
w.clear();
|
||||||
w << "Fetching information...";
|
w << "Fetching information...";
|
||||||
w.flush();
|
w.flush();
|
||||||
m_title = ToWString(m_service->name());
|
m_title = ToWString(m_service->name());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool isLockable() OVERRIDE { return false; }
|
virtual bool isLockable() OVERRIDE { return false; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void getResult();
|
void getResult();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user