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