Skip to content

Commit

Permalink
Ensuring coroutine handles are valid before resuming them. Fixed badly
Browse files Browse the repository at this point in the history
passed action handled to coroutine handlers.
  • Loading branch information
zompi2 committed Aug 1, 2024
1 parent e299343 commit b94a2e9
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@ class ENHANCEDCODEFLOW_API UECFRunAsyncAndWait: public UECFCoroutineActionBase

void Complete(bool bStopped) override
{
CoroutineHandle.resume();
if (bHasValidCoroutineHandle)
{
CoroutineHandle.resume();
}
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ class ENHANCEDCODEFLOW_API UECFWaitSeconds : public UECFCoroutineActionBase

void Complete(bool bStopped) override
{
CoroutineHandle.resume();
if (bHasValidCoroutineHandle)
{
CoroutineHandle.resume();
}
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ class ENHANCEDCODEFLOW_API UECFWaitTicks : public UECFCoroutineActionBase

void Complete(bool bStopped) override
{
CoroutineHandle.resume();
if (bHasValidCoroutineHandle)
{
CoroutineHandle.resume();
}
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ class ENHANCEDCODEFLOW_API UECFWaitUntil : public UECFCoroutineActionBase

void Complete(bool bStopped) override
{
CoroutineHandle.resume();
if (bHasValidCoroutineHandle)
{
CoroutineHandle.resume();
}
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class ENHANCEDCODEFLOW_API UECFCoroutineActionBase : public UECFActionBase
if (bHasValidCoroutineHandle)
{
CoroutineHandle.destroy();
bHasValidCoroutineHandle = false;
}
Super::BeginDestroy();
}
Expand All @@ -33,15 +34,15 @@ class ENHANCEDCODEFLOW_API UECFCoroutineActionBase : public UECFActionBase
// Coroutine handle used to control the coroutine inside the Action.
FECFCoroutineHandle CoroutineHandle;

//
// Flag indicating if the coroutine handle is valid and safe to be destroyed.
bool bHasValidCoroutineHandle = false;

private:

// Setting up action. The same as in ActionBase, but it additionally sets the coroutine handle.
void SetCoroutineAction(const UObject* InOwner, FECFCoroutineHandle InCoroutineHandle, const FECFHandle& InHandleId, const FECFActionSettings& InSettings)
{
UECFActionBase::SetAction(InOwner, HandleId, {}, InSettings);
UECFActionBase::SetAction(InOwner, InHandleId, {}, InSettings);
CoroutineHandle = InCoroutineHandle;
bHasValidCoroutineHandle = true;
}
Expand Down

0 comments on commit b94a2e9

Please sign in to comment.