You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
Do not allow new transaction to be created while in the midst of loading packages or post loading objects Temporarily shelve an opened transaction while ticking async loading in the main thread and consider this scope as "loading packages" #rb Jamie.Dale [CL 15397637 by Francis Hurteau in ue5-main branch]
58 lines
1.4 KiB
C++
58 lines
1.4 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
#include "ScopedTransaction.h"
|
|
#include "Framework/Application/SlateApplication.h"
|
|
#include "Editor.h"
|
|
|
|
FScopedTransaction::FScopedTransaction(const FText& SessionName, const bool bShouldActuallyTransact )
|
|
{
|
|
Construct( TEXT(""), SessionName, NULL, bShouldActuallyTransact);
|
|
}
|
|
|
|
FScopedTransaction::FScopedTransaction(const TCHAR* TransactionContext, const FText& SessionName, UObject* PrimaryObject, const bool bShouldActuallyTransact)
|
|
{
|
|
Construct( TransactionContext, SessionName, PrimaryObject, bShouldActuallyTransact);
|
|
}
|
|
|
|
void FScopedTransaction::Construct (const TCHAR* TransactionContext, const FText& SessionName, UObject* PrimaryObject, const bool bShouldActuallyTransact)
|
|
{
|
|
if( bShouldActuallyTransact && GEditor && GEditor->CanTransact() && ensure(!GIsTransacting))
|
|
{
|
|
Index = GEditor->BeginTransaction( TransactionContext, SessionName, PrimaryObject );
|
|
check( IsOutstanding() );
|
|
}
|
|
else
|
|
{
|
|
Index = -1;
|
|
}
|
|
}
|
|
|
|
FScopedTransaction::~FScopedTransaction()
|
|
{
|
|
if ( IsOutstanding() )
|
|
{
|
|
GEditor->EndTransaction();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Cancels the transaction. Reentrant.
|
|
*/
|
|
void FScopedTransaction::Cancel()
|
|
{
|
|
if ( IsOutstanding() )
|
|
{
|
|
GEditor->CancelTransaction( Index );
|
|
Index = -1;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @return true if the transaction is still outstanding (that is, has not been cancelled).
|
|
*/
|
|
bool FScopedTransaction::IsOutstanding() const
|
|
{
|
|
return Index >= 0;
|
|
}
|