It’s the FSlateGameResources instance that stops the resources within the brushes from being GC’d, however it looks like you’re just creating that temporarily in your constructor and then throwing it away?
You can either store that as a member of your widget so that it stays alive as along as the widget needs it, or, and probably preferentially, you may to want to store that somewhere more centralised so that multiple widgets can grab their style information from it. FVehicleStyle from the VehicleGame sample provides an example of a centralised FSlateGameResources instance (it also adds in a font since it pre-dates the Slate composite font support, but you can probably just ignore that).
Another topic link to that, how do you manage DynamicMaterialInstace in slate?
I mean I’m able to retrieve the MaterialBrush, get the ressource behind it to create a DynamicMaterialInstance but I have an issue when the widget is destroyed.
In fact, when you create a DMI yo need to specify a UObject as the outer, so I used the HUD Uobject as the Slate Widget classes are Raw C++.
But, I can’t find a way to clean this properly and not crash when my Widget is destroyed.
Slate does not manage dynamic material instances for you. You need to do that yourself. The standard method is to reference your dynamic material instance on another UObject so it is not destroyed by garbage collection. When your widget is done with it you can null out the reference to the material on the other object to ensure it is released by garbage collection.
It is unclear how you are crashing so please provide some more info and the callstack.
Sorry for the delayed response and thank you for including the requested information. The crash you reported is still being investigated to understand what is causing it. If possible could you send us the project that is crashing so that we can take a look directly to help us determine what is happening?
I’ve not been able to reproduce this myself. Would it be possible to send a small sample project if you’re able to reproduce the crash in a new project with no additional content?