From 05bf644e371c9d965ba864cf7dda6515c7cdce91 Mon Sep 17 00:00:00 2001 From: Michael Jurka Date: Wed, 30 Nov 2011 20:28:53 -0800 Subject: [PATCH] Fix memory leak in Launcher Leak happened when a stack view was on the workspace and then workspace forced a rebind of its items (for example, when an app was installed) Bug # 5629171 --- src/com/android/launcher2/Launcher.java | 1 + src/com/android/launcher2/LauncherModel.java | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java index f9c7bf070f..864fca5bec 100644 --- a/src/com/android/launcher2/Launcher.java +++ b/src/com/android/launcher2/Launcher.java @@ -2920,6 +2920,7 @@ public final class Launcher extends Activity final CellLayout layoutParent = (CellLayout) workspace.getChildAt(i); layoutParent.removeAllViewsInLayout(); } + mWidgetsToAdvance.clear(); if (mHotseat != null) { mHotseat.resetLayout(); } diff --git a/src/com/android/launcher2/LauncherModel.java b/src/com/android/launcher2/LauncherModel.java index e2ddf1b49c..7da55db6d7 100644 --- a/src/com/android/launcher2/LauncherModel.java +++ b/src/com/android/launcher2/LauncherModel.java @@ -176,12 +176,16 @@ public class LauncherModel extends BroadcastReceiver { // Ensure that we don't use the same workspace items data structure on the main thread // by making a copy of workspace items first. final ArrayList workspaceItems = new ArrayList(sWorkspaceItems); + final ArrayList appWidgets = new ArrayList(sAppWidgets); mHandler.post(new Runnable() { @Override public void run() { for (ItemInfo item : workspaceItems) { item.unbind(); } + for (ItemInfo item : appWidgets) { + item.unbind(); + } } }); @@ -1229,7 +1233,6 @@ public class LauncherModel extends BroadcastReceiver { } }); - // Unbind previously bound workspace items to prevent a leak of AppWidgetHostViews. final ArrayList workspaceItems = unbindWorkspaceItemsOnMainThread(); // Add the items to the workspace.