realesmedia
Topic Author
Posts: 85
Joined: 18 May 2016, 10:26

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

28 Dec 2017, 12:09

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?
Last edited by realesmedia on 23 Mar 2018, 12:25, edited 2 times in total.
 
User avatar
sfernandez
Site Admin
Posts: 1912
Joined: 22 Dec 2011, 19:20

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

04 Jan 2018, 02:47

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.
 
realesmedia
Topic Author
Posts: 85
Joined: 18 May 2016, 10:26

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

11 Jan 2018, 14:01

If element had been removed when it's selected, refcounter greater 1, but must be 1.
Otherwise when not selected refcounter correctly equal 1.
 
User avatar
sfernandez
Site Admin
Posts: 1912
Joined: 22 Dec 2011, 19:20

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

11 Jan 2018, 18:36

Thanks, that helps trying to narrow where the problem comes from.
As soon as we fix it I let you know.
 
realesmedia
Topic Author
Posts: 85
Joined: 18 May 2016, 10:26

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

15 Jan 2018, 12:33

UPD: Clearing collection with Clear() method have the same effect as in case of removing single item.
 
User avatar
sfernandez
Site Admin
Posts: 1912
Joined: 22 Dec 2011, 19:20

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

17 Jan 2018, 14:44

We found the source of the problem and fix it.
It would be solve in the next beta release we generate, probably tonight.
 
realesmedia
Topic Author
Posts: 85
Joined: 18 May 2016, 10:26

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

23 Mar 2018, 12:28

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.
 
User avatar
sfernandez
Site Admin
Posts: 1912
Joined: 22 Dec 2011, 19:20

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

27 Mar 2018, 19:30

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?
 
realesmedia
Topic Author
Posts: 85
Joined: 18 May 2016, 10:26

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

28 Mar 2018, 11:56

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.
Attachments
Src.zip
Sample with bug reproduction
(1.75 KiB) Downloaded 90 times
 
User avatar
sfernandez
Site Admin
Posts: 1912
Joined: 22 Dec 2011, 19:20

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

28 Mar 2018, 12:14

Thanks for the sample project, I'll take a look as soon as possible and let you know.

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 1 guest