Always clear worker after fetching lyrics completed
This commit is contained in:
@@ -227,9 +227,8 @@ void Lyrics::update()
|
||||
}
|
||||
else
|
||||
w << "\nLyrics were not found.\n";
|
||||
clearWorker();
|
||||
m_refresh_window = true;
|
||||
// Reset worker so it's no longer valid.
|
||||
m_worker = std::future<boost::optional<std::string>>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -273,7 +272,10 @@ void Lyrics::fetch(const MPD::Song &s)
|
||||
w.clear();
|
||||
m_song = s;
|
||||
if (loadLyrics(w, lyricsFilename(m_song)))
|
||||
{
|
||||
clearWorker();
|
||||
m_refresh_window = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_shared_buffer = std::make_shared<Shared<NC::Buffer>>();
|
||||
@@ -295,8 +297,7 @@ void Lyrics::refetchCurrent()
|
||||
}
|
||||
else
|
||||
{
|
||||
// Get rid of current worker so fetch can restart the process.
|
||||
m_worker = std::future<boost::optional<std::string>>();
|
||||
clearWorker();
|
||||
fetch(m_song);
|
||||
}
|
||||
}
|
||||
@@ -417,3 +418,9 @@ boost::optional<std::string> Lyrics::tryTakeConsumerMessage()
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void Lyrics::clearWorker()
|
||||
{
|
||||
m_shared_buffer.reset();
|
||||
m_worker = std::future<boost::optional<std::string>>();
|
||||
}
|
||||
|
||||
@@ -88,6 +88,8 @@ private:
|
||||
boost::optional<std::string> message;
|
||||
};
|
||||
|
||||
void clearWorker();
|
||||
|
||||
bool m_refresh_window;
|
||||
size_t m_scroll_begin;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user