Skip to content

Conversation

@pteasima
Copy link

@pteasima pteasima commented Mar 8, 2016

This fixes a crash where if the ReactiveArray was initialized with a producer and the producer sends a value after the ReactiveArray has been dealloced, the app will crash on calling a method on unowned dealloced self in _signal.observe.

Easiest way to reproduce this bug is using a mirror:

let xs = ReactiveArray<String>()
;{
let ys = xs.mirror { _ in "I will crash" }
}()
xs.append("ys shall crash now!")

There may be better ways to fix this than my solution, so feel free to implement your own.
I would have liked to use .takeUntil(willDeallocSignal) instead of the disposeBag, but I dont have a willDeallocSignal for arbitrary swift classes (not NSObject)
I could tackle this by disposing of the _signal.observe to prevent other possible problems of this kind, but I felt like my change fixes this particular problem as locally as possible.

@guidomb guidomb self-assigned this Apr 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants