From 0eca1e03c0491112d5f85eb906658eeb2f1764c2 Mon Sep 17 00:00:00 2001 From: SpiritCroc Date: Thu, 14 Apr 2022 13:56:26 +0200 Subject: [PATCH] Fix beginTransaction crash when continuing a transaction Change-Id: Ied0911c1f310ed59a5bf18e423efa5c8b146c668 --- .../matrix/android/sdk/internal/database/AsyncTransaction.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/AsyncTransaction.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/AsyncTransaction.kt index ebc9bcce5a..0df64568af 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/AsyncTransaction.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/AsyncTransaction.kt @@ -38,7 +38,9 @@ internal fun CoroutineScope.asyncTransaction(realmConfiguration: RealmConfig suspend fun awaitTransaction(config: RealmConfiguration, transaction: suspend (realm: Realm) -> T): T { return withContext(Realm.WRITE_EXECUTOR.asCoroutineDispatcher()) { Realm.getInstance(config).use { bgRealm -> - bgRealm.beginTransaction() + if (!bgRealm.isInTransaction) { + bgRealm.beginTransaction() + } val result: T try { val start = System.currentTimeMillis()