Merge lp:~ahayzen/music-app/fix-potential-trackclicked-issues into lp:music-app/trusty

Proposed by Andrew Hayzen
Status: Merged
Approved by: Victor Thompson
Approved revision: 501
Merged at revision: 507
Proposed branch: lp:~ahayzen/music-app/fix-potential-trackclicked-issues
Merge into: lp:music-app/trusty
Diff against target: 94 lines (+21/-17)
1 file modified
music-app.qml (+21/-17)
To merge this branch: bzr merge lp:~ahayzen/music-app/fix-potential-trackclicked-issues
Reviewer Review Type Date Requested Status
Victor Thompson Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+224035@code.launchpad.net

Commit message

* Fix potential trackclicked issues

Description of the change

* Fix potential trackclicked issues

Resolves and tidies a few things within trackClicked. Mainly resolves errors such as below when using the album:// uri.

qml: URI=album:///Queen/A%20Kind%20of%20Magic
file:///opt/click.ubuntu.com/com.ubuntu.music/1.3.501/music-app.qml:450: TypeError: Cannot read property 'filename' of undefined

To post a comment you must log in.
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Victor Thompson (vthompson) wrote :

I can't reproduce the issue at hand, but this change doesn't introduce any regressions and the changes are straight forward

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'music-app.qml'
2--- music-app.qml 2014-06-15 13:43:37 +0000
3+++ music-app.qml 2014-06-21 23:28:24 +0000
4@@ -218,7 +218,8 @@
5
6 // Play album it tracks exist
7 if (songsAlbumArtistModel.rowCount > 0) {
8- trackClicked(songsAlbumArtistModel, 0, true);
9+ // trackClicked(model, index, play, clear=true) will clear the model
10+ trackClicked(songsAlbumArtistModel, 0, true, true);
11 }
12 else {
13 console.debug("Unknown artist-album " + uri + ", skipping")
14@@ -244,12 +245,17 @@
15 return;
16 }
17
18+ if (play) {
19+ // clear play queue
20+ trackQueue.model.clear()
21+ }
22+
23 // enqueue
24- trackQueue.append(track);
25+ trackQueue.append(makeDict(track));
26
27 // play first URI
28 if (play) {
29- trackQueueClick(0);
30+ trackQueueClick(trackQueue.model.count - 1);
31 }
32 }
33
34@@ -270,8 +276,6 @@
35 }
36
37 onOpened: {
38- // clear play queue
39- trackQueue.model.clear()
40 for (var i=0; i < uris.length; i++) {
41 console.debug("URI=" + uris[i])
42
43@@ -405,12 +409,7 @@
44 }
45
46 for (var i=0; i < model.rowCount; i++) {
47- var item = model.get(i, model.RoleModelData);
48- if (item.art !== undefined && (item.art === "" || item.art === null)) {
49- item.art = "image://albumart/artist=" + item.author + "&album=" + item.album
50- }
51-
52- trackQueue.model.append(makeDict(item));
53+ trackQueue.model.append(makeDict(model.get(i, model.RoleModelData)));
54 }
55 }
56
57@@ -430,13 +429,14 @@
58 function makeDict(model) {
59 return {
60 album: model.album,
61+ art: "image://albumart/artist=" + model.author + "&album=" + model.album,
62 author: model.author,
63 filename: model.filename,
64 title: model.title
65 };
66 }
67
68- function trackClicked(model, index, play) {
69+ function trackClicked(model, index, play, clear) {
70 // TODO: remove once playlists uses U1DB
71 if (model.hasOwnProperty("linkLibraryListModel")) {
72 model = model.linkLibraryListModel;
73@@ -445,12 +445,16 @@
74 var file = Qt.resolvedUrl(model.get(index, model.RoleModelData).filename);
75
76 play = play === undefined ? true : play // default play to true
77+ clear = clear === undefined ? false : clear // force clear and will ignore player.toggle()
78
79- // If same track and on now playing page then toggle
80- if (musicToolbar.currentPage === nowPlaying &&
81- Qt.resolvedUrl(trackQueue.model.get(player.currentIndex).filename) === file) {
82- player.toggle()
83- return;
84+ if (!clear) {
85+ // If same track and on now playing page then toggle
86+ if (musicToolbar.currentPage === nowPlaying &&
87+ trackQueue.model.get(player.currentIndex) !== undefined &&
88+ Qt.resolvedUrl(trackQueue.model.get(player.currentIndex).filename) === file) {
89+ player.toggle()
90+ return;
91+ }
92 }
93
94 trackQueue.model.clear(); // clear the old model

Subscribers

People subscribed via source and target branches

to status/vote changes: