Merge lp:~fboucault/bamf-qt/bamf-qt-crashfix702566 into lp:bamf-qt
- bamf-qt-crashfix702566
- Merge into trunk
Proposed by
Florian Boucault
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Ugo Riboni | ||||
Approved revision: | 365 | ||||
Merged at revision: | 368 | ||||
Proposed branch: | lp:~fboucault/bamf-qt/bamf-qt-crashfix702566 | ||||
Merge into: | lp:bamf-qt | ||||
Diff against target: |
416 lines (+241/-16) 10 files modified
CMakeLists.txt (+4/-0) bamf-application.cpp (+12/-3) bamf-factory.cpp (+3/-3) bamf-indicator-proxy.cpp (+26/-0) bamf-indicator-proxy.h (+61/-0) bamf-indicator.cpp (+62/-0) bamf-indicator.h (+55/-0) bamf-matcher.cpp (+15/-9) bamf-plugin.cpp (+2/-0) bamf-window.cpp (+1/-1) |
||||
To merge this branch: | bzr merge lp:~fboucault/bamf-qt/bamf-qt-crashfix702566 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ugo Riboni | Pending | ||
Review via email:
|
Commit message
Description of the change
Added support for indicators (new BamfIndicator class).
Added safeguards for when BamfFactory:
Replaced static_cast with qobject_cast for values returned from BamfFactory:
To post a comment you must log in.
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Florian Boucault (fboucault) wrote : | # |
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Florian Boucault (fboucault) wrote : | # |
The why this MR fixes the issue is two-folds:
1) using static cast is wrong; a dynamic cast needs to be used so that if the cast fails a NULL pointer is returned. qobject_cast does the same but is smarter about other things.
2) the MR adds NULL pointer checks in relevant places
- 364. By Florian Boucault
-
Methods Address and Path in BamfIndicator now return QString() when failing, instead of NULL.
- 365. By Florian Boucault
-
Fixed indentation.
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Florian Boucault (fboucault) wrote : | # |
The 2 stylistic issues raised are now fixed.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'CMakeLists.txt' | |||
2 | --- CMakeLists.txt 2011-01-13 17:57:36 +0000 | |||
3 | +++ CMakeLists.txt 2011-01-17 04:32:10 +0000 | |||
4 | @@ -13,6 +13,8 @@ | |||
5 | 13 | bamf-control.cpp | 13 | bamf-control.cpp |
6 | 14 | bamf-control-proxy.cpp | 14 | bamf-control-proxy.cpp |
7 | 15 | bamf-factory.cpp | 15 | bamf-factory.cpp |
8 | 16 | bamf-indicator.cpp | ||
9 | 17 | bamf-indicator-proxy.cpp | ||
10 | 16 | bamf-matcher.cpp | 18 | bamf-matcher.cpp |
11 | 17 | bamf-matcher-proxy.cpp | 19 | bamf-matcher-proxy.cpp |
12 | 18 | bamf-view.cpp | 20 | bamf-view.cpp |
13 | @@ -27,6 +29,8 @@ | |||
14 | 27 | bamf-control.h | 29 | bamf-control.h |
15 | 28 | bamf-control-proxy.h | 30 | bamf-control-proxy.h |
16 | 29 | bamf-factory.h | 31 | bamf-factory.h |
17 | 32 | bamf-indicator.h | ||
18 | 33 | bamf-indicator-proxy.h | ||
19 | 30 | bamf-list.h | 34 | bamf-list.h |
20 | 31 | bamf-matcher.h | 35 | bamf-matcher.h |
21 | 32 | bamf-matcher-proxy.h | 36 | bamf-matcher-proxy.h |
22 | 33 | 37 | ||
23 | === modified file 'bamf-application.cpp' | |||
24 | --- bamf-application.cpp 2010-12-21 09:56:42 +0000 | |||
25 | +++ bamf-application.cpp 2011-01-17 04:32:10 +0000 | |||
26 | @@ -85,7 +85,10 @@ | |||
27 | 85 | BamfViewList *children = this->children(); | 85 | BamfViewList *children = this->children(); |
28 | 86 | for(int i = 0; i < children->size(); ++i) | 86 | for(int i = 0; i < children->size(); ++i) |
29 | 87 | { | 87 | { |
31 | 88 | result.prepend(static_cast<BamfWindow *>(children->at(i))); | 88 | BamfWindow* window = qobject_cast<BamfWindow *>(children->at(i)); |
32 | 89 | if (window != NULL) { | ||
33 | 90 | result.prepend(window); | ||
34 | 91 | } | ||
35 | 89 | } | 92 | } |
36 | 90 | delete children; | 93 | delete children; |
37 | 91 | return new BamfWindowList(result); | 94 | return new BamfWindowList(result); |
38 | @@ -95,13 +98,19 @@ | |||
39 | 95 | BamfApplication::OnWindowAdded(const QString &path) | 98 | BamfApplication::OnWindowAdded(const QString &path) |
40 | 96 | { | 99 | { |
41 | 97 | BamfView *view = BamfFactory::get_default().view_for_path(path); | 100 | BamfView *view = BamfFactory::get_default().view_for_path(path); |
43 | 98 | WindowAdded(static_cast<BamfWindow *>(view)); | 101 | BamfWindow* window = qobject_cast<BamfWindow *>(view); |
44 | 102 | if (window != NULL) { | ||
45 | 103 | WindowAdded(window); | ||
46 | 104 | } | ||
47 | 99 | } | 105 | } |
48 | 100 | 106 | ||
49 | 101 | void | 107 | void |
50 | 102 | BamfApplication::OnWindowRemoved(const QString &path) | 108 | BamfApplication::OnWindowRemoved(const QString &path) |
51 | 103 | { | 109 | { |
52 | 104 | BamfView *view = BamfFactory::get_default().view_for_path(path); | 110 | BamfView *view = BamfFactory::get_default().view_for_path(path); |
54 | 105 | WindowRemoved(static_cast<BamfWindow *>(view)); | 111 | BamfWindow* window = qobject_cast<BamfWindow *>(view); |
55 | 112 | if (window != NULL) { | ||
56 | 113 | WindowRemoved(window); | ||
57 | 114 | } | ||
58 | 106 | } | 115 | } |
59 | 107 | 116 | ||
60 | 108 | 117 | ||
61 | === modified file 'bamf-factory.cpp' | |||
62 | --- bamf-factory.cpp 2010-12-21 09:56:42 +0000 | |||
63 | +++ bamf-factory.cpp 2011-01-17 04:32:10 +0000 | |||
64 | @@ -22,7 +22,7 @@ | |||
65 | 22 | #include "bamf-view.h" | 22 | #include "bamf-view.h" |
66 | 23 | #include "bamf-application.h" | 23 | #include "bamf-application.h" |
67 | 24 | #include "bamf-window.h" | 24 | #include "bamf-window.h" |
69 | 25 | //#include "bamf-indicator.h" | 25 | #include "bamf-indicator.h" |
70 | 26 | 26 | ||
71 | 27 | BamfFactory::BamfFactory() : | 27 | BamfFactory::BamfFactory() : |
72 | 28 | m_views(NULL) | 28 | m_views(NULL) |
73 | @@ -48,8 +48,8 @@ | |||
74 | 48 | view = static_cast<BamfView *>(new BamfApplication(path)); | 48 | view = static_cast<BamfView *>(new BamfApplication(path)); |
75 | 49 | else if (type == "window") | 49 | else if (type == "window") |
76 | 50 | view = static_cast<BamfView *>(new BamfWindow(path)); | 50 | view = static_cast<BamfView *>(new BamfWindow(path)); |
79 | 51 | //else if (type == "indicator") | 51 | else if (type == "indicator") |
80 | 52 | // view = static_cast<BamfView *>(new BamfIndicator(path)); | 52 | view = static_cast<BamfView *>(new BamfIndicator(path)); |
81 | 53 | 53 | ||
82 | 54 | if (view != NULL) | 54 | if (view != NULL) |
83 | 55 | { | 55 | { |
84 | 56 | 56 | ||
85 | === added file 'bamf-indicator-proxy.cpp' | |||
86 | --- bamf-indicator-proxy.cpp 1970-01-01 00:00:00 +0000 | |||
87 | +++ bamf-indicator-proxy.cpp 2011-01-17 04:32:10 +0000 | |||
88 | @@ -0,0 +1,26 @@ | |||
89 | 1 | /* | ||
90 | 2 | * This file was generated by qdbusxml2cpp version 0.7 | ||
91 | 3 | * Command line was: qdbusxml2cpp bamf-indicator-glue.xml -p bamf-indicator-proxy | ||
92 | 4 | * | ||
93 | 5 | * qdbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). | ||
94 | 6 | * | ||
95 | 7 | * This is an auto-generated file. | ||
96 | 8 | * This file may have been hand-edited. Look for HAND-EDIT comments | ||
97 | 9 | * before re-generating it. | ||
98 | 10 | */ | ||
99 | 11 | |||
100 | 12 | #include "bamf-indicator-proxy.h" | ||
101 | 13 | |||
102 | 14 | /* | ||
103 | 15 | * Implementation of interface class OrgAyatanaBamfIndicatorInterface | ||
104 | 16 | */ | ||
105 | 17 | |||
106 | 18 | OrgAyatanaBamfIndicatorInterface::OrgAyatanaBamfIndicatorInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) | ||
107 | 19 | : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent) | ||
108 | 20 | { | ||
109 | 21 | } | ||
110 | 22 | |||
111 | 23 | OrgAyatanaBamfIndicatorInterface::~OrgAyatanaBamfIndicatorInterface() | ||
112 | 24 | { | ||
113 | 25 | } | ||
114 | 26 | |||
115 | 0 | 27 | ||
116 | === added file 'bamf-indicator-proxy.h' | |||
117 | --- bamf-indicator-proxy.h 1970-01-01 00:00:00 +0000 | |||
118 | +++ bamf-indicator-proxy.h 2011-01-17 04:32:10 +0000 | |||
119 | @@ -0,0 +1,61 @@ | |||
120 | 1 | /* | ||
121 | 2 | * This file was generated by qdbusxml2cpp version 0.7 | ||
122 | 3 | * Command line was: qdbusxml2cpp bamf-indicator-glue.xml -p bamf-indicator-proxy | ||
123 | 4 | * | ||
124 | 5 | * qdbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). | ||
125 | 6 | * | ||
126 | 7 | * This is an auto-generated file. | ||
127 | 8 | * Do not edit! All changes made to it will be lost. | ||
128 | 9 | */ | ||
129 | 10 | |||
130 | 11 | #ifndef BAMF-INDICATOR-PROXY_H_1294953124 | ||
131 | 12 | #define BAMF-INDICATOR-PROXY_H_1294953124 | ||
132 | 13 | |||
133 | 14 | #include <QtCore/QObject> | ||
134 | 15 | #include <QtCore/QByteArray> | ||
135 | 16 | #include <QtCore/QList> | ||
136 | 17 | #include <QtCore/QMap> | ||
137 | 18 | #include <QtCore/QString> | ||
138 | 19 | #include <QtCore/QStringList> | ||
139 | 20 | #include <QtCore/QVariant> | ||
140 | 21 | #include <QtDBus/QtDBus> | ||
141 | 22 | |||
142 | 23 | /* | ||
143 | 24 | * Proxy class for interface org.ayatana.bamf.indicator | ||
144 | 25 | */ | ||
145 | 26 | class OrgAyatanaBamfIndicatorInterface: public QDBusAbstractInterface | ||
146 | 27 | { | ||
147 | 28 | Q_OBJECT | ||
148 | 29 | public: | ||
149 | 30 | static inline const char *staticInterfaceName() | ||
150 | 31 | { return "org.ayatana.bamf.indicator"; } | ||
151 | 32 | |||
152 | 33 | public: | ||
153 | 34 | OrgAyatanaBamfIndicatorInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); | ||
154 | 35 | |||
155 | 36 | ~OrgAyatanaBamfIndicatorInterface(); | ||
156 | 37 | |||
157 | 38 | public Q_SLOTS: // METHODS | ||
158 | 39 | inline QDBusPendingReply<QString> Address() | ||
159 | 40 | { | ||
160 | 41 | QList<QVariant> argumentList; | ||
161 | 42 | return asyncCallWithArgumentList(QLatin1String("Address"), argumentList); | ||
162 | 43 | } | ||
163 | 44 | |||
164 | 45 | inline QDBusPendingReply<QString> Path() | ||
165 | 46 | { | ||
166 | 47 | QList<QVariant> argumentList; | ||
167 | 48 | return asyncCallWithArgumentList(QLatin1String("Path"), argumentList); | ||
168 | 49 | } | ||
169 | 50 | |||
170 | 51 | Q_SIGNALS: // SIGNALS | ||
171 | 52 | }; | ||
172 | 53 | |||
173 | 54 | namespace org { | ||
174 | 55 | namespace ayatana { | ||
175 | 56 | namespace bamf { | ||
176 | 57 | typedef ::OrgAyatanaBamfIndicatorInterface indicator; | ||
177 | 58 | } | ||
178 | 59 | } | ||
179 | 60 | } | ||
180 | 61 | #endif | ||
181 | 0 | 62 | ||
182 | === added file 'bamf-indicator.cpp' | |||
183 | --- bamf-indicator.cpp 1970-01-01 00:00:00 +0000 | |||
184 | +++ bamf-indicator.cpp 2011-01-17 04:32:10 +0000 | |||
185 | @@ -0,0 +1,62 @@ | |||
186 | 1 | /* | ||
187 | 2 | * Copyright (C) 2010 Canonical, Ltd. | ||
188 | 3 | * | ||
189 | 4 | * Authors: | ||
190 | 5 | * Olivier Tilloy <olivier.tilloy@canonical.com> | ||
191 | 6 | * | ||
192 | 7 | * This library is free software; you can redistribute it and/or modify | ||
193 | 8 | * it under the terms of the GNU Lesser General Public License | ||
194 | 9 | * as published by the Free Software Foundation; version 3. | ||
195 | 10 | * | ||
196 | 11 | * This library is distributed in the hope that it will be useful, | ||
197 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
198 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
199 | 14 | * GNU Lesser General Public License for more details. | ||
200 | 15 | * | ||
201 | 16 | * You should have received a copy of the GNU Lesser General Public | ||
202 | 17 | * License along with this program. If not, see | ||
203 | 18 | * <http://www.gnu.org/licenses/>. | ||
204 | 19 | */ | ||
205 | 20 | |||
206 | 21 | #include "bamf-indicator.h" | ||
207 | 22 | #include "bamf-indicator-proxy.h" | ||
208 | 23 | #include "bamf-factory.h" | ||
209 | 24 | |||
210 | 25 | BamfIndicator::BamfIndicator(QString path) : | ||
211 | 26 | BamfView(path), m_indicator_proxy(NULL) | ||
212 | 27 | { | ||
213 | 28 | m_indicator_proxy = new OrgAyatanaBamfIndicatorInterface("org.ayatana.bamf", path, | ||
214 | 29 | QDBusConnection::sessionBus(), | ||
215 | 30 | static_cast<QObject*>(this)); | ||
216 | 31 | } | ||
217 | 32 | |||
218 | 33 | BamfIndicator::~BamfIndicator() | ||
219 | 34 | { | ||
220 | 35 | delete m_indicator_proxy; | ||
221 | 36 | } | ||
222 | 37 | |||
223 | 38 | const QString | ||
224 | 39 | BamfIndicator::address() const | ||
225 | 40 | { | ||
226 | 41 | QDBusPendingReply<QString> reply = m_indicator_proxy->Address(); | ||
227 | 42 | reply.waitForFinished(); | ||
228 | 43 | if (reply.isError()) { | ||
229 | 44 | qWarning() << reply.error(); | ||
230 | 45 | return QString(); | ||
231 | 46 | } else { | ||
232 | 47 | return reply.value(); | ||
233 | 48 | } | ||
234 | 49 | } | ||
235 | 50 | |||
236 | 51 | const QString | ||
237 | 52 | BamfIndicator::path() const | ||
238 | 53 | { | ||
239 | 54 | QDBusPendingReply<QString> reply = m_indicator_proxy->Path(); | ||
240 | 55 | reply.waitForFinished(); | ||
241 | 56 | if (reply.isError()) { | ||
242 | 57 | qWarning() << reply.error(); | ||
243 | 58 | return QString(); | ||
244 | 59 | } else { | ||
245 | 60 | return reply.value(); | ||
246 | 61 | } | ||
247 | 62 | } | ||
248 | 0 | 63 | ||
249 | === added file 'bamf-indicator.h' | |||
250 | --- bamf-indicator.h 1970-01-01 00:00:00 +0000 | |||
251 | +++ bamf-indicator.h 2011-01-17 04:32:10 +0000 | |||
252 | @@ -0,0 +1,55 @@ | |||
253 | 1 | /* | ||
254 | 2 | * Copyright (C) 2010 Canonical, Ltd. | ||
255 | 3 | * | ||
256 | 4 | * Authors: | ||
257 | 5 | * Florian Boucault <florian.boucault@canonical.com> | ||
258 | 6 | * | ||
259 | 7 | * This library is free software; you can redistribute it and/or modify | ||
260 | 8 | * it under the terms of the GNU Lesser General Public License | ||
261 | 9 | * as published by the Free Software Foundation; version 3. | ||
262 | 10 | * | ||
263 | 11 | * This library is distributed in the hope that it will be useful, | ||
264 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
265 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
266 | 14 | * GNU Lesser General Public License for more details. | ||
267 | 15 | * | ||
268 | 16 | * You should have received a copy of the GNU Lesser General Public | ||
269 | 17 | * License along with this program. If not, see | ||
270 | 18 | * <http://www.gnu.org/licenses/>. | ||
271 | 19 | */ | ||
272 | 20 | |||
273 | 21 | #ifndef QT_BAMF_INDICATOR_H | ||
274 | 22 | #define QT_BAMF_INDICATOR_H | ||
275 | 23 | |||
276 | 24 | #include <QtCore/QObject> | ||
277 | 25 | |||
278 | 26 | #include "bamf-view.h" | ||
279 | 27 | |||
280 | 28 | class OrgAyatanaBamfIndicatorInterface; | ||
281 | 29 | |||
282 | 30 | class BamfIndicator: public BamfView | ||
283 | 31 | { | ||
284 | 32 | Q_OBJECT | ||
285 | 33 | |||
286 | 34 | Q_PROPERTY(QString address READ address); | ||
287 | 35 | Q_PROPERTY(QString path READ path); | ||
288 | 36 | |||
289 | 37 | friend class BamfFactory; | ||
290 | 38 | |||
291 | 39 | private: | ||
292 | 40 | BamfIndicator(QString path); | ||
293 | 41 | ~BamfIndicator(); | ||
294 | 42 | BamfIndicator(BamfIndicator const&); | ||
295 | 43 | void operator=(BamfIndicator const&); | ||
296 | 44 | |||
297 | 45 | public: | ||
298 | 46 | // getters | ||
299 | 47 | const QString address() const; | ||
300 | 48 | const QString path() const; | ||
301 | 49 | |||
302 | 50 | private: | ||
303 | 51 | OrgAyatanaBamfIndicatorInterface *m_indicator_proxy; | ||
304 | 52 | }; | ||
305 | 53 | |||
306 | 54 | #endif | ||
307 | 55 | |||
308 | 0 | 56 | ||
309 | === modified file 'bamf-matcher.cpp' | |||
310 | --- bamf-matcher.cpp 2010-12-21 09:56:42 +0000 | |||
311 | +++ bamf-matcher.cpp 2011-01-17 04:32:10 +0000 | |||
312 | @@ -62,7 +62,7 @@ | |||
313 | 62 | return NULL; | 62 | return NULL; |
314 | 63 | 63 | ||
315 | 64 | BamfView *view = BamfFactory::get_default().view_for_path(path); | 64 | BamfView *view = BamfFactory::get_default().view_for_path(path); |
317 | 65 | return static_cast<BamfApplication *>(view); | 65 | return qobject_cast<BamfApplication *>(view); |
318 | 66 | } | 66 | } |
319 | 67 | } | 67 | } |
320 | 68 | 68 | ||
321 | @@ -80,7 +80,7 @@ | |||
322 | 80 | return NULL; | 80 | return NULL; |
323 | 81 | 81 | ||
324 | 82 | BamfView *view = BamfFactory::get_default().view_for_path(path); | 82 | BamfView *view = BamfFactory::get_default().view_for_path(path); |
326 | 83 | return static_cast<BamfWindow *>(view); | 83 | return qobject_cast<BamfWindow *>(view); |
327 | 84 | } | 84 | } |
328 | 85 | } | 85 | } |
329 | 86 | 86 | ||
330 | @@ -98,7 +98,7 @@ | |||
331 | 98 | return NULL; | 98 | return NULL; |
332 | 99 | 99 | ||
333 | 100 | BamfView *view = BamfFactory::get_default().view_for_path(path); | 100 | BamfView *view = BamfFactory::get_default().view_for_path(path); |
335 | 101 | return static_cast<BamfApplication *>(view); | 101 | return qobject_cast<BamfApplication *>(view); |
336 | 102 | } | 102 | } |
337 | 103 | } | 103 | } |
338 | 104 | 104 | ||
339 | @@ -127,7 +127,10 @@ | |||
340 | 127 | QStringList list = reply.value(); | 127 | QStringList list = reply.value(); |
341 | 128 | for (int i = 0; i < list.size(); ++i) { | 128 | for (int i = 0; i < list.size(); ++i) { |
342 | 129 | BamfView *view = BamfFactory::get_default().view_for_path(list.at(i)); | 129 | BamfView *view = BamfFactory::get_default().view_for_path(list.at(i)); |
344 | 130 | result.prepend(static_cast<BamfApplication *>(view)); | 130 | BamfApplication* application = qobject_cast<BamfApplication *>(view); |
345 | 131 | if (application != NULL) { | ||
346 | 132 | result.prepend(application); | ||
347 | 133 | } | ||
348 | 131 | } | 134 | } |
349 | 132 | } | 135 | } |
350 | 133 | return new BamfApplicationList(result); | 136 | return new BamfApplicationList(result); |
351 | @@ -145,7 +148,10 @@ | |||
352 | 145 | QStringList list = reply.value(); | 148 | QStringList list = reply.value(); |
353 | 146 | for (int i = 0; i < list.size(); ++i) { | 149 | for (int i = 0; i < list.size(); ++i) { |
354 | 147 | BamfView *view = BamfFactory::get_default().view_for_path(list.at(i)); | 150 | BamfView *view = BamfFactory::get_default().view_for_path(list.at(i)); |
356 | 148 | result.prepend(static_cast<BamfApplication *>(view)); | 151 | BamfApplication* application = qobject_cast<BamfApplication *>(view); |
357 | 152 | if (application != NULL) { | ||
358 | 153 | result.prepend(application); | ||
359 | 154 | } | ||
360 | 149 | } | 155 | } |
361 | 150 | } | 156 | } |
362 | 151 | return new BamfApplicationList(result); | 157 | return new BamfApplicationList(result); |
363 | @@ -156,8 +162,8 @@ | |||
364 | 156 | { | 162 | { |
365 | 157 | BamfView *former = BamfFactory::get_default().view_for_path(old_active); | 163 | BamfView *former = BamfFactory::get_default().view_for_path(old_active); |
366 | 158 | BamfView *current = BamfFactory::get_default().view_for_path(new_active); | 164 | BamfView *current = BamfFactory::get_default().view_for_path(new_active); |
369 | 159 | ActiveApplicationChanged(static_cast<BamfApplication *>(former), | 165 | ActiveApplicationChanged(qobject_cast<BamfApplication *>(former), |
370 | 160 | static_cast<BamfApplication *>(current)); | 166 | qobject_cast<BamfApplication *>(current)); |
371 | 161 | } | 167 | } |
372 | 162 | 168 | ||
373 | 163 | void | 169 | void |
374 | @@ -165,8 +171,8 @@ | |||
375 | 165 | { | 171 | { |
376 | 166 | BamfView *former = BamfFactory::get_default().view_for_path(old_active); | 172 | BamfView *former = BamfFactory::get_default().view_for_path(old_active); |
377 | 167 | BamfView *current = BamfFactory::get_default().view_for_path(new_active); | 173 | BamfView *current = BamfFactory::get_default().view_for_path(new_active); |
380 | 168 | ActiveWindowChanged(static_cast<BamfWindow *>(former), | 174 | ActiveWindowChanged(qobject_cast<BamfWindow *>(former), |
381 | 169 | static_cast<BamfWindow *>(current)); | 175 | qobject_cast<BamfWindow *>(current)); |
382 | 170 | } | 176 | } |
383 | 171 | 177 | ||
384 | 172 | void | 178 | void |
385 | 173 | 179 | ||
386 | === modified file 'bamf-plugin.cpp' | |||
387 | --- bamf-plugin.cpp 2011-01-13 17:57:36 +0000 | |||
388 | +++ bamf-plugin.cpp 2011-01-17 04:32:10 +0000 | |||
389 | @@ -27,6 +27,7 @@ | |||
390 | 27 | #include "bamf-view.h" | 27 | #include "bamf-view.h" |
391 | 28 | #include "bamf-application.h" | 28 | #include "bamf-application.h" |
392 | 29 | #include "bamf-window.h" | 29 | #include "bamf-window.h" |
393 | 30 | #include "bamf-indicator.h" | ||
394 | 30 | #include "bamf-control.h" | 31 | #include "bamf-control.h" |
395 | 31 | #include "bamf-matcher.h" | 32 | #include "bamf-matcher.h" |
396 | 32 | 33 | ||
397 | @@ -42,6 +43,7 @@ | |||
398 | 42 | qmlRegisterUncreatableType<BamfApplication>(uri, 0, 2, "BamfApplication", message); | 43 | qmlRegisterUncreatableType<BamfApplication>(uri, 0, 2, "BamfApplication", message); |
399 | 43 | qmlRegisterUncreatableType<BamfApplicationList>(uri, 0, 2, "BamfApplicationList", message); | 44 | qmlRegisterUncreatableType<BamfApplicationList>(uri, 0, 2, "BamfApplicationList", message); |
400 | 44 | qmlRegisterUncreatableType<BamfWindow>(uri, 0, 2, "BamfWindow", message); | 45 | qmlRegisterUncreatableType<BamfWindow>(uri, 0, 2, "BamfWindow", message); |
401 | 46 | qmlRegisterUncreatableType<BamfIndicator>(uri, 0, 2, "BamfIndicator", message); | ||
402 | 45 | qmlRegisterUncreatableType<BamfWindowList>(uri, 0, 2, "BamfWindowList", message); | 47 | qmlRegisterUncreatableType<BamfWindowList>(uri, 0, 2, "BamfWindowList", message); |
403 | 46 | qmlRegisterUncreatableType<BamfControl>(uri, 0, 2, "BamfControl", message); | 48 | qmlRegisterUncreatableType<BamfControl>(uri, 0, 2, "BamfControl", message); |
404 | 47 | qmlRegisterUncreatableType<BamfMatcher>(uri, 0, 2, "BamfMatcher", message); | 49 | qmlRegisterUncreatableType<BamfMatcher>(uri, 0, 2, "BamfMatcher", message); |
405 | 48 | 50 | ||
406 | === modified file 'bamf-window.cpp' | |||
407 | --- bamf-window.cpp 2010-12-21 09:56:42 +0000 | |||
408 | +++ bamf-window.cpp 2011-01-17 04:32:10 +0000 | |||
409 | @@ -47,7 +47,7 @@ | |||
410 | 47 | return NULL; | 47 | return NULL; |
411 | 48 | } else { | 48 | } else { |
412 | 49 | BamfView *view = BamfFactory::get_default().view_for_path(reply.value()); | 49 | BamfView *view = BamfFactory::get_default().view_for_path(reply.value()); |
414 | 50 | return static_cast<BamfWindow *>(view); | 50 | return qobject_cast<BamfWindow *>(view); |
415 | 51 | } | 51 | } |
416 | 52 | } | 52 | } |
417 | 53 | 53 |
From Ugo Riboni's previous review:
"""
Functionally it does its job, the crash disappears.
However I don't exactly understand *why* this MR fixes the issue, so I'm not sure I'm the most qualified to review this. Or perhaps some more comments in the code are in order ?
Anyway, please fix the (mostly style) issues below:
* The methods Address and Path in BamfIndicator should return QString() when failing, instead of NULL. tionChanged and OnActiveWindowC hanged in BamfMatcher
* In the BamfIndicator constructor, please align the arguments on the same line. The same for OnActiveApplica
"""