Choosing "Create Slate Brush" from Texture Context menu generates ensure about FSlateDynamicImageBrush usage

Ensure condition failed: false [File:C:\fbroot\Engine\Source\Runtime\SlateCore\Public\Brushes\SlateDynamicImageBrush.h] [Line: 120]

This hack usually results in a crash during loading screens in slate. Please change any code that arrives here to not use FSlateDynamicImageBrush. In the case of loading screens, you can use FDeferredCleanupSlateBrush. Which correctly accounts for both GC lifetime, and the lifetime of the object through the slate rendering pipeline which may be several frames after you stop using it.

Trying to keep our ensure count down, so just noticed this one and trying to be a good reporting citizen.

Seems to come from SlateDynamicImageBrush.h:

// @todo Slate - Hack:  This is to address an issue where the brush created and a GC occurs before the brush resource object becomes referenced
// by the Slate resource manager. Don't add objects that are already in root set (and mark them as such) to avoid incorrect removing objects
// from root set in destructor.
if (!Object->IsRooted())
{
    ensureMsgf(false, TEXT("This hack usually results in a crash during loading screens in slate.  Please change any code that arrives here to not use FSlateDynamicImageBrush.  In the case of loading screens, you can use FDeferredCleanupSlateBrush.  Which correctly accounts for both GC lifetime, and the lifetime of the object through the slate rendering pipeline which may be several frames after you stop using it."));

    Object->AddToRoot();
    bRemoveResourceFromRootSet = true;
}

[Attachment Removed]

Steps to Reproduce

  1. Right-click on a Texture in the Content Browser
  2. Click “Create Slate Brush”
  3. Note immediate ensure

[Attachment Removed]

Hi,

Thanks for reporting this! I think it should be fairly benign, but I’ve filed bug report UE-378302 so we can get this fixed up.

Best,

Cody

[Attachment Removed]