Fix subscriptions for read only signals passed as props (#3173)
* add a fuzzing test for reference counted generational boxes * Fix subscriptions for readonlysignal passed as props * Don't subscribe to dropped contexts --------- Co-authored-by: Jonathan Kelley <jkelleyrtp@gmail.com>
This commit is contained in:
1 parent
5186d8dded
commit
45a1147ffd
8 files changed
+519
-191
No files matched your search
@@ -80,7 +80,7 @@ impl<T: 'static, S: Storage<T>> CopyValue<T, S> {
|
||||
}
|
||||
|
||||
/// Point to another copy value
|
||||
pub fn point_to(&mut self, other: Self) -> BorrowResult {
|
||||
pub fn point_to(&self, other: Self) -> BorrowResult {
|
||||
self.value.point_to(other.value)
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ impl<T: 'static, S: Storage<SignalData<T>>> ReadOnlySignal<T, S> {
|
||||
}
|
||||
|
||||
/// Point to another signal
|
||||
pub fn point_to(&mut self, other: Self) -> BorrowResult {
|
||||
pub fn point_to(&self, other: Self) -> BorrowResult {
|
||||
self.inner.point_to(other.inner)
|
||||
}
|
||||
|
||||
|
||||
@@ -221,8 +221,14 @@ impl<T: 'static, S: Storage<SignalData<T>>> Signal<T, S> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Point to another signal
|
||||
pub fn point_to(&mut self, other: Self) -> BorrowResult {
|
||||
/// Point to another signal. This will subscribe the other signal to all subscribers of this signal.
|
||||
pub fn point_to(&self, other: Self) -> BorrowResult {
|
||||
#[allow(clippy::mutable_key_type)]
|
||||
let this_subscribers = self.inner.value.read().subscribers.lock().unwrap().clone();
|
||||
let other_read = other.inner.value.read();
|
||||
for subscriber in this_subscribers.iter() {
|
||||
subscriber.subscribe(other_read.subscribers.clone());
|
||||
}
|
||||
self.inner.point_to(other.inner)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user