diff options
| author | Andrey Loskutov | 2016-06-09 19:31:38 +0000 |
|---|---|---|
| committer | Andrey Loskutov | 2016-06-11 21:40:01 +0000 |
| commit | 2c81696b9663068043a850fd9278fff5e0d03804 (patch) | |
| tree | d41faa555a4ae6f9e31a23416e90535879d32b6e | |
| parent | a18b0584902a63a7a9173e73298dfb41fe53aa6f (diff) | |
| download | eclipse.platform.ui-2c81696b9663068043a850fd9278fff5e0d03804.tar.gz eclipse.platform.ui-2c81696b9663068043a850fd9278fff5e0d03804.tar.xz eclipse.platform.ui-2c81696b9663068043a850fd9278fff5e0d03804.zip | |
Bug 470076 - The save dialog appears twice when exiting eclipse
Change-Id: I1f616b4696ff0f0ba3a67e06fa5504ea6fd870fb
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
| -rw-r--r-- | bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java | 38 |
1 files changed, 30 insertions, 8 deletions
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java index 2c9a500f020..afa914a6bb8 100644 --- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java +++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java @@ -33,9 +33,11 @@ import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.List; import java.util.ListIterator; +import java.util.Map; import java.util.Set; import java.util.WeakHashMap; import javax.annotation.PostConstruct; @@ -3605,7 +3607,7 @@ public class WorkbenchPage implements IWorkbenchPage { IWorkbenchPart part = reference.getPart(false); ISaveablePart saveable = SaveableHelper.getSaveable(part); - if (saveable != null) { + if (saveable != null && !result.contains(saveable)) { if (saveable.isDirty()) { result.add(saveable); } @@ -3616,21 +3618,41 @@ public class WorkbenchPage implements IWorkbenchPage { /** * @return workbench parts which are dirty (implement or adapt to - * {@link ISaveablePart}) + * {@link ISaveablePart}). Only parts matching different saveables + * are returned. */ public IWorkbenchPart[] getDirtyWorkbenchParts() { List<IWorkbenchPart> result = new ArrayList<>(3); + Map<ISaveablePart, IWorkbenchPart> saveables = new LinkedHashMap<>(3); IWorkbenchPartReference[] allParts = getSortedParts(true, true, true); - for (int i = 0; i < allParts.length; i++) { - IWorkbenchPartReference reference = allParts[i]; - + for (IWorkbenchPartReference reference : allParts) { IWorkbenchPart part = reference.getPart(false); ISaveablePart saveable = SaveableHelper.getSaveable(part); - if (saveable != null) { - if (saveable.isDirty()) { - result.add(part); + if (saveable == null || !saveable.isDirty()) { + continue; + } + IWorkbenchPart previousPart = saveables.get(saveable); + if (previousPart != null) { + // We have already a part claiming to handle this saveable. + // See bug 470076 where a property view might return + // saveable which is in turn just editor part + if (previousPart == saveable) { + // if the previous part matches saveable, we have a + // perfect match already + continue; + } + // if parts provide adapters to same saveable but + // saveable itself is not a part, we can try to keep + // editors and skip views + if (part != saveable && previousPart instanceof IEditorPart) { + continue; } + // last part wins, since we don't want to return multiple parts + // representing same saveables + result.remove(previousPart); } + result.add(part); + saveables.put(saveable, part); } return result.toArray(new IWorkbenchPart[result.size()]); } |
