Fix a few FFI leaks (#405)

Fix a few FFI leaks

These are instances where we obtain an FFIObject and don't call
Close on it to release the underlying reference on the Rust side.

The worst instance here was leaking an object per room member
every time we refreshed the member list
This commit is contained in:
Chris Smith 2023-05-12 11:50:39 +01:00 committed by GitHub
parent 89b9db3be6
commit 92e9d3a127
11 changed files with 67 additions and 59 deletions

View file

@ -131,14 +131,18 @@ class InviteListPresenter @Inject constructor(
private fun CoroutineScope.acceptInvite(roomId: RoomId, acceptedAction: MutableState<Async<RoomId>>) = launch {
suspend {
client.getRoom(roomId)?.acceptInvitation()?.getOrThrow()
client.getRoom(roomId)?.use {
it.acceptInvitation().getOrThrow()
}
roomId
}.execute(acceptedAction)
}
private fun CoroutineScope.declineInvite(roomId: RoomId, declinedAction: MutableState<Async<Unit>>) = launch {
suspend {
client.getRoom(roomId)?.rejectInvitation()?.getOrThrow() ?: Unit
client.getRoom(roomId)?.use {
it.rejectInvitation().getOrThrow()
} ?: Unit
}.execute(declinedAction)
}