Skip to content

Commit f6ba7b4

Browse files
authored
debugger: if controller has been disposed, leave showScriptLocation early (#9884)
1 parent 4362d64 commit f6ba7b4

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

packages/devtools_app/lib/src/screens/debugger/codeview_controller.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,9 @@ class CodeViewController extends DisposableController
218218
);
219219

220220
if (succeeded) {
221+
// The controller may have been disposed while awaiting the asynchronous
222+
// location display setup.
223+
if (disposed) return;
221224
// Update the scripts history (and make sure we don't react to the
222225
// subsequent event).
223226
scriptsHistory.current.removeListener(_scriptHistoryListener);
@@ -234,6 +237,8 @@ class CodeViewController extends DisposableController
234237
final isolateRef =
235238
serviceConnection.serviceManager.isolateManager.selectedIsolate.value!;
236239
final processedReport = await _getSourceReport(isolateRef, current.script);
240+
// The controller may have been disposed while awaiting the source report.
241+
if (disposed) return;
237242

238243
parsedScript.value = ParsedScript(
239244
script: current.script,
@@ -264,6 +269,8 @@ class CodeViewController extends DisposableController
264269
if (scriptRef.id != parsedScript.value?.script.id) {
265270
// Try to parse the script if it isn't the currently parsed script:
266271
final script = await _parseScript(scriptRef);
272+
// The controller may have been disposed while awaiting the script parsing.
273+
if (disposed) return false;
267274
if (script == null) {
268275
// Return early and indicate failure if parsing fails.
269276
reportError(

0 commit comments

Comments
 (0)