From b1f5f6464d8b1cf27d584ac85f18afa140d7dc73 Mon Sep 17 00:00:00 2001 From: Selim Mustafaev Date: Sun, 5 Oct 2025 16:45:06 +0300 Subject: [PATCH] Fix for potential recording crash --- AutoCat.xcodeproj/project.pbxproj | 4 ++-- .../VehicleRecordService/VehicleRecordService.swift | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/AutoCat.xcodeproj/project.pbxproj b/AutoCat.xcodeproj/project.pbxproj index 8c4485f..8566875 100644 --- a/AutoCat.xcodeproj/project.pbxproj +++ b/AutoCat.xcodeproj/project.pbxproj @@ -1721,7 +1721,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 170; + CURRENT_PROJECT_VERSION = 171; DEVELOPMENT_TEAM = 46DTTB8X4S; INFOPLIST_FILE = AutoCat/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = AutoCat; @@ -1750,7 +1750,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 170; + CURRENT_PROJECT_VERSION = 171; DEVELOPMENT_TEAM = 46DTTB8X4S; INFOPLIST_FILE = AutoCat/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = AutoCat; diff --git a/AutoCatCore/Services/VehicleRecordService/VehicleRecordService.swift b/AutoCatCore/Services/VehicleRecordService/VehicleRecordService.swift index d7028b3..cf3d5f6 100644 --- a/AutoCatCore/Services/VehicleRecordService/VehicleRecordService.swift +++ b/AutoCatCore/Services/VehicleRecordService/VehicleRecordService.swift @@ -114,6 +114,12 @@ extension VehicleRecordService: VehicleRecordServiceProtocol { throw VehicleRecordError.emptyUrl } + locationTask?.cancel() + locationTask = nil + self.url = nil + let location = self.location + self.location = nil + await recordService.stopRecording() async let recognitionTask = recordService.recognizeText(from: url) @@ -121,10 +127,6 @@ extension VehicleRecordService: VehicleRecordServiceProtocol { let (text, duration) = await (recognitionTask, try? durationTask) - locationTask?.cancel() - locationTask = nil - self.url = nil - let record = AudioRecordDto( path: url.lastPathComponent, number: await getPlateNumber(from: text),