anton.sodergren_pdx
Topic Author
Posts: 21
Joined: 24 Mar 2022, 17:10

TextBlock inlines unloaded event

01 Dec 2023, 14:11

Hello, we have some code where we rely on the Unloaded event to be executed for the UI element that the user is currently hovering over as we have some custom logic for keeping track of what is being hovered over. However, we have run into an issue where the Unloaded event is not always fired, and I have tracked down that it is specifically Inline elements within TextBlocks that don't have the Unloaded event fire when the parent containing them is removed. This currently results in a crash if an in-game-window is closed while the user is hovering over an Inline element within the window.

There are some things we can do to work around this, such as using the TextBlock containing the inlines instead of to the inlines themselves for keeping track of mouse hover. But I was wondering if this could be a bug in Noesis, or if it is intended that inlines don't have the Unloaded event trigger?

I could add as well that we are not using the default TextBlock, but rather our own ParsedTextBlock class, but that one simply inherits from TextBlock and populates the Inline collection that already exists in it, so that really shouldn't cause this. I have also only noticed this being an issue recently, after we updated from Noesis 3.1.4 to 3.2.2, but I have not confirmed whether the Noesis version is the cause of it.
 
User avatar
sfernandez
Site Admin
Posts: 3363
Joined: 22 Dec 2011, 19:20

Re: TextBlock inlines unloaded event

01 Dec 2023, 20:34

This looks like a bug in Noesis, because the Unloaded event should be fired when the TextBlock is disconnected from the View. Could you please report this in our bugtracker?

Regarding the crash, is it happening in Noesis code or in your game as a result of not receiving the Unloaded event? In case it is in Noesis, could you attach a crash dump for this too?
 
anton.sodergren_pdx
Topic Author
Posts: 21
Joined: 24 Mar 2022, 17:10

Re: TextBlock inlines unloaded event

04 Dec 2023, 10:27

The crash itself is on our end, so no need to worry about that.

I analyzed the issue further, testing with a regular TextBlock. What I found was that when adding the inlines in XAML, it seems to work fine and doesn't cause a crash, regardless of whether I use TextBlock or our ParsedTextBlock. But when adding the inlines in code via ParsedTextBlock (and likely using code-behind on a normal TextBlock), the issue happens. Not sure if we're doing something wrong or missing something when adding inlines, but what we're doing in simple cases essentially boils down to this:
Noesis::InlineCollection& Inlines = *GetInlines();
const auto Run = Noesis::MakePtr<Noesis::Run>();
Run->SetText( Text );
Inlines.Add( Run );
I'll make an issue in the bug tracker, unless you see something that is obviously wrong or missing in the snippet above.
 
anton.sodergren_pdx
Topic Author
Posts: 21
Joined: 24 Mar 2022, 17:10

Re: TextBlock inlines unloaded event

04 Dec 2023, 13:02

Created a bug ticket for this now: https://www.noesisengine.com/bugs/view.php?id=2915
 
User avatar
sfernandez
Site Admin
Posts: 3363
Joined: 22 Dec 2011, 19:20

Re: TextBlock inlines unloaded event

04 Dec 2023, 13:06

Nothing wrong on your code, so we will need to investigate what is going on. Thanks for the report!

Who is online

Users browsing this forum: Google [Bot] and 4 guests