Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9c00bb23 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "viewcapture: fix NPE (WindowListener#mRoot)" into main

parents e788cae6 b835d283
Loading
Loading
Loading
Loading
+11 −6
Original line number Diff line number Diff line
@@ -161,10 +161,13 @@ public abstract class ViewCapture {
    public void stopCapture(@NonNull View rootView) {
        mListeners.forEach(it -> {
            if (rootView == it.mRoot) {
                runOnUiThread(() -> it.mRoot.getViewTreeObserver().removeOnDrawListener(it),
                        it.mRoot);
                runOnUiThread(() -> {
                    if (it.mRoot != null) {
                        it.mRoot.getViewTreeObserver().removeOnDrawListener(it);
                        it.mRoot = null;
                    }
                }, it.mRoot);
            }
        });
    }

@@ -494,9 +497,11 @@ public abstract class ViewCapture {
        @AnyThread
        void detachFromRoot() {
            mIsActive = false;
            runOnUiThread(() -> {
                if (mRoot != null) {
                runOnUiThread(() -> mRoot.getViewTreeObserver().removeOnDrawListener(this), mRoot);
                    mRoot.getViewTreeObserver().removeOnDrawListener(this);
                }
            }, mRoot);
        }

        @UiThread