Page 1 of 2

[C++] Clear resources on collection item remove.

Posted: 28 Dec 2017, 12:09
by realesmedia
I have my own component placed in observable collection with binding to treeview.
Component have ref-counter. When I put new element to collection it have ref counter equal 15. When I remove item from collection with Remove() method ref-counter have the same value. When I select another item in collection (by clicking on treeview) ref-counter drops to 1.
How can I clear resources in place where item was removed?

Re: [C++] Clear resources on collection item remove.

Posted: 04 Jan 2018, 02:47
by sfernandez
Sorry for the late answer.

Is it possible that the item you are removing is currently selected in the TreeView?
Our code seems to clean the references to the TreeView.SelectedItem property, but maybe we have something wrong I'm not seeing now.
Could you please report it in our bugtracker attaching the sample code and we will take a look?

Thanks for your collaboration.

Re: [C++] Clear resources on collection item remove.

Posted: 11 Jan 2018, 14:01
by realesmedia
If element had been removed when it's selected, refcounter greater 1, but must be 1.
Otherwise when not selected refcounter correctly equal 1.

Re: [C++] Clear resources on collection item remove.

Posted: 11 Jan 2018, 18:36
by sfernandez
Thanks, that helps trying to narrow where the problem comes from.
As soon as we fix it I let you know.

Re: [C++] Clear resources on collection item remove.

Posted: 15 Jan 2018, 12:33
by realesmedia
UPD: Clearing collection with Clear() method have the same effect as in case of removing single item.

Re: [C++] Clear resources on collection item remove.

Posted: 17 Jan 2018, 14:44
by sfernandez
We found the source of the problem and fix it.
It would be solve in the next beta release we generate, probably tonight.

Re: [C++] Clear resources on collection item remove.

Posted: 23 Mar 2018, 12:28
by realesmedia
Additional problem.
Have few tabs. First tab have collection with selected item.
Case 1: First tab selected. Close app and have item's destructor call.
Case 2: Second tab selected (first doesn't visible). Close app and have NO destructor call for selected item in collection.

Re: [C++] Clear resources on collection item remove.

Posted: 27 Mar 2018, 19:30
by sfernandez
Do you mean an items control with a collection attached inside each tab, and then item destructors are only called when closing with first tab selected?

Re: [C++] Clear resources on collection item remove.

Posted: 28 Mar 2018, 11:56
by realesmedia
Sources in attachment which reproduce bug.

Two tabs have binding to different collections.
Each tab have 5 items.

Normal case:
Click button and see that all destructors ~MyComponent() called.

Bug case:
Select an item and click button. Destructor for selected item didn't call. Closing app call destructor.

I cannot reproduce bug with case when destructor not callable after closing the app.

Re: [C++] Clear resources on collection item remove.

Posted: 28 Mar 2018, 12:14
by sfernandez
Thanks for the sample project, I'll take a look as soon as possible and let you know.