From c405f1d7f642741695fe05c7bb836fb585a312e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20=C3=96nnerby?= Date: Tue, 29 Apr 2008 20:54:59 +0000 Subject: [PATCH] Fixed the PlaybackQueue::CurrentTrackChanged signal to be called even with empty track. --- src/core/PlaybackQueue.cpp | 44 +++++++++++++++++--------------- src/cube/TransportController.cpp | 11 +++++--- 2 files changed, 30 insertions(+), 25 deletions(-) diff --git a/src/core/PlaybackQueue.cpp b/src/core/PlaybackQueue.cpp index c01440b38..1f66be4b3 100644 --- a/src/core/PlaybackQueue.cpp +++ b/src/core/PlaybackQueue.cpp @@ -112,10 +112,9 @@ void PlaybackQueue::Play(){ ////////////////////////////////////////// void PlaybackQueue::Next(){ musik::core::TrackPtr track( this->nowPlaying->NextTrack() ); - if(track){ - this->SetCurrentTrack(track->Copy()); - this->Play(); - } + + this->SetCurrentTrack(track); + this->Play(); } ////////////////////////////////////////// @@ -124,10 +123,10 @@ void PlaybackQueue::Next(){ ////////////////////////////////////////// void PlaybackQueue::Previous(){ musik::core::TrackPtr track( this->nowPlaying->PreviousTrack() ); - if(track){ - this->SetCurrentTrack(track->Copy()); - this->Play(); - } + + this->SetCurrentTrack(track); + this->Play(); + } ////////////////////////////////////////// @@ -155,8 +154,7 @@ TrackPtr PlaybackQueue::CurrentTrack(){ if(!this->currentTrack){ // If the current track is empty, get a track from the nowPlaying tracklist - this->SetCurrentTrack( this->nowPlaying->CurrentTrack()->Copy() ); - + this->SetCurrentTrack( this->nowPlaying->CurrentTrack() ); } return this->currentTrack; } @@ -169,20 +167,24 @@ TrackPtr PlaybackQueue::CurrentTrack(){ ///for all the tracks metadata ////////////////////////////////////////// void PlaybackQueue::SetCurrentTrack(TrackPtr track){ - if(this->currentTrack!=track){ - this->currentTrack = track; - // Get all metadata to the track - if(this->currentTrack){ - this->metadataQuery.Clear(); - this->metadataQuery.RequestAllMetakeys(); - this->metadataQuery.RequestTrack(this->currentTrack); - this->nowPlaying->Library()->AddQuery(this->metadataQuery,musik::core::Query::Wait|musik::core::Query::AutoCallback|musik::core::Query::UnCanceable|musik::core::Query::Prioritize); - } + if(track){ + this->currentTrack = track->Copy(); + }else{ + this->currentTrack = musik::core::TrackPtr(); + } - // Call the signal if track updates - this->CurrentTrackChanged(track); + // Get all metadata to the track + if(this->currentTrack){ + this->metadataQuery.Clear(); + this->metadataQuery.RequestAllMetakeys(); + this->metadataQuery.RequestTrack(this->currentTrack); + this->nowPlaying->Library()->AddQuery(this->metadataQuery,musik::core::Query::Wait|musik::core::Query::AutoCallback|musik::core::Query::UnCanceable|musik::core::Query::Prioritize); } + + // Call the signal if track updates + this->CurrentTrackChanged(this->currentTrack); + } ////////////////////////////////////////// diff --git a/src/cube/TransportController.cpp b/src/cube/TransportController.cpp index 9f87b0bfb..93e6b8bac 100644 --- a/src/cube/TransportController.cpp +++ b/src/cube/TransportController.cpp @@ -115,12 +115,15 @@ void TransportController::OnTrackChange(musik::core::TrackPtr track){ win32cpp::uistring title(_T("-")); win32cpp::uistring artist(_T("-")); - if(track->GetValue("title")) - title.assign( track->GetValue("title") ); + if(track){ - if(track->GetValue("visual_artist")) - artist.assign( track->GetValue("visual_artist") ); + if(track->GetValue("title")) + title.assign( track->GetValue("title") ); + if(track->GetValue("visual_artist")) + artist.assign( track->GetValue("visual_artist") ); + + } this->transportView.titleLabel->SetCaption(title); this->transportView.artistLabel->SetCaption(artist);