View Issue Details

IDProjectCategoryView StatusLast Update
0001872NoesisGUIC++ SDKpublic2021-01-07 18:58
ReporterasusralisAssigned Tosfernandez 
PrioritynormalSeveritycrashReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.0.8 
Target Version3.0.9Fixed in Version3.0.9 
Summary0001872: Crash from clicking button
DescriptionWhen upgrading from 3.06 -> 3.0.8, a button makes Unity crash. It does not show any error and no crash logs are created.

Video of it happening, thought I don't know if it helps: https://files.catbox.moe/djagdk.mp4

It seems once I move my tooltip from the button it stops crashing, but it seems when I tried to add it back (out of playing) the editor crashed when the xaml was reimporting (?). My tooltip is a custom one that is made to follow the mouse.

public class SmartToolTip : ToolTip
    {
        private UIElement _targetElement;

        private TranslateTransform _transform;

        public static readonly DependencyProperty HeaderProperty = DependencyProperty.Register("Header", typeof(string), typeof(SmartToolTip));

        public static readonly DependencyProperty HorizontalPlacementProperty = DependencyProperty.Register("HorizontalPlacement", typeof(HorizontalPlacement), typeof(SmartToolTip), new PropertyMetadata(HorizontalPlacement.Right));

        public static readonly DependencyProperty VerticalPlacementProperty = DependencyProperty.Register("VerticalPlacement", typeof(VerticalPlacement), typeof(SmartToolTip), new PropertyMetadata(VerticalPlacement.Top));

        public string Header
        {
            get => (string)GetValue(HeaderProperty);
            set => SetValue(HeaderProperty, value);
        }

        public HorizontalPlacement HorizontalPlacement
        {
            get => (HorizontalPlacement)GetValue(HorizontalPlacementProperty);
            set => SetValue(HorizontalPlacementProperty, value);
        }

        public VerticalPlacement VerticalPlacement
        {
            get => (VerticalPlacement)GetValue(VerticalPlacementProperty);
            set => SetValue(VerticalPlacementProperty, value);
        }

        private void UpdatePosition(Point position)
        {
#if UNITY_5_3_OR_NEWER
            //UnityEngine.Debug.Log($"X: {position.X}, Y: {position.Y}");
#endif
            Point spacing = new Point(40, 40);

            Point offset = new Point(
                HorizontalPlacement == HorizontalPlacement.Left ? -ActualWidth - spacing.X : spacing.X,
                VerticalPlacement == VerticalPlacement.Top ? 0 : -ActualHeight);

            HorizontalOffset = position.X + offset.X;
            VerticalOffset = position.Y + offset.Y;
        }

        private void PlacementTarget_MouseMove(object sender, MouseEventArgs e)
        {
            if(_targetElement != null)
            {
                var position = e.GetPosition(_targetElement);

                UpdatePosition(position);
            }
        }

        public SmartToolTip()
        {
            Opened += SmartToolTip_Opened;
            Closed += SmartToolTip_Closed;
            ToolTipClosing += SmartToolTip_ToolTipClosing;

            Loaded += (s, e) =>
            {
              
            };
        }

        private void SmartToolTip_Closed(object sender, RoutedEventArgs args)
        {
            if (_targetElement != null)
            {
                _targetElement.MouseMove -= PlacementTarget_MouseMove;
                SizeChanged -= SmartToolTip_SizeChanged;
                _targetElement = null;
            }
        }

        private void SmartToolTip_ToolTipClosing(object sender, ToolTipEventArgs args)
        {
            if (_targetElement != null)
            {
                _targetElement.MouseMove -= PlacementTarget_MouseMove;
            }
        }

        private void SmartToolTip_Opened(object sender, RoutedEventArgs args)
        {
            if(PlacementTarget != null)
            {
#if UNITY_5_3_OR_NEWER
               // UnityEngine.Debug.Log("Tooltip opened.");
#endif

                _targetElement = PlacementTarget;
                _targetElement.MouseMove += PlacementTarget_MouseMove;
                SizeChanged += SmartToolTip_SizeChanged;

                UpdatePosition(Mouse.GetPosition(_targetElement));
            }
        }

        private void SmartToolTip_SizeChanged(object sender, SizeChangedEventArgs e)
        {
            UpdatePosition(Mouse.GetPosition(_targetElement));
        }

        static SmartToolTip()
        {
            DefaultStyleKeyProperty.OverrideMetadata(typeof(SmartToolTip), new FrameworkPropertyMetadata(typeof(SmartToolTip)));
        }
    }

TagsNo tags attached.
PlatformAny

