Closed Flydiverny closed 8 years ago
This crash also occurs in realm 0.90.0 and in 0.89.1, I'm thinking it has to do with the changes to the event loop/looper refresh changes.
It has. This pattern here no longer works:
while (locksToRemove.size() > 0) {
LockInfo lock = locksToRemove.get(0);
if (lock.getPersons().size() == 0) {
if (lock.getTBDN() != null) {
lock.getTBDN().deleteFromRealm(); // Removing lock -> remove TBDN
}
}
lock.deleteFromRealm();
}
Instead do a normal loop like so:
for (LockInfo lock : locksToRemove) {
if (lock.getPersons().size() == 0) {
if (lock.getTBDN() != null) {
lock.getTBDN().deleteFromRealm(); // Removing lock -> remove TBDN
}
}
lock.deleteFromRealm();
}
Technically it's the change in 0.89.0 where RealmResults were changed to no longer live-update when a condition for an element is no longer met, they just become invalid with !isValid()
.
So I personally would recommend iteration from the end, that works in both versions, old and new:
for(int i = results.size() - 1; i >= 0; i--) {
SomeObj someObj = results.get(i);
//blah blah
if(/*blah*/) {
someObj.deleteFromRealm();
}
}
@cmelchior Hi!
Tested changing this seems to indeed resolve the issue :)
Thanks.
Goal
Clearing temporary data when signing out of application :)
Expected Results
Data is removed when we remove it without crashing!
Actual Results
Steps & Code to Reproduce
So we tried to split it up in several transactions & commits with no luck. This worked previously for us in
realm 0.88.3
, we have not done any extensive testing on versions 0.89.0 thru 0.91.0 more than basically it compiled.Version of Realm and tooling
Realm version(s): 1.0.1 Android Studio version: 2.1.2