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

Commit df9fc63e authored by Winson Chung's avatar Winson Chung
Browse files

Clean up some more refs to thumbnail data

- Always return a copy of the task list to ensure that the model doesn't
  hold refs to the thumbnail data if it was loaded into the same task
- Always clear the task thumbnail data ref once the visibility of the
  task view changes to be invisible

Bug: 132309376
Test: Enter overview scroll to the end of the list, relaunch app and take
      heap dump

Change-Id: I4437fd30172a5fe2a78c111f780163a1e6bbbb54
parent a90531cd
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -368,6 +368,9 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable {
        } else {
            mSnapshotView.setThumbnail(null, null);
            setIcon(null);
            // Reset the task thumbnail reference as well (it will be fetched from the cache or
            // reloaded next time we need it)
            mTask.thumbnail = null;
        }
    }

@@ -488,9 +491,6 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable {
        mSnapshotView.setThumbnail(mTask, null);
        setOverlayEnabled(false);
        onTaskListVisibilityChanged(false);
        if (mTask != null) {
            mTask.thumbnail = null;
        }
    }

    @Override
+11 −1
Original line number Diff line number Diff line
@@ -84,7 +84,7 @@ public class RecentTasksList extends TaskStackChangeListener {
        final int requestLoadId = mChangeId;
        Runnable resultCallback = callback == null
                ? () -> { }
                : () -> callback.accept(mTasks);
                : () -> callback.accept(copyOf(mTasks));

        if (mLastLoadedId == mChangeId && (!mLastLoadHadKeysOnly || loadKeysOnly)) {
            // The list is up to date, callback with the same list
@@ -183,4 +183,14 @@ public class RecentTasksList extends TaskStackChangeListener {

        return allTasks;
    }

    private ArrayList<Task> copyOf(ArrayList<Task> tasks) {
        ArrayList<Task> newTasks = new ArrayList<>();
        for (int i = 0; i < tasks.size(); i++) {
            Task t = tasks.get(i);
            newTasks.add(new Task(t.key, t.colorPrimary, t.colorBackground, t.isDockable,
                    t.isLocked, t.taskDescription, t.topActivity));
        }
        return newTasks;
    }
}
 No newline at end of file