fpwong / BlueprintAssistWiki

47 stars 2 forks source link

Crash because of unsafe casting #184

Closed heinerlohmann closed 2 months ago

heinerlohmann commented 3 months ago

Hello, The following code in BlueprintAssistBlueprintActions.cpp assumes that any Editor for an Asset derived from UBlueprint must be an FBlueprintEditor.

bool FBABlueprintActionsBase::HasOpenBlueprintEditor() const
{
    FBlueprintEditor* BPEditor = FBAMiscUtils::GetEditorFromActiveTabCasted<UBlueprint, FBlueprintEditor>();
    return BPEditor != nullptr && BPEditor->InEditingMode();
}

This is unsafe and BPEditor->InEditingMode() will crash the Application if it's not the case. Could you maybe change the code to this?

bool FBABlueprintActionsBase::HasOpenBlueprintEditor() const
{
    FBlueprintEditor* BPEditor = FBAMiscUtils::GetEditorFromActiveTabCasted<UBlueprint, FBlueprintEditor>();
    return BPEditor != nullptr && BPEditor->IsBlueprintEditor() && BPEditor->InEditingMode();
}

That way it should be safe and not crash anymore for my custom Assets that are technically UBlueprints but do not use an FBlueprintEditor.

Thank you so much for the good work, I can't imagine working on BPs without your plugin anymore! Best regards, Heiner

fpwong commented 3 months ago

Hi @heinerlohmann, will add this to the next update👍

heinerlohmann commented 3 months ago

Awesome, thanks! 👍

fpwong commented 2 months ago

Added in https://github.com/fpwong/BlueprintAssistWiki/releases/tag/4.2.19