From 8df9168f5587cfd31e0bf6a4170a4c4f9784dbb7 Mon Sep 17 00:00:00 2001 From: Robert Tari Date: Tue, 9 Mar 2021 00:32:56 +0100 Subject: Avoid possible null value --- src/media-player-list-greeter.vala | 9 +++++++-- src/media-player-user.vala | 21 ++++++++++++++++++--- 2 files changed, 25 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/media-player-list-greeter.vala b/src/media-player-list-greeter.vala index fb57597..1357e38 100644 --- a/src/media-player-list-greeter.vala +++ b/src/media-player-list-greeter.vala @@ -45,8 +45,13 @@ public class MediaPlayerListGreeter : MediaPlayerList { this.proxy.entry_selected.connect(active_user_changed); this.proxy.get_active_entry.begin ((obj, res) => { try { - var value = (obj as AyatanaGreeterList).get_active_entry.end(res); - active_user_changed(value); + var list = (obj as AyatanaGreeterList); + + if (list != null) + { + var value = list.get_active_entry.end(res); + active_user_changed(value); + } } catch (Error e) { warning("Unable to get active entry: %s", e.message); } diff --git a/src/media-player-user.vala b/src/media-player-user.vala index 3cc90a0..ee31537 100644 --- a/src/media-player-user.vala +++ b/src/media-player-user.vala @@ -238,7 +238,12 @@ public class MediaPlayerUser : MediaPlayer { if (this.greeter != null) { this.greeter.RequestSoundPlayPause.begin(this.username, (obj, res) => { try { - (obj as GreeterBroadcast).RequestSoundPlayPause.end(res); + var broadcasts = (obj as GreeterBroadcast); + + if (broadcasts != null) + { + broadcasts.RequestSoundPlayPause.end(res); + } } catch (Error e) { warning("Unable to send play pause: %s", e.message); } @@ -253,7 +258,12 @@ public class MediaPlayerUser : MediaPlayer { if (this.greeter != null) { this.greeter.RequestSoundNext.begin(this.username, (obj, res) => { try { - (obj as GreeterBroadcast).RequestSoundNext.end(res); + var broadcasts = (obj as GreeterBroadcast); + + if (broadcasts != null) + { + broadcasts.RequestSoundNext.end(res); + } } catch (Error e) { warning("Unable to send next: %s", e.message); } @@ -268,7 +278,12 @@ public class MediaPlayerUser : MediaPlayer { if (this.greeter != null) { this.greeter.RequestSoundPrev.begin(this.username, (obj, res) => { try { - (obj as GreeterBroadcast).RequestSoundPrev.end(res); + var broadcasts = (obj as GreeterBroadcast); + + if (broadcasts != null) + { + broadcasts.RequestSoundPrev.end(res); + } } catch (Error e) { warning("Unable to send previous: %s", e.message); } -- cgit v1.2.3