Merge lp:~ted/indicator-sound/lp1305902 into lp:indicator-sound/14.04

Proposed by Ted Gould
Status: Superseded
Proposed branch: lp:~ted/indicator-sound/lp1305902
Merge into: lp:indicator-sound/14.04
Diff against target: 26 lines (+10/-4)
1 file modified
src/accounts-service-user.vala (+10/-4)
To merge this branch: bzr merge lp:~ted/indicator-sound/lp1305902
Reviewer Review Type Date Requested Status
Charles Kerr (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+215690@code.launchpad.net

This proposal has been superseded by a proposal from 2014-06-11.

Commit message

Protect against icon serialization errors

Description of the change

The trace isn't entirely clear, but this seems like the most likely case of a null getting into build.

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
Charles Kerr (charlesk) wrote :

Okay, it took me a little bit but I agree this probably is the cause; the icon is the only place where g_variant_new_variant() is called. All the other calls to g_builder_add_variant() in the generated code look safe.

This is kind of a convoluted way to fix this, the lines immediately above have steps to create the same icon to handle icon == null. What about something like

> GLib.Variant serialized = null;
> if (this._player.icon != null)
> serialized = this._player.icon.serialize();
> if (serialized == null) {
> var icon = new ThemedIcon.with_default_fallbacks ("application-default-icon");
> serialized = icon.serialize();
> }
> this.proxy.player_icon = serialized;

lp:~ted/indicator-sound/lp1305902 updated
443. By Ted Gould

Unroll one more level of if statement

Revision history for this message
Ted Gould (ted) wrote :

Cyclomatic complexity reduced!

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

\o/

review: Approve

Unmerged revisions

443. By Ted Gould

Unroll one more level of if statement

442. By Ted Gould

Protect against icon serialization errors

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/accounts-service-user.vala'
2--- src/accounts-service-user.vala 2014-03-21 21:35:59 +0000
3+++ src/accounts-service-user.vala 2014-04-22 15:17:30 +0000
4@@ -58,13 +58,19 @@
5 } else {
6 this.proxy.timestamp = GLib.get_monotonic_time();
7 this.proxy.player_name = this._player.name;
8- if (this._player.icon == null) {
9+
10+ /* Serialize the icon if it exits, if it doesn't or errors then
11+ we need to use the application default icon */
12+ GLib.Variant? icon_serialization = null;
13+ if (this._player.icon != null)
14+ icon_serialization = this._player.icon.serialize();
15+ if (icon_serialization == null) {
16 var icon = new ThemedIcon.with_default_fallbacks ("application-default-icon");
17- this.proxy.player_icon = icon.serialize();
18- } else {
19- this.proxy.player_icon = this._player.icon.serialize();
20+ icon_serialization = icon.serialize();
21 }
22+ this.proxy.player_icon = icon_serialization;
23
24+ /* Set state of the player */
25 this.proxy.running = this._player.is_running;
26 this.proxy.state = this._player.state;
27

Subscribers

People subscribed via source and target branches