Merge lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/optInDeprecationWarnings into lp:ubuntu-ui-toolkit/staging

Proposed by Cris Dywan
Status: Merged
Merge reported by: Cris Dywan
Merged at revision: not available
Proposed branch: lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/optInDeprecationWarnings
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 165 lines (+49/-27)
4 files modified
src/Ubuntu/Components/plugin/quickutils.cpp (+9/-0)
src/Ubuntu/Components/plugin/quickutils.h (+1/-0)
src/Ubuntu/Components/plugin/ucdeprecatedtheme.cpp (+6/-5)
src/Ubuntu/Components/plugin/ucubuntushape.cpp (+33/-22)
To merge this branch: bzr merge lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/optInDeprecationWarnings
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Zoltan Balogh Approve
Review via email: mp+268902@code.launchpad.net

Commit message

Make deprecation warnings from C++ opt-in

Description of the change

Make deprecation warnings from C++ opt-in

To post a comment you must log in.
Revision history for this message
Zoltan Balogh (bzoltan) wrote :

Good for me

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Ubuntu/Components/plugin/quickutils.cpp'
2--- src/Ubuntu/Components/plugin/quickutils.cpp 2015-03-10 11:49:27 +0000
3+++ src/Ubuntu/Components/plugin/quickutils.cpp 2015-08-24 11:39:27 +0000
4@@ -196,3 +196,12 @@
5 delete component;
6 return result;
7 }
8+
9+bool QuickUtils::showDeprecationWarnings() {
10+ static int showWarnings = 0;
11+ if (showWarnings == 0) {
12+ QByteArray warningsFlag = qgetenv("SUPPRESS_DEPRECATED_NOTE");
13+ showWarnings = (warningsFlag.isEmpty() || warningsFlag == "yes") ? 1 : 2;
14+ }
15+ return showWarnings == 2;
16+}
17
18=== modified file 'src/Ubuntu/Components/plugin/quickutils.h'
19--- src/Ubuntu/Components/plugin/quickutils.h 2015-03-10 11:49:27 +0000
20+++ src/Ubuntu/Components/plugin/quickutils.h 2015-08-24 11:39:27 +0000
21@@ -46,6 +46,7 @@
22 Q_INVOKABLE static QString className(QObject *item);
23 Q_REVISION(1) Q_INVOKABLE static bool inherits(QObject *object, const QString &fromClass);
24 QObject* createQmlObject(const QUrl &url, QQmlEngine *engine);
25+ static bool showDeprecationWarnings();
26
27 Q_SIGNALS:
28 void rootObjectChanged();
29
30=== modified file 'src/Ubuntu/Components/plugin/ucdeprecatedtheme.cpp'
31--- src/Ubuntu/Components/plugin/ucdeprecatedtheme.cpp 2015-05-27 18:02:23 +0000
32+++ src/Ubuntu/Components/plugin/ucdeprecatedtheme.cpp 2015-08-24 11:39:27 +0000
33@@ -19,6 +19,7 @@
34 #include "ucnamespace.h"
35 #include "ucdeprecatedtheme.h"
36 #include "uctheme.h"
37+#include "quickutils.h"
38 #include "listener.h"
39 #include <QtQml/QQmlComponent>
40 #include <QtQml/QQmlContext>
41@@ -75,6 +76,9 @@
42
43 void UCDeprecatedTheme::showDeprecatedNote(QObject *onItem, const char *note)
44 {
45+ if (!QuickUtils::showDeprecationWarnings())
46+ return;
47+
48 QQmlContext ctx(QQmlEngine::contextForObject(onItem));
49 // No warnings due to deprecated code used in the components themselves
50 if (ctx.baseUrl().toString().contains("/Ubuntu/Components/"))
51@@ -86,11 +90,8 @@
52 QString noteId(QString("%1.%2").arg(note).arg(onItem->metaObject()->className()));
53 if (m_notes.contains(noteId))
54 return;
55- QByteArray suppressNote = qgetenv("SUPPRESS_DEPRECATED_NOTE");
56- if (suppressNote.isEmpty() || suppressNote != "yes") {
57- qmlInfo(onItem) << note;
58- m_notes.insert(noteId, true);
59- }
60+ qmlInfo(onItem) << note;
61+ m_notes.insert(noteId, true);
62 }
63
64 /*!
65
66=== modified file 'src/Ubuntu/Components/plugin/ucubuntushape.cpp'
67--- src/Ubuntu/Components/plugin/ucubuntushape.cpp 2015-08-24 09:24:37 +0000
68+++ src/Ubuntu/Components/plugin/ucubuntushape.cpp 2015-08-24 11:39:27 +0000
69@@ -28,6 +28,7 @@
70 #include "ucubuntushape.h"
71 #include "ucubuntushapetexture.h"
72 #include "ucunits.h"
73+#include "quickutils.h"
74 #include <QtCore/QPointer>
75 #include <QtGui/QGuiApplication>
76 #include <QtGui/QScreen>
77@@ -790,11 +791,13 @@
78 */
79 void UCUbuntuShape::setColor(const QColor& color)
80 {
81- static bool deprecationNoteShown = false;
82- if (!deprecationNoteShown) {
83- deprecationNoteShown = true;
84- qmlInfo(this) << "'color' is deprecated. Use 'backgroundColor', 'secondaryBackgroundColor' and "
85- "'backgroundMode' instead.";
86+ if (QuickUtils::showDeprecationWarnings()) {
87+ static bool deprecationNoteShown = false;
88+ if (!deprecationNoteShown) {
89+ deprecationNoteShown = true;
90+ qmlInfo(this) << "'color' is deprecated. Use 'backgroundColor', 'secondaryBackgroundColor' and "
91+ "'backgroundMode' instead.";
92+ }
93 }
94
95 if (!(m_flags & BackgroundApiSet)) {
96@@ -823,11 +826,13 @@
97 */
98 void UCUbuntuShape::setGradientColor(const QColor& gradientColor)
99 {
100- static bool deprecationNoteShown = false;
101- if (!deprecationNoteShown) {
102- deprecationNoteShown = true;
103- qmlInfo(this) << "'gradientColor' is deprecated. Use 'backgroundColor', "
104- "'secondaryBackgroundColor' and 'backgroundMode' instead.";
105+ if (QuickUtils::showDeprecationWarnings()) {
106+ static bool deprecationNoteShown = false;
107+ if (!deprecationNoteShown) {
108+ deprecationNoteShown = true;
109+ qmlInfo(this) << "'gradientColor' is deprecated. Use 'backgroundColor', "
110+ "'secondaryBackgroundColor' and 'backgroundMode' instead.";
111+ }
112 }
113
114 if (!(m_flags & BackgroundApiSet)) {
115@@ -854,10 +859,12 @@
116 */
117 void UCUbuntuShape::setImage(const QVariant& image)
118 {
119- static bool deprecationNoteShown = false;
120- if (!deprecationNoteShown) {
121- deprecationNoteShown = true;
122- qmlInfo(this) << "'image' is deprecated. Use 'source' instead.";
123+ if (QuickUtils::showDeprecationWarnings()) {
124+ static bool deprecationNoteShown = false;
125+ if (!deprecationNoteShown) {
126+ deprecationNoteShown = true;
127+ qmlInfo(this) << "'image' is deprecated. Use 'source' instead.";
128+ }
129 }
130
131 if (!(m_flags & SourceApiSet)) {
132@@ -887,10 +894,12 @@
133 // maintain it for a while for compatibility reasons.
134 void UCUbuntuShape::setStretched(bool stretched)
135 {
136- static bool deprecationNoteShown = false;
137- if (!deprecationNoteShown) {
138- deprecationNoteShown = true;
139- qmlInfo(this) << "'stretched' is deprecated. Use 'sourceFillMode' instead";
140+ if (QuickUtils::showDeprecationWarnings()) {
141+ static bool deprecationNoteShown = false;
142+ if (!deprecationNoteShown) {
143+ deprecationNoteShown = true;
144+ qmlInfo(this) << "'stretched' is deprecated. Use 'sourceFillMode' instead";
145+ }
146 }
147
148 if (!(m_flags & SourceApiSet)) {
149@@ -910,10 +919,12 @@
150 // Deprecation layer. Same comment as setStretched().
151 void UCUbuntuShape::setHorizontalAlignment(HAlignment horizontalAlignment)
152 {
153- static bool deprecationNoteShown = false;
154- if (!deprecationNoteShown) {
155- deprecationNoteShown = true;
156- qmlInfo(this) << "'horizontalAlignment' is deprecated. Use 'sourceHorizontalAlignment' instead";
157+ if (QuickUtils::showDeprecationWarnings()) {
158+ static bool deprecationNoteShown = false;
159+ if (!deprecationNoteShown) {
160+ deprecationNoteShown = true;
161+ qmlInfo(this) << "'horizontalAlignment' is deprecated. Use 'sourceHorizontalAlignment' instead";
162+ }
163 }
164
165 if (!(m_flags & SourceApiSet)) {

Subscribers

People subscribed via source and target branches