Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Guard async context after dispose

Neeraj Gupta132de78541bc
diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_widget.dart b/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_widget.dart
index 506cdea564..d7479a5bae 100644
--- a/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_widget.dart
+++ b/mobile/apps/photos/lib/ui/viewer/gallery/gallery_app_bar_widget.dart
@@ -1029,6 +1029,7 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
widget.collection!,
useCache: false,
);
+ if (!mounted) return;
final bool isEmptyCollection = count == 0;
if (isEmptyCollection) {
final dialog = createProgressDialog(
@@ -1041,10 +1042,12 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
widget.collection!,
);
await dialog.hide();
+ if (!mounted) return;
Navigator.of(context).pop();
} catch (e, s) {
_logger.warning("failed to trash collection", e, s);
await dialog.hide();
+ if (!mounted) return;
await showGenericErrorDialog(context: context, error: e);
}
} else {
@@ -1052,6 +1055,7 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
context,
widget.collection!,
);
+ if (!mounted) return;
if (result == true) {
Navigator.of(context).pop();
} else {
diff --git a/mobile/packages/lock_screen/lib/ui/lock_screen.dart b/mobile/packages/lock_screen/lib/ui/lock_screen.dart
index 546eb9b42d..7c5ad4284d 100644
--- a/mobile/packages/lock_screen/lib/ui/lock_screen.dart
+++ b/mobile/packages/lock_screen/lib/ui/lock_screen.dart
@@ -327,6 +327,9 @@ class _LockScreenState extends State<LockScreen> with WidgetsBindingObserver {
1000;
await startLockTimer(remainingTime);
+ if (!mounted) {
+ return;
+ }
}
_isShowingLockScreen = true;
final result = isTimerRunning
@@ -338,6 +341,10 @@ class _LockScreenState extends State<LockScreen> with WidgetsBindingObserver {
macOSReason: context.strings.unlock,
isOpeningApp: true,
);
+ if (!mounted) {
+ _isShowingLockScreen = false;
+ return;
+ }
_logger.finest("LockScreen Result $result $currentTimestamp");
_isShowingLockScreen = false;
if (result) {