diff --git a/glib/src/object.rs b/glib/src/object.rs index a9d8b87c2261..e694da21f864 100644 --- a/glib/src/object.rs +++ b/glib/src/object.rs @@ -3583,18 +3583,13 @@ impl PartialOrd for WeakRef { /// where it was created on will panic but dropping or cloning can be done /// safely from any thread. #[derive(Debug)] -pub struct SendWeakRef(WeakRef, Option); +pub struct SendWeakRef(WeakRef, usize); impl SendWeakRef { - #[inline] - pub fn new() -> SendWeakRef { - SendWeakRef(WeakRef::new(), None) - } - #[inline] pub fn into_weak_ref(self) -> WeakRef { assert!( - self.1.is_none() || self.1 == Some(thread_id()), + self.1 == thread_id(), "SendWeakRef dereferenced on a different thread", ); @@ -3608,7 +3603,7 @@ impl ops::Deref for SendWeakRef { #[inline] fn deref(&self) -> &WeakRef { assert!( - self.1.is_none() || self.1 == Some(thread_id()), + self.1 == thread_id(), "SendWeakRef dereferenced on a different thread" ); @@ -3627,14 +3622,14 @@ impl Clone for SendWeakRef { impl Default for SendWeakRef { #[inline] fn default() -> Self { - Self::new() + Self::from(WeakRef::new()) } } impl From> for SendWeakRef { #[inline] fn from(v: WeakRef) -> SendWeakRef { - SendWeakRef(v, Some(thread_id())) + SendWeakRef(v, thread_id()) } }