Add some mounted checks before setState, after using await (#3144)

This commit is contained in:
freebeartogoodhome
2026-05-11 02:33:59 -06:00
committed by GitHub
parent 71767f1f46
commit 06d420eabe
5 changed files with 19 additions and 11 deletions
@@ -151,9 +151,11 @@ class _CreateGameBodyState extends ConsumerState<CreateCorrespondenceGameBottomS
try {
await _pendingCreateGame;
} finally {
setState(() {
_pendingCreateGame = null;
});
if (mounted) {
setState(() {
_pendingCreateGame = null;
});
}
}
if (context.mounted) {
Navigator.of(
@@ -56,9 +56,11 @@ class _AccountPreferencesScreenState extends ConsumerState<AccountPreferencesScr
try {
await f();
} finally {
setState(() {
isLoading = false;
});
if (mounted) {
setState(() {
isLoading = false;
});
}
}
}
@@ -161,6 +161,7 @@ class _EngineSettingsScreenState extends ConsumerState<EngineSettingsScreen> {
);
if (isOk == true) {
await ref.read(nnueServiceProvider).deleteNNUEFiles();
if (!mounted) return;
setState(() {
_hasVerifiedNNUEFiles = false;
});
+5 -3
View File
@@ -32,9 +32,11 @@ class _PieceSetScreenState extends ConsumerState<PieceSetScreen> {
try {
await precachePieceImages(value);
} finally {
setState(() {
isLoading = false;
});
if (mounted) {
setState(() {
isLoading = false;
});
}
}
}
}
@@ -1150,7 +1150,7 @@ class _BottomBarState extends ConsumerState<_BottomBar> {
if (selectedTeamId == null) {
return; // User cancelled
}
if (!mounted) return;
setState(() {
joinOrLeaveInProgress = true;
});
@@ -1166,7 +1166,7 @@ class _BottomBarState extends ConsumerState<_BottomBar> {
if (entryCode == null || entryCode.isEmpty) {
return;
}
if (!mounted) return;
setState(() {
joinOrLeaveInProgress = true;
});
@@ -1176,6 +1176,7 @@ class _BottomBarState extends ConsumerState<_BottomBar> {
.read(tournamentControllerProvider(widget.state.id).notifier)
.joinOrPause(entryCode: entryCode);
} catch (e) {
if (!mounted) return;
setState(() {
joinOrLeaveInProgress = false;
});