Merge lp:~vthompson/ubuntu-clock-app/resolve-build-warning into lp:ubuntu-clock-app

Proposed by Victor Thompson
Status: Merged
Approved by: Nekhelesh Ramananthan
Approved revision: 33
Merged at revision: 33
Proposed branch: lp:~vthompson/ubuntu-clock-app/resolve-build-warning
Merge into: lp:ubuntu-clock-app
Diff against target: 25 lines (+2/-2)
2 files modified
backend/modules/Alarm/Settings/alarmsettings.cpp (+1/-1)
backend/modules/Alarm/Settings/alarmsettings.h (+1/-1)
To merge this branch: bzr merge lp:~vthompson/ubuntu-clock-app/resolve-build-warning
Reviewer Review Type Date Requested Status
Nekhelesh Ramananthan Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Needs Fixing
Victor Thompson Needs Fixing
Review via email: mp+228437@code.launchpad.net

Commit message

Resolve build warning

Description of the change

Currently, a warning is produced when building the app. An unused parameter "valid" is part of the signature for AlarmSettings::onSettingsChanged. Can this variable be removed or is it needed for a future functionality?

[ 30%] Building CXX object backend/CMakeFiles/alarmsettings.dir/modules/Alarm/Settings/alarmsettings.cpp.o
/home/victor/Development/reboot/backend/modules/Alarm/Settings/alarmsettings.cpp:40:6: warning: unused parameter ‘valid’ [-Wunused-parameter]
 void AlarmSettings::onSettingsChanged(const QString &interface,
      ^

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
Nekhelesh Ramananthan (nik90) wrote :

hmm I will have to check with Charles about this. Will find out tomorrow.

Revision history for this message
Charles Kerr (charlesk) wrote :

Nik90, TBH I haven't dropped arguments out of a signal/slot function and am not sure what Qt does under the covers there. If Victor's patch works, I guess that's our answer.

Another way to fix the warning is to leave the function signature alone (i.e., keep the arguments the same to match the org.freedesktop.DBus.Properties.PropertiesChanged signature) but remove the names of the unused fields to let the compiler know they're unused. I usually do this by putting the variable name inside a comment so it's hidden from the compiler but that humans can still see what's going on. Specifically:

void onSettingsChanged(const QString &interface,
                       const QVariantMap &properties,
                       const QStringList& /*invalidated_properties*/);

Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :

@Victor, what you proposed and what charles said both work. I tested it on the utopic phone emulator. I think however we should stick to charles's solution since this way we do not change the function signature. So can you please change that to,

=== modified file 'backend/modules/Alarm/Settings/alarmsettings.cpp'
--- backend/modules/Alarm/Settings/alarmsettings.cpp 2014-07-27 22:18:23 +0000
+++ backend/modules/Alarm/Settings/alarmsettings.cpp 2014-07-28 15:52:41 +0000
@@ -34,11 +34,12 @@
                        "org.freedesktop.DBus.Properties",
                        "PropertiesChanged",
                        this,
- SLOT(onSettingsChanged(QString, QVariantMap)));
+ SLOT(onSettingsChanged(QString, QVariantMap, QStringList)));
 }

 void AlarmSettings::onSettingsChanged(const QString &interface,
- const QVariantMap &properties)
+ const QVariantMap &properties,
+ const QStringList /*&valid*/)
 {
     if(interface != "com.canonical.indicator.datetime.AlarmProperties") {
         // Check if the properties changed are in the correct interface

=== modified file 'backend/modules/Alarm/Settings/alarmsettings.h'
--- backend/modules/Alarm/Settings/alarmsettings.h 2014-07-27 22:18:23 +0000
+++ backend/modules/Alarm/Settings/alarmsettings.h 2014-07-28 15:51:29 +0000
@@ -79,7 +79,8 @@
      settings values are changed on dBus side
     */
     void onSettingsChanged(const QString &interface,
- const QVariantMap &properties);
+ const QVariantMap &properties,
+ const QStringList /*invalidated_properties*/);
 };

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

I will do this the way Charles suggests, I agree it's a better option. However, I'd like to leave the variable name in the commentary as-is:

=== modified file 'backend/modules/Alarm/Settings/alarmsettings.h'
--- backend/modules/Alarm/Settings/alarmsettings.h 2014-07-27 22:18:23 +0000
+++ backend/modules/Alarm/Settings/alarmsettings.h 2014-07-28 15:51:29 +0000
@@ -79,7 +79,8 @@
      settings values are changed on dBus side
     */
     void onSettingsChanged(const QString &interface,
- const QVariantMap &properties);
+ const QVariantMap &properties,
+ const QStringList /*&valid*/);

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

It seems Qt has a defined macro for this purpose [1]. Maybe that's a better option? I assume that it's portable.

[1] http://qt-project.org/doc/qt-5/qtglobal.html#Q_UNUSED

Revision history for this message
Nekhelesh Ramananthan (nik90) wrote :

> It seems Qt has a defined macro for this purpose [1]. Maybe that's a better
> option? I assume that it's portable.
>
> [1] http://qt-project.org/doc/qt-5/qtglobal.html#Q_UNUSED

Reading through http://www.qtcentre.org/threads/39725-A-more-extended-explanation-for-Q_UNUSED-macro, either one is fine. So I leave the choice to you.

33. By Victor Thompson

Update solution

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
Nekhelesh Ramananthan (nik90) wrote :

lgtm

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'backend/modules/Alarm/Settings/alarmsettings.cpp'
2--- backend/modules/Alarm/Settings/alarmsettings.cpp 2014-07-18 14:56:49 +0000
3+++ backend/modules/Alarm/Settings/alarmsettings.cpp 2014-07-28 23:09:33 +0000
4@@ -39,7 +39,7 @@
5
6 void AlarmSettings::onSettingsChanged(const QString &interface,
7 const QVariantMap &properties,
8- const QStringList &valid)
9+ const QStringList & /*valid*/)
10 {
11 if(interface != "com.canonical.indicator.datetime.AlarmProperties") {
12 // Check if the properties changed are in the correct interface
13
14=== modified file 'backend/modules/Alarm/Settings/alarmsettings.h'
15--- backend/modules/Alarm/Settings/alarmsettings.h 2014-07-18 14:56:49 +0000
16+++ backend/modules/Alarm/Settings/alarmsettings.h 2014-07-28 23:09:33 +0000
17@@ -80,7 +80,7 @@
18 */
19 void onSettingsChanged(const QString &interface,
20 const QVariantMap &properties,
21- const QStringList &valid);
22+ const QStringList & /*valid*/);
23 };
24
25 #endif

Subscribers

People subscribed via source and target branches