diff --git a/bindings/matrix-sdk-ffi/src/client.rs b/bindings/matrix-sdk-ffi/src/client.rs index 4790f27743e..a5e6a14e78e 100644 --- a/bindings/matrix-sdk-ffi/src/client.rs +++ b/bindings/matrix-sdk-ffi/src/client.rs @@ -54,7 +54,7 @@ use ruma::{ use serde::{Deserialize, Serialize}; use serde_json::Value; use tokio::sync::broadcast::error::RecvError; -use tracing::{debug, error, info}; +use tracing::{debug, error}; use url::Url; use super::{room::Room, session_verification::SessionVerificationController, RUNTIME}; @@ -179,7 +179,6 @@ impl Drop for Client { // SAFETY: self.inner is never used again, which is the only requirement // for ManuallyDrop::drop to be used safely. unsafe { - info!("Dropping a client"); ManuallyDrop::drop(&mut self.inner); } } diff --git a/bindings/matrix-sdk-ffi/src/room.rs b/bindings/matrix-sdk-ffi/src/room.rs index 7da57d89648..bf90d8f0fa2 100644 --- a/bindings/matrix-sdk-ffi/src/room.rs +++ b/bindings/matrix-sdk-ffi/src/room.rs @@ -1,4 +1,4 @@ -use std::{mem::ManuallyDrop, sync::Arc}; +use std::sync::Arc; use anyhow::{Context, Result}; use matrix_sdk::{ @@ -22,7 +22,7 @@ use ruma::{ EventId, Int, RoomAliasId, UserId, }; use tokio::sync::RwLock; -use tracing::{error, info}; +use tracing::error; use super::RUNTIME; use crate::{ @@ -58,35 +58,17 @@ pub(crate) type TimelineLock = Arc>>>; #[derive(uniffi::Object)] pub struct Room { - pub(super) inner: ManuallyDrop, + pub(super) inner: SdkRoom, timeline: TimelineLock, } -impl Drop for Room { - fn drop(&mut self) { - // A `Room` may be the ultimate holder of a `Client` reference, so it may - // release a `Client` too. - // - // Dropping the inner OlmMachine must happen within a tokio context - // because deadpool drops sqlite connections in the DB pool on tokio's - // blocking threadpool to avoid blocking async worker threads. - let _guard = RUNTIME.enter(); - // SAFETY: self.inner is never used again, which is the only requirement - // for ManuallyDrop::drop to be used safely. - unsafe { - info!("Dropping a room"); - ManuallyDrop::drop(&mut self.inner); - } - } -} - impl Room { pub(crate) fn new(inner: SdkRoom) -> Self { - Room { inner: ManuallyDrop::new(inner), timeline: Default::default() } + Room { inner, timeline: Default::default() } } pub(crate) fn with_timeline(inner: SdkRoom, timeline: TimelineLock) -> Self { - Room { inner: ManuallyDrop::new(inner), timeline } + Room { inner, timeline } } } diff --git a/bindings/matrix-sdk-ffi/src/widget.rs b/bindings/matrix-sdk-ffi/src/widget.rs index f2bf6e94700..7a1505d8ac5 100644 --- a/bindings/matrix-sdk-ffi/src/widget.rs +++ b/bindings/matrix-sdk-ffi/src/widget.rs @@ -42,7 +42,7 @@ impl WidgetDriver { }; let capabilities_provider = CapabilitiesProviderWrap(capabilities_provider.into()); - if let Err(()) = driver.run((*room.inner).clone(), capabilities_provider).await { + if let Err(()) = driver.run(room.inner.clone(), capabilities_provider).await { // TODO } }