Closed theoks closed 7 years ago
This is most probably not on RxRealm's side, since the exception raises in the C++ code of the Realm core, but it's an interesting error - I'll try replicating it this week and help.
Should I post it on realm-cocoa repo too along with the similar issue I posted on stackoverflow?
@tkallioras it's probably worth reposting on Realm's github, especially if you have code how to replicate the crash and the full exception message. Somebody could rather quickly see what the reason for the issue is.
I see this is tracked by the realm cocoa team now: https://github.com/realm/realm-cocoa/issues/4731 . Closing this one down
I have this object:
let territory = RoadObject()
which has this LinkingObjects property:
let roadNumbers = LinkingObjects.init(fromType: RoadNumberObject.self, property: "territory")
I create at my ViewModel this property to get an array with the linking objects:
let roadNumbers: Variable<[RoadNumberObject]>
I initialize it (by creating an Array from the LinkingObjects property):
self.roadNumbers = Variable(self.territory.roadNumbers.toArray())
And I am trying to bind an Observer from the LinkingObjects so I can track the changes and access them easily through the Variable (I am using the same realm everywhere by the way, and I do not access it in this case from a thread other than the Main one) :
As soon as my ViewModel is initialized it crashes. I back traced the issue and the problem arises when I try to bind. I checked it as an Observable (not a Variable) and it doesn't crash, but I would like to use the variable for convenience.
The line where it crashes is:
bool read_only() const { return schema_mode == SchemaMode::ReadOnly; }
in the
Config
method in theshared_realm.hpp
fileIt doesn't happen though with a
ReplaySubject
, or aPublishSubject
. Only with aVariable
and aBehaviorSubject
It also doesn't happen if I initialize the Variable with an empty array (
Variable([])
). It only happens when it is already initialized asVariable(self.territory.roadNumbers.toArray())
One solution I found is if I initialize the Variable with an empty array and on the subscription I place
.startWith(self.territory.roadNumbers.toArray())