Editor randomly crashes when DisableInput is called

I’ve set up an inventory toggle input, and when the button is pressed, all the inputs coming from the player need to be disabled, on top of ignoring look and move inputs. I specify “player” here because I have axis inputs defined in the controller while actions are bound in the player character class

Code

void AProtagonistController::ToggleInventory()
{
    if(!bIsInventoryOpen)
    {
        WidgetInventory->AddToViewport();
        aControlledCharacter->DisableInput(this); // This is the Character actor controlled by this player controller. This is also the line 86 referenced in the crash log
        SetIgnoreLookInput(true);
        SetIgnoreMoveInput(true);
        bIsInventoryOpen = true;
        bShowMouseCursor = true;
        bEnableMouseOverEvents = true;
    }
    else
    {
        WidgetInventory->RemoveFromViewport();
        aControlledCharacter->EnableInput(this);
        ResetIgnoreLookInput();
        ResetIgnoreMoveInput();
        bShowMouseCursor = false;
        bEnableMouseOverEvents = false;
        bIsInventoryOpen = false;
    }
}
Unhandled Exception: EXCEPTION_ACCESS_VIOLATION 0x000000003f800000

UnrealEditor_Project_patch_1!AProtagonistController::ToggleInventory() [C:\Users\user\Documents\Unreal Projects\Project\Source\Project\Private\ProtagonistController.cpp:86]
UnrealEditor_Project_patch_1!TBaseUObjectMethodDelegateInstance<0,AProtagonistController,void __cdecl(void),FDefaultDelegateUserPolicy>::Execute() [C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\Delegates\DelegateInstancesImpl.h:594]
UnrealEditor_Engine!FInputActionUnifiedDelegate::Execute() [D:\build\++UE5\Sync\Engine\Source\Runtime\Engine\Classes\Components\InputComponent.h:288]
UnrealEditor_Engine!UPlayerInput::ProcessInputStack() [D:\build\++UE5\Sync\Engine\Source\Runtime\Engine\Private\UserInterface\PlayerInput.cpp:1419]
UnrealEditor_Engine!APlayerController::ProcessPlayerInput() [D:\build\++UE5\Sync\Engine\Source\Runtime\Engine\Private\PlayerController.cpp:2609]
UnrealEditor_Engine!APlayerController::TickPlayerInput() [D:\build\++UE5\Sync\Engine\Source\Runtime\Engine\Private\PlayerController.cpp:4762]
UnrealEditor_Engine!APlayerController::PlayerTick() [D:\build\++UE5\Sync\Engine\Source\Runtime\Engine\Private\PlayerController.cpp:2234]

This behavior happens at random so I have no idea how to reproduce it

Does aControlledCharacter have the macro UPROPERTY above it?
If not then perhaps it’s being garbage collected with time?

Could also be an error regarding delegates further down. Are you binding something in the constructor to one?

1 Like

I didn’t set the UPROPERTY, I’ll try that. Consider that I’m accessing the inventory at the editor start up since I’m testing/developing it right now, so that’s why I didn’t even think of garbage collection.

As for the constructors, the controller is setting up “aControlledCharacter” and creating a UserWidget for the hud, the actual player character is just creating its actor/scene components.

I’ll keep on going testing it with the UPROPERTY macro set, if I don’t get the error again for a day I’ll close this question and assume that was the reason