Merge lp:~nik90/ubuntu-clock-app/fix-alarm-sound-race-issue into lp:ubuntu-clock-app

Proposed by Nekhelesh Ramananthan
Status: Merged
Approved by: Nekhelesh Ramananthan
Approved revision: 348
Merged at revision: 347
Proposed branch: lp:~nik90/ubuntu-clock-app/fix-alarm-sound-race-issue
Merge into: lp:ubuntu-clock-app
Prerequisite: lp:~nik90/ubuntu-clock-app/default-alarm-sound-backwards-compatibility
Diff against target: 69 lines (+23/-17)
1 file modified
app/alarm/EditAlarmPage.qml (+23/-17)
To merge this branch: bzr merge lp:~nik90/ubuntu-clock-app/fix-alarm-sound-race-issue
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Bartosz Kosiorek Approve
Review via email: mp+268814@code.launchpad.net

Commit message

Fixes race issue in the edit alarm page caused due to the QML FolderListModel resulting in incorrect alarm sound names sometimes being shown.

Description of the change

In trunk, there is a race issue involved due the 2 QML FolderListModels defaultSoundModel and customSoundModel. The reason it happens is because QML FolderListModel does not have a signal to indicate that it has finished loading. The onComplete() signal is useless here since after it has completed, the count variable still takes another few ms to update.

So some of the file checks we do for custom alarm sound like checking the existence of the file is done *before* the 2 FolderListModels have fully loaded thereby providing incorrect results sometimes.

I have introduced a Timer which introduces a delay of 250ms to ensure that the FolderListModels have fully loaded before performing the file checks.

This seems to have solved the issue.

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: Needs Fixing (continuous-integration)
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
Bartosz Kosiorek (gang65) wrote :

It is working for me correctly, except issues which I was described in chat.
I will report bugs for that issues later.

Thanks Nekhelesh.

review: Approve
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :

FAILED: Autolanding.
More details in the following jenkins job:
http://91.189.93.70:8080/job/ubuntu-clock-app-autolanding/296/
Executed test runs:
    FAILURE: http://91.189.93.70:8080/job/ubuntu-clock-app-vivid-amd64-autolanding/53/console

review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'app/alarm/EditAlarmPage.qml'
2--- app/alarm/EditAlarmPage.qml 2015-08-21 21:28:40 +0000
3+++ app/alarm/EditAlarmPage.qml 2015-08-21 22:15:48 +0000
4@@ -252,33 +252,40 @@
5 FolderListModel {
6 id: defaultSoundModel
7
8+ property bool isModelLoaded: false
9+
10 showDirs: false
11 nameFilters: [ "*.ogg", "*.mp3" ]
12 folder: "/usr/share/sounds/ubuntu/ringtones"
13-
14- onCountChanged: {
15- if(count > 0) {
16- // When folder model is completely loaded set the alarm sound.
17- if(!pageStack.currentPage.isAlarmSoundPage) {
18- setAlarmSound()
19- }
20- }
21+ Component.onCompleted: {
22+ isModelLoaded = true
23 }
24 }
25
26 FolderListModel {
27 id: customSoundModel
28
29+ property bool isModelLoaded: false
30+
31 showDirs: false
32 folder: customSound.alarmSoundDirectory
33+ Component.onCompleted: {
34+ isModelLoaded = true
35+ }
36+ }
37
38- onCountChanged: {
39- if(count > 0) {
40- // When folder model is completely loaded set the alarm sound.
41- if(!pageStack.currentPage.isAlarmSoundPage) {
42- setAlarmSound()
43- }
44- }
45+ /*
46+ QML FolderListModel does not provide any signals to indicate that it is fully loaded other
47+ than the onCompleted() signal which is not sufficient. This introduces a race-condition where
48+ file checks are done *before* the folder models have fully loaded. This timer introduces a
49+ delay to workaround that issue.
50+ */
51+ Timer {
52+ id: delaySettingAlarmSoundTimer
53+ interval: 100
54+ running: defaultSoundModel.isModelLoaded && customSoundModel.isModelLoaded
55+ onTriggered: {
56+ setAlarmSound()
57 }
58 }
59
60@@ -359,8 +366,7 @@
61 id: _alarmSound
62 objectName: "alarmSound"
63
64- // Default Alarm Sound for new alarms
65- property string defaultAlarmSound: "Alarm clock"
66+ readonly property string defaultAlarmSound: "Alarm clock"
67
68 text: i18n.tr("Sound")
69 onClicked: pageStack.push(Qt.resolvedUrl("AlarmSound.qml"), {

Subscribers

People subscribed via source and target branches