From: Damyan Ivanov Date: Thu, 25 Nov 2021 20:59:08 +0000 (+0000) Subject: cope with no $idler right after idle is done X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=f5de4154d0110183daa442faefa4c746a14a7023;p=mpd-feeder.git cope with no $idler right after idle is done might be undef'd by an event handler --- diff --git a/lib/App/MPD/Feeder.pm b/lib/App/MPD/Feeder.pm index 8561cf8..36bf29d 100644 --- a/lib/App/MPD/Feeder.pm +++ b/lib/App/MPD/Feeder.pm @@ -346,23 +346,25 @@ method pulse { $log->trace('got out of idle'); - if ( $idler->is_done ) { - my $result = $idler->get; - undef $idler; - if ( ref $result and $result->{changed} ) { - my $changed = $result->{changed}; - $changed = [$changed] unless ref $changed; - - $mpd->emit($_) for @$changed; + if ($idler) { + if ( $idler->is_done ) { + my $result = $idler->get; + undef $idler; + if ( ref $result and $result->{changed} ) { + my $changed = $result->{changed}; + $changed = [$changed] unless ref $changed; + + $mpd->emit($_) for @$changed; + } + } + elsif ( $idler->is_cancelled ) { + $log->trace("idle was cancelled"); + undef $idler; + } + elsif ( $idler->is_failed ) { + $log->warn("idle failed: ".$idler->failure); + undef $idler; } - } - elsif ( $idler->is_cancelled ) { - $log->trace("idle was cancelled"); - undef $idler; - } - elsif ( $idler->is_failed ) { - $log->warn("idle failed: ".$idler->failure); - undef $idler; } $mpd->loop->stop;