Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCurtis Windatt2007-05-09 20:25:43 +0000
committerCurtis Windatt2007-05-09 20:25:43 +0000
commit25249f0e9eebfd5031323e676cfdea5b3e84edb7 (patch)
tree11ca47c475637dca7df7110a91a1ecda5724898c /org.eclipse.debug.ui
parent1a074f88b7e379c8bbc08c2d848904cacf1e0cb3 (diff)
downloadeclipse.platform.debug-25249f0e9eebfd5031323e676cfdea5b3e84edb7.tar.gz
eclipse.platform.debug-25249f0e9eebfd5031323e676cfdea5b3e84edb7.tar.xz
eclipse.platform.debug-25249f0e9eebfd5031323e676cfdea5b3e84edb7.zip
Bug 184902 - Timing problem in variables views' expansion state save/restore logic.
Diffstat (limited to 'org.eclipse.debug.ui')
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ModelContentProvider.java67
1 files changed, 64 insertions, 3 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ModelContentProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ModelContentProvider.java
index 6848ab770..fe897f1d5 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ModelContentProvider.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ModelContentProvider.java
@@ -14,10 +14,12 @@ import java.io.IOException;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.Map.Entry;
import org.eclipse.core.runtime.IAdaptable;
@@ -103,6 +105,16 @@ abstract class ModelContentProvider implements IContentProvider, IModelChangedLi
private ModelDelta fPendingState = null;
/**
+ * Set of IMementoManager's that are currently saving state
+ */
+ private Set fPendingStateSaves = new HashSet();
+
+ /**
+ * Used to queue a viewer input for state restore
+ */
+ private Object fQueuedRestore = null;
+
+ /**
* Used to determine when restoration delta has been processed
*/
class CheckState implements IModelDeltaVisitor {
@@ -221,12 +233,26 @@ abstract class ModelContentProvider implements IContentProvider, IModelChangedLi
}
/**
- * Restores viewer state for the new input
- *
- * @param newInput
+ * Restores the viewer state unless a save is taking place. If a save is
+ * taking place, the restore is queued.
+ * @param input viewer input
*/
protected synchronized void restoreViewerState(final Object input) {
fPendingState = null;
+ if (isSavingState()) {
+ fQueuedRestore = input;
+ } else {
+ startRestoreViewerState(input);
+ }
+ }
+
+ /**
+ * Restores viewer state for the given input
+ *
+ * @param input viewer input
+ */
+ private synchronized void startRestoreViewerState(final Object input) {
+ fPendingState = null;
final IElementMementoProvider defaultProvider = getViewerStateAdapter(input);
if (defaultProvider != null) {
// build a model delta representing expansion and selection state
@@ -388,6 +414,7 @@ abstract class ModelContentProvider implements IContentProvider, IModelChangedLi
} catch (IOException e) {
DebugUIPlugin.log(e);
}
+ stateSaveComplete(this);
}
} else {
abort = true;
@@ -397,6 +424,7 @@ abstract class ModelContentProvider implements IContentProvider, IModelChangedLi
req.cancel();
}
requests.clear();
+ stateSaveComplete(this);
}
}
}
@@ -431,8 +459,41 @@ abstract class ModelContentProvider implements IContentProvider, IModelChangedLi
}
};
rootDelta.accept(visitor);
+ stateSaveStarted(manager);
manager.processReqeusts();
}
+
+ /**
+ * Called when a state save is starting.
+ *
+ * @param manager
+ */
+ private synchronized void stateSaveStarted(IMementoManager manager) {
+ fPendingStateSaves.add(manager);
+ }
+
+ /**
+ * Called when a state save is complete.
+ *
+ * @param manager
+ */
+ private synchronized void stateSaveComplete(IMementoManager manager) {
+ fPendingStateSaves.remove(manager);
+ if (fQueuedRestore != null) {
+ Object temp = fQueuedRestore;
+ fQueuedRestore = null;
+ restoreViewerState(temp);
+ }
+ }
+
+ /**
+ * Returns whether any state saving is in progress.
+ *
+ * @return whether any state saving is in progress
+ */
+ private synchronized boolean isSavingState() {
+ return !fPendingStateSaves.isEmpty();
+ }
/**
* Builds a delta with the given root delta for expansion/selection state.

Back to the top