mirror of
https://github.com/dz0ny/meshcore-sar.git
synced 2026-08-13 09:20:29 +00:00
fix: Add mounted checks and fix memory leaks across UI components
Address potential memory leaks and state-after-dispose issues: - AppProvider: Add dispose method to clean up listeners and callbacks - MapTab: Store and restore original location callback instead of nullifying - MessagesTab: Use Timer instead of Future.delayed for highlight cleanup - ConnectionDialog: Use named listener method for proper tab controller cleanup - RoomLoginSheet: Add _isDisposed flag to handle async callback race conditions - SettingsScreen: Clear location service callbacks in dispose - Various screens: Add mounted checks before setState after async operations (contacts_tab, device_config, home_screen, map_management, packet_log, sar_template_management, sar_update_sheet, permission_request_dialog)
This commit is contained in:
@@ -231,6 +231,7 @@ class _SarUpdateSheetState extends State<SarUpdateSheet> {
|
||||
try {
|
||||
// Check if location services are enabled
|
||||
bool serviceEnabled = await Geolocator.isLocationServiceEnabled();
|
||||
if (!mounted) return;
|
||||
if (!serviceEnabled) {
|
||||
setState(() {
|
||||
_locationError = 'Location services are disabled';
|
||||
@@ -241,8 +242,10 @@ class _SarUpdateSheetState extends State<SarUpdateSheet> {
|
||||
|
||||
// Check permissions
|
||||
LocationPermission permission = await Geolocator.checkPermission();
|
||||
if (!mounted) return;
|
||||
if (permission == LocationPermission.denied) {
|
||||
permission = await Geolocator.requestPermission();
|
||||
if (!mounted) return;
|
||||
if (permission == LocationPermission.denied) {
|
||||
setState(() {
|
||||
_locationError = 'Location permission denied';
|
||||
|
||||
Reference in New Issue
Block a user