Commit 4233e5fb authored by Kevin Whitaker's avatar Kevin Whitaker

Sanity checks. Make sure track isn't in vote batch and remove it from request queue if there.

parent e5b86cc4
......@@ -64,13 +64,22 @@ void RequestInterface::trackRequestClicked(AudioTrack track)
void RequestInterface::trackRemoveClicked(RequestItem* item, AudioTrack track)
{
if(GroovePlayerMgr::getInstance()->currentTrack.trackFingerprint != track.trackFingerprint)
bool inVoting = false;
for(AudioTrack vtrack: GroovePlayerMgr::getInstance()->currentVoteBatch)
{
if(vtrack.trackFingerprint == track.trackFingerprint) inVoting = true;
}
if(GroovePlayerMgr::getInstance()->currentTrack.trackFingerprint != track.trackFingerprint && !inVoting)
{
Wt::Dbo::Session sqlSession;
sqlSession.setConnectionPool(*GroovePlayerMgr::getInstance()->connectionPool);
sqlSession.mapClass<User>("user");
sqlSession.mapClass<AudioTrack>("tracks");
sqlSession.mapClass<UserAction>("actions");
for(std::list<std::pair<AudioTrack,User>>::const_iterator request = GroovePlayerMgr::getInstance()->requestQueue.begin(); request != GroovePlayerMgr::getInstance()->requestQueue.end(); request++)
{
if((*request).first.trackFingerprint == track.trackFingerprint) GroovePlayerMgr::getInstance()->requestQueue.erase(request);
}
GroovePlayerMgr::getInstance()->removeTrack(&sqlSession,track);
delete item;
}
......
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