$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;