Merge lp:~phablet-team/media-hub/fix-1510219 into lp:media-hub/stable

Proposed by Alfonso Sanchez-Beato
Status: Merged
Merged at revision: 163
Proposed branch: lp:~phablet-team/media-hub/fix-1510219
Merge into: lp:media-hub/stable
Prerequisite: lp:~morphis/media-hub/previous-to-same-after-four-secs
Diff against target: 54 lines (+15/-10)
1 file modified
src/core/media/track_list_skeleton.cpp (+15/-10)
To merge this branch: bzr merge lp:~phablet-team/media-hub/fix-1510219
Reviewer Review Type Date Requested Status
Ubuntu Phablet Team Pending
Review via email: mp+275972@code.launchpad.net

Commit message

Make sure our iterator for the current track points to the right place when (un)shuffling. Fixes LP #1510219

Description of the change

Make sure our iterator for the current track points to the right place when (un)shuffling. Fixes LP #1510219

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/core/media/track_list_skeleton.cpp'
2--- src/core/media/track_list_skeleton.cpp 2015-10-23 15:30:47 +0000
3+++ src/core/media/track_list_skeleton.cpp 2015-10-28 10:19:59 +0000
4@@ -42,6 +42,8 @@
5 namespace dbus = core::dbus;
6 namespace media = core::ubuntu::media;
7
8+using namespace std;
9+
10 struct media::TrackListSkeleton::Private
11 {
12 Private(media::TrackListSkeleton* impl, const dbus::Bus::Ptr& bus, const dbus::Object::Ptr& object,
13@@ -399,6 +401,7 @@
14
15 if (do_go_to_next_track)
16 {
17+ cout << "next track id is " << *(current_iterator()) << endl;
18 on_track_changed()(*(current_iterator()));
19 // Don't automatically call stop() and play() in player_implementation.cpp on_go_to_track()
20 // since this breaks video playback when using open_uri() (stop() and play() are unwanted in
21@@ -526,21 +529,23 @@
22
23 void media::TrackListSkeleton::on_shuffle_changed(bool shuffle)
24 {
25+ if (tracks().get().empty())
26+ return;
27+
28+ const media::Track::Id current_id = *(current_iterator());
29+
30+ cout << __PRETTY_FUNCTION__ << " " << shuffle
31+ << " current track: " << current_id << endl;
32+
33 if (shuffle)
34 shuffle_tracks();
35 else
36- {
37- // Save the current Track::Id of what's currently playing to restore after unshuffle
38- const media::Track::Id current_id = *(current_iterator());
39-
40 unshuffle_tracks();
41
42- // Since we use assign() in unshuffle_tracks, which invalidates existing iterators, we need
43- // to make sure that current is pointing to the right place
44- auto it = std::find(tracks().get().begin(), tracks().get().end(), current_id);
45- if (it != tracks().get().end())
46- d->current_track = it;
47- }
48+ // Shuffling and unshuffling invalidates iterators, so we re-create current_track
49+ auto it = find(tracks().get().begin(), tracks().get().end(), current_id);
50+ if (it != tracks().get().end())
51+ d->current_track = it;
52 }
53
54 const core::Property<media::TrackList::Container>& media::TrackListSkeleton::tracks() const

Subscribers

People subscribed via source and target branches

to all changes: