From bec2ac1a3d1420d552a7f5ef270b5768185bf982 Mon Sep 17 00:00:00 2001 From: Raphael Date: Thu, 8 Dec 2011 14:12:15 -0800 Subject: SDK Manager: fix SWTException disposed when closing during a download. SDK Bug: 21312 Change-Id: I49462d9750c4f64f92372793dee65d28f23e94ab --- .../internal/repository/sdkman2/PackagesPage.java | 36 ++++++++++++---------- 1 file changed, 20 insertions(+), 16 deletions(-) (limited to 'sdkmanager') diff --git a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PackagesPage.java b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PackagesPage.java index 00315e2..c3b3568 100755 --- a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PackagesPage.java +++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/internal/repository/sdkman2/PackagesPage.java @@ -992,22 +992,26 @@ public class PackagesPage extends UpdaterPage * Updates the Install and Delete Package buttons. */ private void updateButtonsState() { - int numPackages = getArchivesForInstall(null /*archives*/); - - mButtonInstall.setEnabled((numPackages > 0) && !mOperationPending); - mButtonInstall.setText( - numPackages == 0 ? "Install packages..." : // disabled button case - numPackages == 1 ? "Install 1 package..." : - String.format("Install %d packages...", numPackages)); - - // We can only delete local archives - numPackages = getArchivesToDelete(null /*outMsg*/, null /*outArchives*/); - - mButtonDelete.setEnabled((numPackages > 0) && !mOperationPending); - mButtonDelete.setText( - numPackages == 0 ? "Delete packages..." : // disabled button case - numPackages == 1 ? "Delete 1 package..." : - String.format("Delete %d packages...", numPackages)); + if (!mButtonInstall.isDisposed()) { + int numPackages = getArchivesForInstall(null /*archives*/); + + mButtonInstall.setEnabled((numPackages > 0) && !mOperationPending); + mButtonInstall.setText( + numPackages == 0 ? "Install packages..." : // disabled button case + numPackages == 1 ? "Install 1 package..." : + String.format("Install %d packages...", numPackages)); + } + + if (!mButtonDelete.isDisposed()) { + // We can only delete local archives + int numPackages = getArchivesToDelete(null /*outMsg*/, null /*outArchives*/); + + mButtonDelete.setEnabled((numPackages > 0) && !mOperationPending); + mButtonDelete.setText( + numPackages == 0 ? "Delete packages..." : // disabled button case + numPackages == 1 ? "Delete 1 package..." : + String.format("Delete %d packages...", numPackages)); + } } /** -- cgit v1.1