-
Type: Improvement
-
Resolution: Fixed
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
What happened?
We are using Realms object and in Syncfusion ListView. We have a realm query that is bound to the ItemsSource of the list like below,
var realm = Realm.GetInstance(); //just clean everything realm.Write(() => realm.RemoveAll()); realm.Write(() => { for (int i = 0; i < 10; i++) { realm.Add(new ItemModel() { Title = i.ToString(), Subtitle = Guid.NewGuid().ToString("N").Substring(0, 5), IsDirectory = false }); } }); var query = realm.All<ItemModel>().Where(im => im.IsDirectory == true); listview.ItemsSource = query;
The list will have the items with IsDirectory is true. When updating the IsDirectory to false, the item is removed from the query and the CollectionChanged event is fired with Remove action.
The problem we are facing is, in the NotifyCollectionChangedEventArgs, the olditem is InvalidObject.
Due to this, we could not get the proper item in the syncfusion level to update the SfListView. Since the removed item is invalidobject, we could not get the proper index/item to remove it from our end.
Note: The issue occurs from version 10.4.0. Before this version, the OldItem is null.
We need the e.OldItems as actual data or null to process in the syncfusion source level.
Repro steps
- Run the attached sample (ReplicationSample)
- Click update
- The IsDirectory property is updated, and the CollectionChanged event will be triggered. But, the OldItem is invalidobject.
Version
10.7.0
What SDK flavour are you using?
Local Database only
What type of application is this?
Xamarin
Client OS and version
10.7.0
Code snippets
private void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { Debug.WriteLine($"<||> OnCollectionChanged. {e.Action}, {e.NewItems?.Count}, {e.OldItems?.Count}");
if (e.Action == NotifyCollectionChangedAction.Remove) { var oldItem = e.OldItems[0]; if (oldItem == null) { //The olditem is null till v10.3.0 Debug.WriteLine("OldItem is: " + oldItem); } else { //Invalidate object passed as olditem from v10.4.0 Debug.WriteLine("OldItem is: " + oldItem); } } }
Stacktrace of the exception/crash you're getting
NA
Relevant log output
NA
- depends on
-
RCORE-953 Access to deleted ObjectIds from collection listener callback
- Closed