Skip to content

Commit

Permalink
[Ermine][QuickSettings] Fix error from modifying unmodifiable list
Browse files Browse the repository at this point in the history
Dart FIDL lists were made unmodifiable in
https://fuchsia-review.googlesource.com/c/fuchsia/+/665177/
which seems to be making this logic crash at runtime.

Fixes this error from some logs I saw in an unrelated
bug fxb/101341:
```
[00020.831] [30826][60673][flutter_aot_product_runner.cm] ERROR:  [flutter/runtime/dart_vm_initializer.cc:41] Unhandled Exception: Unsupported operation: Cannot remove from an unmodifiable list
#0      UnmodifiableListMixin.removeAt (dart:_internal/list.dart:164)
#1      new SettingsStateImpl.<anonymous closure>.<anonymous closure> (package:ermine/src/states/settings_state_impl.dart:325)
#2      Function._apply (dart:core-patch/function_patch.dart:11)
#3      Function.apply (dart:core-patch/function_patch.dart:34)
#4      Action.call (package:mobx/src/core/action.dart:53)
#5      runInAction (package:mobx/src/api/action.dart:11)
#6      new SettingsStateImpl.<anonymous closure> (package:ermine/src/states/settings_state_impl.dart:313)
#7      ChannelService.start (package:ermine/src/services/settings/channel_service.dart:39)
<asynchronous suspension>
#8      Future.wait.<anonymous closure> (dart:async/future.dart:522)
<asynchronous suspension>
#9      SettingsStateImpl.start (package:ermine/src/states/settings_state_impl.dart:387)
<asynchronous suspension>
```

Change-Id: I5adffdec4e64beafc2cc97da5e23197e4ec2e298
Reviewed-on: https://fuchsia-review.googlesource.com/c/experiences/+/684597
Reviewed-by: Sanjay Chouksey <[email protected]>
Reviewed-by: Charles Whitten <[email protected]>
Commit-Queue: Alexander Biggs <[email protected]>
  • Loading branch information
akbiggs authored and CQ Bot committed Jun 12, 2022
1 parent 488fc65 commit e5259b4
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,10 @@ class SettingsStateImpl with Disposable implements SettingsState, TaskService {
List<String> channels;
if (currentChannel.isNotEmpty) {
if (channelService.channels.contains(currentChannel)) {
channels = channelService.channels;
// FIDL messages are unmodifiable so we need to copy the list of
// channels here.
channels = List.from(channelService.channels);

int index = channels.indexOf(currentChannel);
if (index != 0) {
channels
Expand Down

0 comments on commit e5259b4

Please sign in to comment.