View Issue Details

IDProjectCategoryView StatusLast Update
0002494NoesisGUIUnitypublic2023-02-20 19:30
Reporterckfinite Assigned Tosfernandez  
PrioritynormalSeverityminor 
Status resolvedResolutionno change required 
Product Version3.0.12 
Fixed in Version3.2.0 
Summary0002494: Changing content from a DataTrigger causes a crash to desktop on destruction
Description

Taken from a larger example,
[code]
<Menu IsMainMenu="False">
<MenuItem ItemsSource="{Binding Items}">
<MenuItem.ItemContainerStyle>
<Style TargetType="{x:Type MenuItem}" BasedOn="{StaticResource MenuItem}">
<Style.Triggers>
<DataTrigger Binding="{Binding Property}" Value="False">
<Setter Property="Header" Value="{Binding Header}"/>
</DataTrigger>
<DataTrigger Binding="{Binding Property}" Value="True">
<Setter Property="Header">
<Setter.Value>
<TextBlock/>
</Setter.Value>
</Setter>
</DataTrigger>
</Style.Triggers>
</Style>
</MenuItem.ItemContainerStyle>
</MenuItem>
</Menu>
[/code]
crashes Unity to desktop when it is destroyed (such as when the underlying viewmodel is changed). I suspect that the control created by the inactive setter is retained therein even after it is destroyed creating an invalid but retained reference that crashes the system upon its reuse. Refactoring this to use a datatemplate avoids the crash.

PlatformAny

Activities

sfernandez

sfernandez

2023-02-14 14:36

manager   ~0008283

I was unable to make Unity crash with latest version (3.1.7) of NoesisGUI.

Anyway, setting the Header this way won't work because the <TextBlock> element can only be the child of a single MenuItem. If I create a test using that Style then I get an error message indicating that: "Child already has a logical parent".

So the solution, as you already mentioned, is to use DataTemplates, that way a different visual tree for the header is generated from the template for each MenuItem.
Would it be ok to close this ticket?

ckfinite

ckfinite

2023-02-15 15:06

reporter   ~0008289

Yes, it's fine to close the ticket; I suspect that what was causing the crash was precisely they "has a logical parent" issue which wasn't correctly checked for in 3.0.12> Thank you for looking into it!

Issue History

Date Modified Username Field Change
2023-01-17 05:07 ckfinite New Issue
2023-01-17 19:17 sfernandez Assigned To => sfernandez
2023-01-17 19:17 sfernandez Status new => assigned
2023-02-14 14:36 sfernandez Status assigned => feedback
2023-02-14 14:36 sfernandez Note Added: 0008283
2023-02-15 15:06 ckfinite Note Added: 0008289
2023-02-15 15:06 ckfinite Status feedback => assigned
2023-02-15 19:50 sfernandez Status assigned => resolved
2023-02-15 19:50 sfernandez Resolution open => no change required
2023-02-20 19:30 jsantos Fixed in Version => 3.2.0
2025-10-10 13:29 jsantos Category Unity3D => Unity