From 7c9ef58acd0971ef47c78f4d3247d388991044bc Mon Sep 17 00:00:00 2001 From: Stypox Date: Thu, 25 Jul 2019 12:32:56 +0200 Subject: [PATCH] Fix crash when closing a not-yet-loaded popup. --- .../main/java/org/schabi/newpipe/player/BasePlayer.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java b/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java index 11434b29d..46e7c1fdc 100644 --- a/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java @@ -288,8 +288,11 @@ public abstract class BasePlayer implements if (item != null && item.getRecoveryPosition() == PlayQueueItem.RECOVERY_UNSET && isPlaybackResumeEnabled()) { final Disposable stateLoader = recordManager.loadStreamState(item) .observeOn(AndroidSchedulers.mainThread()) - .doFinally(() -> initPlayback(queue, repeatMode, playbackSpeed, playbackPitch, playbackSkipSilence, - /*playOnInit=*/true)) + .doFinally(() -> { + if (simpleExoPlayer == null) return; // doFinally called while closing + initPlayback(queue, repeatMode, playbackSpeed, playbackPitch, playbackSkipSilence, + /*playOnInit=*/true); + }) .subscribe( state -> queue.setRecovery(queue.getIndex(), state.getProgressTime()), error -> { @@ -331,6 +334,7 @@ public abstract class BasePlayer implements simpleExoPlayer.removeListener(this); simpleExoPlayer.stop(); simpleExoPlayer.release(); + simpleExoPlayer = null; } if (isProgressLoopRunning()) stopProgressLoop(); if (playQueue != null) playQueue.dispose();