Merge lp:~ahayzen/music-app/startup-model-console-warning into lp:music-app/remix

Proposed by Andrew Hayzen
Status: Merged
Approved by: Victor Thompson
Approved revision: 832
Merged at revision: 832
Proposed branch: lp:~ahayzen/music-app/startup-model-console-warning
Merge into: lp:music-app/remix
Diff against target: 48 lines (+15/-12)
1 file modified
music-app.qml (+15/-12)
To merge this branch: bzr merge lp:~ahayzen/music-app/startup-model-console-warning
Reviewer Review Type Date Requested Status
Victor Thompson Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+248837@code.launchpad.net

Commit message

* Fix for console error on startup

Description of the change

* Fix for console error on startup

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 :

What console error does this prevent?

review: Needs Information
Revision history for this message
Andrew Hayzen (ahayzen) wrote :

/app/music-app.qml:1320: TypeError: Cannot read property 'model' of null

Revision history for this message
Victor Thompson (vthompson) wrote :

lgtm!

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 2015-02-04 00:29:37 +0000
3+++ music-app.qml 2015-02-05 22:41:09 +0000
4@@ -1257,7 +1257,7 @@
5 // Set the models in the tab to allow/disallow loading
6 function allowLoading(tabToLoad, state)
7 {
8- if (tabToLoad !== undefined && tabToLoad.model !== undefined)
9+ if (tabToLoad && tabToLoad.model !== undefined)
10 {
11 for (var i=0; i < tabToLoad.model.length; i++)
12 {
13@@ -1268,21 +1268,24 @@
14
15 function ensurePopulated(selectedTab)
16 {
17- allowLoading(selectedTab, true); // allow loading of the models
18-
19- if (!selectedTab.populated && !selectedTab.loading && loadedUI) {
20- loading.visible = true
21- selectedTab.loading = true
22-
23- if (selectedTab.loader !== undefined)
24- {
25- for (var i=0; i < selectedTab.loader.length; i++)
26+ if (selectedTab) { // check not null or undefined
27+ allowLoading(selectedTab, true); // allow loading of the models
28+
29+ if (!selectedTab.populated && !selectedTab.loading && loadedUI) {
30+ loading.visible = true
31+ selectedTab.loading = true
32+
33+ if (selectedTab.loader !== undefined)
34 {
35- selectedTab.loader[i]();
36+ for (var i=0; i < selectedTab.loader.length; i++)
37+ {
38+ selectedTab.loader[i]();
39+ }
40 }
41 }
42+
43+ loading.visible = selectedTab.loading || !selectedTab.populated
44 }
45- loading.visible = selectedTab.loading || !selectedTab.populated
46 }
47
48 function pushNowPlaying()

Subscribers

People subscribed via source and target branches