diff options
author | Karsten Thoms | 2018-03-20 05:12:19 +0000 |
---|---|---|
committer | Leo Ufimtsev | 2018-03-27 15:05:53 +0000 |
commit | b72ec4ee4a25b3b62b1cea617c5fcc5fd2549359 (patch) | |
tree | 7dbfdc774e660c0951ec2dc77ad27f941624b410 | |
parent | a95e8a2b264972bbb609d56159553818ea82399f (diff) | |
download | eclipse.platform.swt-b72ec4ee4a25b3b62b1cea617c5fcc5fd2549359.tar.gz eclipse.platform.swt-b72ec4ee4a25b3b62b1cea617c5fcc5fd2549359.tar.xz eclipse.platform.swt-b72ec4ee4a25b3b62b1cea617c5fcc5fd2549359.zip |
Bug 532632 - showWhile(): add disposal check
Also changed for-loops to extended for-loop.
Change-Id: Ia196bed55553639d1853d871aaf1d5805e03faf8
Signed-off-by: Karsten Thoms <karsten.thoms@itemis.de>
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/BusyIndicator.java | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/BusyIndicator.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/BusyIndicator.java index ba5b7a3d52..1690e460ff 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/BusyIndicator.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/BusyIndicator.java @@ -11,6 +11,8 @@ package org.eclipse.swt.custom; +import java.util.*; + import org.eclipse.swt.*; import org.eclipse.swt.graphics.*; import org.eclipse.swt.widgets.*; @@ -57,26 +59,23 @@ public static void showWhile(Display display, Runnable runnable) { Integer busyId = Integer.valueOf(nextBusyId); nextBusyId++; Cursor cursor = display.getSystemCursor(SWT.CURSOR_WAIT); - Shell[] shells = display.getShells(); - for (int i = 0; i < shells.length; i++) { - Integer id = (Integer)shells[i].getData(BUSYID_NAME); - if (id == null) { - shells[i].setCursor(cursor); - shells[i].setData(BUSYID_NAME, busyId); - } - } + + Arrays.stream(display.getShells()) + .filter(shell -> !shell.isDisposed() && shell.getData(BUSYID_NAME) == null) + .forEach(shell -> { + shell.setCursor(cursor); + shell.setData(BUSYID_NAME, busyId); + }); try { runnable.run(); } finally { - shells = display.getShells(); - for (int i = 0; i < shells.length; i++) { - Integer id = (Integer)shells[i].getData(BUSYID_NAME); - if (id == busyId) { - shells[i].setCursor(null); - shells[i].setData(BUSYID_NAME, null); - } - } + Arrays.stream(display.getShells()) + .filter(shell -> !shell.isDisposed() && shell.getData(BUSYID_NAME) == busyId) + .forEach(shell -> { + shell.setCursor(null); + shell.setData(BUSYID_NAME, null); + }); } } } |