IOS-1521 fixes: CD multithreading rules violation crash IOS-1521+IOS-1495
authorbuff <andreas@pep-project.org>
Tue, 14 May 2019 22:01:58 +0200
branchIOS-1521+IOS-1495
changeset 8615e23f4c0960c2
parent 8614 9332d31f8949
child 8616 a18e4cc9c07e
IOS-1521 fixes: CD multithreading rules violation crash
pEpForiOS/UI/Compose/Util/MediaAttachmentPickerProvider/MediaAttachmentPickerProviderViewModel.swift
pEpForiOSTests/SimpleOperationsTest.swift
     1.1 --- a/pEpForiOS/UI/Compose/Util/MediaAttachmentPickerProvider/MediaAttachmentPickerProviderViewModel.swift	Tue May 14 19:25:54 2019 +0200
     1.2 +++ b/pEpForiOS/UI/Compose/Util/MediaAttachmentPickerProvider/MediaAttachmentPickerProviderViewModel.swift	Tue May 14 22:01:58 2019 +0200
     1.3 @@ -93,11 +93,13 @@
     1.4              }
     1.5              let mimeType = resourceUrl.mimeType() ?? MimeTypeUtil.defaultMimeType
     1.6              let filename = me.fileName(forVideoAt: resourceUrl)
     1.7 -            let attachment =  Attachment(data: resourceData,
     1.8 -                                         mimeType: mimeType,
     1.9 -                                         fileName: filename,
    1.10 -                                         contentDisposition: .attachment)
    1.11 -            completion(attachment)
    1.12 +            DispatchQueue.main.async {
    1.13 +                let attachment =  Attachment(data: resourceData,
    1.14 +                                             mimeType: mimeType,
    1.15 +                                             fileName: filename,
    1.16 +                                             contentDisposition: .attachment)
    1.17 +                completion(attachment)
    1.18 +            }
    1.19          }
    1.20      }
    1.21  
     2.1 --- a/pEpForiOSTests/SimpleOperationsTest.swift	Tue May 14 19:25:54 2019 +0200
     2.2 +++ b/pEpForiOSTests/SimpleOperationsTest.swift	Tue May 14 22:01:58 2019 +0200
     2.3 @@ -520,7 +520,7 @@
     2.4      }
     2.5  
     2.6      func testOutgoingMailColorPerformanceWithMySelf() {
     2.7 -        let moc = Stack.shared.newPrivateConcurrentContext
     2.8 +        let moc: NSManagedObjectContext = Stack.shared.mainContext
     2.9          let (myself, _, _, _, _) = TestUtil.setupSomeIdentities(session)
    2.10          try! session.mySelf(myself)
    2.11          XCTAssertNotNil(myself.fingerPrint)
    2.12 @@ -610,7 +610,7 @@
    2.13  
    2.14      //fails on first run when the an account was setup on
    2.15      func testFixAttachmentsOperation() {
    2.16 -        let moc = Stack.shared.newPrivateConcurrentContext
    2.17 +        let moc: NSManagedObjectContext = Stack.shared.mainContext
    2.18          let cdFolder = CdFolder(context: moc)
    2.19          cdFolder.name = "AttachmentTestFolder"
    2.20          cdFolder.folderType = FolderType.inbox