Merge lp:~bfiller/phone-app/fix-ringtone into lp:phone-app

Proposed by Bill Filler
Status: Rejected
Rejected by: Gustavo Pichorim Boiko
Proposed branch: lp:~bfiller/phone-app/fix-ringtone
Merge into: lp:phone-app
Diff against target: 24 lines (+5/-2)
1 file modified
libphoneapp/ringtone.cpp (+5/-2)
To merge this branch: bzr merge lp:~bfiller/phone-app/fix-ringtone
Reviewer Review Type Date Requested Status
Gustavo Pichorim Boiko (community) Disapprove
PS Jenkins bot continuous-integration Approve
Review via email: mp+167135@code.launchpad.net

Commit message

fix singleton

Description of the change

fix singleton

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Gustavo Pichorim Boiko (boiko) wrote :

As self is being declared static, it will only be initialized once in the original code. The change itself is not wrong, it can be implemented that way too, but the result is the same and in my personal opinion the original code is more simple as it is contained all in the function code.

review: Disapprove

Unmerged revisions

663. By Bill Filler

don't new up instance of Ringtone each time, check if null and only new if needed

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libphoneapp/ringtone.cpp'
2--- libphoneapp/ringtone.cpp 2013-03-11 22:22:35 +0000
3+++ libphoneapp/ringtone.cpp 2013-06-03 20:14:25 +0000
4@@ -23,6 +23,8 @@
5 #include <QDebug>
6
7 #define SOUND_PATH "/usr/share/sounds/ubuntu/stereo/"
8+static Ringtone *self = NULL;
9+
10 Ringtone::Ringtone(QObject *parent) :
11 QObject(parent),
12 mCallAudioPlayer(this), mCallAudioPlaylist(this), mMessageAudioPlayer(this)
13@@ -35,8 +37,9 @@
14
15 Ringtone *Ringtone::instance()
16 {
17- static Ringtone *self = new Ringtone();
18- return self;
19+ if (self == NULL)
20+ self = new Ringtone();
21+ return self;
22 }
23
24 void Ringtone::playIncomingCallSound()

Subscribers

People subscribed via source and target branches