packages/apps/Launcher
修订版 | f3fe9030b6f729782c52d4d7c47757ffefa0a771 (tree) |
---|---|
时间 | 2010-04-18 01:09:16 |
作者 | chrisrl <chris+android@zent...> |
Commiter | Chih-Wei Huang |
Fix a race condition that caused the Launcher to be blank when triggered.
@@ -541,10 +541,12 @@ public class LauncherModel { | ||
541 | 541 | launcher.runOnUiThread(action); |
542 | 542 | } |
543 | 543 | |
544 | - if (!mStopped) { | |
545 | - mApplicationsLoaded = true; | |
546 | - } else { | |
547 | - if (DEBUG_LOADERS) d(LOG_TAG, " ----> applications loader stopped (" + mId + ")"); | |
544 | + synchronized(LauncherModel.this) { | |
545 | + if (!mStopped) { | |
546 | + mApplicationsLoaded = true; | |
547 | + } else { | |
548 | + if (DEBUG_LOADERS) d(LOG_TAG, " ----> applications loader stopped (" + mId + ")"); | |
549 | + } | |
548 | 550 | } |
549 | 551 | mRunning = false; |
550 | 552 | } |
@@ -951,40 +953,42 @@ public class LauncherModel { | ||
951 | 953 | c.close(); |
952 | 954 | } |
953 | 955 | |
954 | - if (!mStopped) { | |
955 | - if (DEBUG_LOADERS) { | |
956 | - d(LOG_TAG, " --> done loading workspace"); | |
957 | - d(LOG_TAG, " ----> worskpace items=" + desktopItems.size()); | |
958 | - d(LOG_TAG, " ----> worskpace widgets=" + desktopAppWidgets.size()); | |
959 | - } | |
956 | + synchronized(LauncherModel.this) { | |
957 | + if (!mStopped) { | |
958 | + if (DEBUG_LOADERS) { | |
959 | + d(LOG_TAG, " --> done loading workspace"); | |
960 | + d(LOG_TAG, " ----> worskpace items=" + desktopItems.size()); | |
961 | + d(LOG_TAG, " ----> worskpace widgets=" + desktopAppWidgets.size()); | |
962 | + } | |
960 | 963 | |
961 | - // Create a copy of the lists in case the workspace loader is restarted | |
962 | - // and the list are cleared before the UI can go through them | |
963 | - final ArrayList<ItemInfo> uiDesktopItems = | |
964 | - new ArrayList<ItemInfo>(desktopItems); | |
965 | - final ArrayList<LauncherAppWidgetInfo> uiDesktopWidgets = | |
966 | - new ArrayList<LauncherAppWidgetInfo>(desktopAppWidgets); | |
964 | + // Create a copy of the lists in case the workspace loader is restarted | |
965 | + // and the list are cleared before the UI can go through them | |
966 | + final ArrayList<ItemInfo> uiDesktopItems = | |
967 | + new ArrayList<ItemInfo>(desktopItems); | |
968 | + final ArrayList<LauncherAppWidgetInfo> uiDesktopWidgets = | |
969 | + new ArrayList<LauncherAppWidgetInfo>(desktopAppWidgets); | |
970 | + | |
971 | + if (!mStopped) { | |
972 | + d(LOG_TAG, " ----> items cloned, ready to refresh UI"); | |
973 | + launcher.runOnUiThread(new Runnable() { | |
974 | + public void run() { | |
975 | + if (DEBUG_LOADERS) d(LOG_TAG, " ----> onDesktopItemsLoaded()"); | |
976 | + launcher.onDesktopItemsLoaded(uiDesktopItems, uiDesktopWidgets); | |
977 | + } | |
978 | + }); | |
979 | + } | |
967 | 980 | |
968 | - if (!mStopped) { | |
969 | - d(LOG_TAG, " ----> items cloned, ready to refresh UI"); | |
970 | - launcher.runOnUiThread(new Runnable() { | |
971 | - public void run() { | |
972 | - if (DEBUG_LOADERS) d(LOG_TAG, " ----> onDesktopItemsLoaded()"); | |
973 | - launcher.onDesktopItemsLoaded(uiDesktopItems, uiDesktopWidgets); | |
981 | + if (mLoadApplications) { | |
982 | + if (DEBUG_LOADERS) { | |
983 | + d(LOG_TAG, " ----> loading applications from workspace loader"); | |
974 | 984 | } |
975 | - }); | |
976 | - } | |
977 | - | |
978 | - if (mLoadApplications) { | |
979 | - if (DEBUG_LOADERS) { | |
980 | - d(LOG_TAG, " ----> loading applications from workspace loader"); | |
985 | + startApplicationsLoader(launcher, mIsLaunching); | |
981 | 986 | } |
982 | - startApplicationsLoader(launcher, mIsLaunching); | |
983 | - } | |
984 | 987 | |
985 | - mDesktopItemsLoaded = true; | |
986 | - } else { | |
987 | - if (DEBUG_LOADERS) d(LOG_TAG, " ----> worskpace loader was stopped"); | |
988 | + mDesktopItemsLoaded = true; | |
989 | + } else { | |
990 | + if (DEBUG_LOADERS) d(LOG_TAG, " ----> worskpace loader was stopped"); | |
991 | + } | |
988 | 992 | } |
989 | 993 | mRunning = false; |
990 | 994 | } |