#FScopedTransaction

1 messages · Page 1 of 1 (latest)

livid ice
#

didn't mean to create a thread sorry

#

it's also not taking into account added instances, so the transaction effectively does nothing

quasi escarp
#

no worries

hmm, that's strange :\

livid ice
#

yeah, going off of all the internal uses of AddInstancedComponent it seems like I'm doing it right, and yet it's not working

quasi escarp
#

don't know if this matters but have you tried calling actor Modify right after instantiating the transaction buffer? also as a matter of cleanliness you would normally wrap the transaction in { scope } braces and have the transaction call and maybe Modify as the first two lines within the scope

livid ice
quasi escarp
#

hmm, well i have had some issues with scope transaction but it usually worked. i have been using this instead in my code, in case you want to try a different mechanism:


#define LOCTEXT_NAMESPACE "FlowYap"

#include "Yap/FlowYapTransactions.h"

#include "Editor/TransBuffer.h"

void FFlowYapTransactions::BeginModify(FText TransactionText, UObject* Object)
{
    // TODO change all this old shit to GEditor->BeginTransaction, EndTransaction
    if (GEditor && GEditor->Trans)
    {
        UTransBuffer* TransBuffer = CastChecked<UTransBuffer>(GEditor->Trans);
        if (TransBuffer != nullptr)
            TransBuffer->Begin(*FString("FlowYap"), TransactionText);
    }
    
    if (IsValid(Object))
    {
        Object->Modify();
    }
}

void FFlowYapTransactions::EndModify()
{
    if (GEditor && GEditor->Trans)
    {
        UTransBuffer* TransBuffer = CastChecked<UTransBuffer>(GEditor->Trans);
        if (TransBuffer != nullptr)
            TransBuffer->End();
    }
}

#undef LOCTEXT_NAMESPACE
#

header

#pragma once

class FFlowYapTransactions
{
public:
    static void BeginModify(FText TransactionText, UObject* Object);

    static void EndModify();
};
#

pretty simple usage - wrap your code in the two calls