Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataTemplate::LoadContent returns an object with an extra ref count #3057

Closed
jevansaks opened this issue Aug 6, 2020 · 2 comments
Closed
Labels
bug Something isn't working needs-winui-3 Indicates that feature can only be done in WinUI 3.0 or beyond. (needs winui 3)

Comments

@jevansaks
Copy link
Member

See #1954 for more information, but the problem is that DataTemplate::LoadContent returns an extra reference on the peer object that it retuns. LoadContent and XamlReader::Load do similar things but XamlReader::Load (in the LoadImpl method) calls UnpegNoRef() which takes care of this extra reference. LoadContent doesn't have this and as a result the object returned to callers has a ref count of 2 on it and there's no obvious way to fix this extra reference.

In ItemsRepeater I'm proposing we work around this by adding the object to a Panel's Children collection and immediately removing it, but we should fix this so we don't need that work around with WinUI 3.0.

@msft-github-bot msft-github-bot added the needs-triage Issue needs to be triaged by the area owners label Aug 6, 2020
@StephenLPeters StephenLPeters added the needs-winui-3 Indicates that feature can only be done in WinUI 3.0 or beyond. (needs winui 3) label Aug 6, 2020
@chrisglein chrisglein added bug Something isn't working and removed needs-triage Issue needs to be triaged by the area owners labels Aug 7, 2020
@lukeblevins
Copy link
Contributor

@jevansaks Do you think ListView, TabViewListView, or GridView would be affected by this bug with DataTemplate? I have no way to inspect the implementation of those controls, but it seems reasonable enough to suspect they would considering the context around this TabView issue I reported #3597.

If so, is there a workaround to allow the proper release of TabViewItem content?

I don't mention this to nag or derail the purpose of this issue. Instead, I see a possible correlation considering the controls I mentioned also leverage DataTemplate.

@StephenLPeters
Copy link
Contributor

This issue has been fixed in the OS code and will be included in a future release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-winui-3 Indicates that feature can only be done in WinUI 3.0 or beyond. (needs winui 3)
Projects
None yet
Development

No branches or pull requests

5 participants