Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(396)

Unified Diff: runtime/lib/lib_prefix.dart

Issue 2045023003: Fix deferred load errors / bug #26482 (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/loader.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/lib_prefix.dart
diff --git a/runtime/lib/lib_prefix.dart b/runtime/lib/lib_prefix.dart
index 9d5af287e9e25e79f56e8ca99c2cb7e8318687c3..269542660d759ae7577f435d2f3162e7cec4dd68 100644
--- a/runtime/lib/lib_prefix.dart
+++ b/runtime/lib/lib_prefix.dart
@@ -32,7 +32,7 @@ class _LibraryPrefix {
// prefix. If that is the case, we must invalidate the dependent
// code and complete the future now since there will be no callback
// from the VM.
- if (hasCompleted) {
+ if (hasCompleted && !completer.isCompleted) {
_invalidateDependentCode();
completer.complete(true);
_outstandingLoadRequests.remove(pair);
@@ -53,19 +53,27 @@ _completeDeferredLoads() {
// which have not completed, remember them for next time in
// stillOutstandingLoadRequests.
var stillOutstandingLoadRequests = new List<List>();
- for (int i = 0; i < _outstandingLoadRequests.length; i++) {
- var prefix = _outstandingLoadRequests[i][0];
- if (prefix._load()) {
- var completer = _outstandingLoadRequests[i][1];
- var error = prefix._loadError();
- if (error != null) {
- completer.completeError(error);
- } else {
- prefix._invalidateDependentCode();
- completer.complete(true);
- }
+ var completedLoadRequests = new List<List>();
+
+ // Make a copy of the outstandingRequests because the call to _load below
+ // may recursively trigger another call to |_completeDeferredLoads|, which
+ // can cause |_outstandingLoadRequests| to be modified.
+ var outstandingRequests = _outstandingLoadRequests.toList();
+ for (int i = 0; i < outstandingRequests.length; i++) {
+ var prefix = outstandingRequests[i][0];
+ var completer = outstandingRequests[i][1];
+ var error = prefix._loadError();
+ if (completer.isCompleted) {
+ // Already completed. Skip.
+ continue;
+ }
+ if (error != null) {
+ completer.completeError(error);
+ } else if (prefix._load()) {
+ prefix._invalidateDependentCode();
+ completer.complete(true);
} else {
- stillOutstandingLoadRequests.add(_outstandingLoadRequests[i]);
+ stillOutstandingLoadRequests.add(outstandingRequests[i]);
}
}
_outstandingLoadRequests = stillOutstandingLoadRequests;
« no previous file with comments | « runtime/bin/loader.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698