arnaud-jamin / Cog

Cog is a set of debug tools for Unreal Engine built on top of Dear ImGui
MIT License
357 stars 44 forks source link

Compiler error during packaging #24

Closed Vaei closed 10 months ago

Vaei commented 10 months ago

Packaging for Switch results in:

CogWindowWidgets.cpp(803,37): error: temporary whose address is used as value of local variable 'ActorName' will be destroyed at the end of the full-expression [-Werror,-Wdangling]

Due to this line (803):

const char* ActorName = TCHAR_TO_ANSI(*FCogWindowHelper::GetActorName(*Actor));

From this code block in the function FCogWindowWidgets::ActorsList:

TArray<AActor*> Actors;
for (TActorIterator It(&World, ActorClass); It; ++It)
{
    AActor* Actor = *It;

    bool AddActor = true;
    if (Filter != nullptr && Filter->IsActive())
    {
        const char* ActorName = TCHAR_TO_ANSI(*FCogWindowHelper::GetActorName(*Actor));
        if (Filter != nullptr && Filter->PassFilter(ActorName) == false)
        {
            AddActor = false;
        }
    }

    if (AddActor)
    {
        Actors.Add(Actor);
    }
}

The fix is simply not storing it. This:

const char* ActorName = TCHAR_TO_ANSI(*FCogWindowHelper::GetActorName(*Actor));
if (Filter != nullptr && Filter->PassFilter(ActorName) == false)
{
    AddActor = false;
}

Becomes:

if (Filter != nullptr && Filter->PassFilter(TCHAR_TO_ANSI(*FCogWindowHelper::GetActorName(*Actor))) == false)
{
    AddActor = false;
}

With this change my Switch build packages successfully.

I would do a PR but unfortunately because its a project and not the plugin on it's own I can't clone it into my own project easily.

arnaud-jamin commented 10 months ago

Should be fixed with https://github.com/arnaud-jamin/Cog/commit/e773b6636fcebf3b9c12417988e1593aa5519e64 Thanks!