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

Proposed by Ted Gould
Status: Merged
Approved by: Charles Kerr
Approved revision: 443
Merged at revision: 444
Proposed branch: lp:~ted/indicator-sound/lp1305902
Merge into: lp:indicator-sound/14.10
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+222812@code.launchpad.net

This proposal supersedes a proposal from 2014-04-14.

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 : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
Charles Kerr (charlesk) wrote : Posted in a previous version of this proposal

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;

Revision history for this message
Ted Gould (ted) wrote : Posted in a previous version of this proposal

Cyclomatic complexity reduced!

Revision history for this message
Charles Kerr (charlesk) wrote : Posted in a previous version of this proposal

\o/

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

Resubmitted to 14.10

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Charles Kerr (charlesk) :
review: Approve

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-06-11 14:56:19 +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