Activities

asusralis

asusralis

2020-12-30 15:42

reporter   ~0006932

And here is the tooltip style:

    <Style TargetType="local:SmartToolTip">
        <Setter Property="Foreground" Value="Transparent" />
        <Setter Property="Background" Value="{StaticResource Window.Background}" />
        <Setter Property="BorderBrush" Value="{StaticResource Window.BorderBrush}" />
        <Setter Property="HorizontalPlacement" Value="Right" />
        <Setter Property="MaxWidth" Value="650" />
        <Setter Property="Placement" Value="Relative" />
        <Setter Property="VerticalPlacement" Value="Bottom" />
        <Setter Property="BorderThickness" Value="{StaticResource Window.BorderThickness}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:SmartToolTip}">
                    <local:NineSliceControl
                        MaxWidth="{TemplateBinding MaxWidth}"
                        Padding="5"
                        ImageSource="{StaticResource AltBorder}">
                        <Grid>
                            <StackPanel>
                                <TextBlock Text="{TemplateBinding Header}">
                                    <TextBlock.Style>
                                        <Style BasedOn="{StaticResource {x:Type TextBlock}}" TargetType="TextBlock">
                                            <Setter Property="Visibility" Value="Visible" />
                                            <Style.Triggers>
                                                <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Text}" Value="{x:Null}">
                                                    <Setter Property="Visibility" Value="Collapsed" />
                                                </DataTrigger>
                                            </Style.Triggers>
                                        </Style>
                                    </TextBlock.Style>
                                </TextBlock>
                                <ContentPresenter />
                            </StackPanel>
                        </Grid>
                    </local:NineSliceControl>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
sfernandez

sfernandez

2020-12-30 17:33

manager   ~0006936

Using the provided class and style I'm not able to reproduce the crash.
If you could provide access to your repository again (in the past you gave me access to a branch named testme-dev) I can find the problem faster.
asusralis

asusralis

2020-12-30 19:23

reporter   ~0006937

I think you still have access to it. Checkout 3.0.8-dev, play, start game, settle city, and click on any product in the city tab. Sometimes you need to move the cursor in the button after clicking it to have it crash.
asusralis

asusralis

2020-12-30 19:25

reporter   ~0006938

Oh, you don't even need to click the button. I think the tooltip closing makes it crash.
sfernandez

sfernandez

2020-12-31 11:49

manager   ~0006939

Thanks for the information, I'll check it right now.
sfernandez

sfernandez

2020-12-31 13:12

manager   ~0006940

Found the problem, please try the following patched library:
https://drive.google.com/file/d/18XKLbZpANMsWm2oQW-kUknzfvN9mlxyn/view?usp=sharing
asusralis

asusralis

2021-01-03 14:48

reporter   ~0006944

Yes, I believe that fixed it. Thanks!
asusralis

asusralis

2021-01-03 14:50

reporter   ~0006945

Is there any reason why I'm not getting emails anymore? It seems like I should be looking at my preferences. I also keep receving this error when trying to reply to things: https://i.imgur.com/vOW8hhs.png
jsantos

jsantos

2021-01-03 20:18

manager   ~0006947

I fixed the error regarding the timeout. About not getting emails, sometimes it happens, I will check tomorrow if there is something wrong at our side.

Issue History

Date Modified Username Field Change
2020-12-30 15:29 asusralis New Issue
2020-12-30 15:42 asusralis Note Added: 0006932
2020-12-30 17:24 jsantos Target Version => 3.0.9
2020-12-30 17:24 jsantos Assigned To => sfernandez
2020-12-30 17:24 jsantos Status new => assigned
2020-12-30 17:33 sfernandez Status assigned => feedback
2020-12-30 17:33 sfernandez Note Added: 0006936
2020-12-30 19:23 asusralis Note Added: 0006937
2020-12-30 19:23 asusralis Status feedback => assigned
2020-12-30 19:25 asusralis Note Added: 0006938
2020-12-31 11:49 sfernandez Note Added: 0006939
2020-12-31 13:12 sfernandez Status assigned => feedback
2020-12-31 13:12 sfernandez Note Added: 0006940
2021-01-03 14:48 asusralis Note Added: 0006944
2021-01-03 14:48 asusralis Status feedback => assigned
2021-01-03 14:50 asusralis Note Added: 0006945
2021-01-03 20:18 jsantos Note Added: 0006947
2021-01-07 18:58 sfernandez Status assigned => resolved
2021-01-07 18:58 sfernandez Resolution open => fixed
2021-01-07 18:58 sfernandez Fixed in Version => 3.0.9