1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

[202109] Fixed a bug in the update modes cache which caused occasional invalid updates.

This commit is contained in:
Pawel Piech 2008-02-15 19:50:57 +00:00
parent 9dc357f09b
commit d088dbc842
3 changed files with 27 additions and 6 deletions

View file

@ -319,7 +319,12 @@ public class DefaultVMContentProviderStrategy implements IElementContentProvider
elementsMultiRequestMon.add(new DataRequestMonitor<List<Object>>(getVMProvider().getExecutor(), null) { elementsMultiRequestMon.add(new DataRequestMonitor<List<Object>>(getVMProvider().getExecutor(), null) {
@Override @Override
protected void handleCompleted() { protected void handleCompleted() {
if (getStatus().isOK()) { // Workaround for a bug caused by an optimization in the viewer:
// The viewer may request more children then there are at a given level.
// This caues the update to return with an error.
// See https://bugs.eclipse.org/bugs/show_bug.cgi?id=202109
// Instead of checking getStatus().isOK(), check getData() != null.
if (getData() != null) {
for (int i = 0; i < elementsLength; i++) { for (int i = 0; i < elementsLength; i++) {
update.setChild(getData().get(i), elementsStartIdx + nodeStartIdx + i); update.setChild(getData().get(i), elementsStartIdx + nodeStartIdx + i);
} }

View file

@ -173,7 +173,12 @@ public class VMViewerUpdate implements IViewerUpdate {
fRequestMonitor.setStatus(new Status( IStatus.CANCEL, DsfUIPlugin.PLUGIN_ID," Update was cancelled") ); //$NON-NLS-1$ fRequestMonitor.setStatus(new Status( IStatus.CANCEL, DsfUIPlugin.PLUGIN_ID," Update was cancelled") ); //$NON-NLS-1$
} }
fRequestMonitor.done(); fRequestMonitor.done();
} catch (RejectedExecutionException e) { // Ignore } catch (RejectedExecutionException e) {
// If the request monitor cannot be invoked still, try to complete the update to avoid
// leaving the viewer in an inconsistent state.
if (fClientUpdate != null) {
fClientUpdate.done();
}
} }
} }

View file

@ -356,6 +356,11 @@ public class AbstractCachingVMProvider extends AbstractVMProvider implements ICa
@Override @Override
protected void handleCompleted() protected void handleCompleted()
{ {
// Workaround for a bug caused by an optimization in the viewer:
// The viewer may request more children then there are at a given level.
// This caues the update to return with an error.
// See https://bugs.eclipse.org/bugs/show_bug.cgi?id=202109
// Instead of checking getStatus().isOK(), check getData() != null.
if(getData() != null) { if(getData() != null) {
// Check if the udpate retrieved all children by specifying "offset = -1, length = -1" // Check if the udpate retrieved all children by specifying "offset = -1, length = -1"
int updateOffset = update.getOffset(); int updateOffset = update.getOffset();
@ -404,7 +409,16 @@ public class AbstractCachingVMProvider extends AbstractVMProvider implements ICa
for (int i = update.getOffset(); i < update.getOffset() + update.getLength(); i++) { for (int i = update.getOffset(); i < update.getOffset() + update.getLength(); i++) {
childrenMissingFromCache.add(i); childrenMissingFromCache.add(i);
} }
childrenMissingFromCache.removeAll(entry.fChildren.keySet());
// Fill in the known children from cache.
for(int position = update.getOffset(); position < update.getOffset() + update.getLength(); position++) {
Object child = entry.fChildren.get(position);
if (child != null) {
update.setChild(entry.fChildren.get(position), position);
} else {
childrenMissingFromCache.remove(position);
}
}
if (childrenMissingFromCache.size() > 0) { if (childrenMissingFromCache.size() > 0) {
// perform a partial update; we only have some of the children of the update request // perform a partial update; we only have some of the children of the update request
@ -445,9 +459,6 @@ public class AbstractCachingVMProvider extends AbstractVMProvider implements ICa
multiRm.setDoneCount(partialUpdates.size()); multiRm.setDoneCount(partialUpdates.size());
} else { } else {
// we have all of the children in cache; return from cache // we have all of the children in cache; return from cache
for(int position = update.getOffset(); position < update.getOffset() + update.getLength(); position++) {
update.setChild(entry.fChildren.get(position), position);
}
update.done(); update.done();
} }
} }