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
=== modified file 'app/alarm/EditAlarmPage.qml'
--- app/alarm/EditAlarmPage.qml 2015-08-21 21:28:40 +0000
+++ app/alarm/EditAlarmPage.qml 2015-08-21 22:15:48 +0000
@@ -252,33 +252,40 @@
252 FolderListModel {252 FolderListModel {
253 id: defaultSoundModel253 id: defaultSoundModel
254254
255 property bool isModelLoaded: false
256
255 showDirs: false257 showDirs: false
256 nameFilters: [ "*.ogg", "*.mp3" ]258 nameFilters: [ "*.ogg", "*.mp3" ]
257 folder: "/usr/share/sounds/ubuntu/ringtones"259 folder: "/usr/share/sounds/ubuntu/ringtones"
258260 Component.onCompleted: {
259 onCountChanged: {261 isModelLoaded = true
260 if(count > 0) {
261 // When folder model is completely loaded set the alarm sound.
262 if(!pageStack.currentPage.isAlarmSoundPage) {
263 setAlarmSound()
264 }
265 }
266 }262 }
267 }263 }
268264
269 FolderListModel {265 FolderListModel {
270 id: customSoundModel266 id: customSoundModel
271267
268 property bool isModelLoaded: false
269
272 showDirs: false270 showDirs: false
273 folder: customSound.alarmSoundDirectory271 folder: customSound.alarmSoundDirectory
272 Component.onCompleted: {
273 isModelLoaded = true
274 }
275 }
274276
275 onCountChanged: {277 /*
276 if(count > 0) {278 QML FolderListModel does not provide any signals to indicate that it is fully loaded other
277 // When folder model is completely loaded set the alarm sound.279 than the onCompleted() signal which is not sufficient. This introduces a race-condition where
278 if(!pageStack.currentPage.isAlarmSoundPage) {280 file checks are done *before* the folder models have fully loaded. This timer introduces a
279 setAlarmSound()281 delay to workaround that issue.
280 }282 */
281 }283 Timer {
284 id: delaySettingAlarmSoundTimer
285 interval: 100
286 running: defaultSoundModel.isModelLoaded && customSoundModel.isModelLoaded
287 onTriggered: {
288 setAlarmSound()
282 }289 }
283 }290 }
284291
@@ -359,8 +366,7 @@
359 id: _alarmSound366 id: _alarmSound
360 objectName: "alarmSound"367 objectName: "alarmSound"
361368
362 // Default Alarm Sound for new alarms369 readonly property string defaultAlarmSound: "Alarm clock"
363 property string defaultAlarmSound: "Alarm clock"
364370
365 text: i18n.tr("Sound")371 text: i18n.tr("Sound")
366 onClicked: pageStack.push(Qt.resolvedUrl("AlarmSound.qml"), {372 onClicked: pageStack.push(Qt.resolvedUrl("AlarmSound.qml"), {

Subscribers

People subscribed via source and target branches