AActor::SetFolderPath stack overflow (fix included)

AActor::SetFolderPath contains a pretty severe bug.

It recursively calls itself for all owners of the actor’s RootComp->AttachChildren but fails to verify that these owners are not the actor itself.

If RootComp->AttachParent is null, the second call to SetFolderPath will exit immediately at the start of the function so in many cases the function will work. But if RootComp->AttachParent is non null and bDetachFromParent is false, then the function will call itself ad-infinitum and cause a stack overflow.

An obvious fix is to replace:



if(ChildActor && ChildActor != this)

How to reproduce:

  1. In a map, create two actors.
  2. Put them under a folder in the map hierarchy.
  3. Put one of them under the other in the map hierarchy.
  4. Rename the folder.
  5. Notice the Editor freezes for a few seconds, then pops up a stack overflow dialog.


Hey Laurent-

The SetFolderPath() function definition changed between 4.8 and 4.9. The if(ChildActor) is no longer in the function, possibly as a way to handle the stack overflow you mentioned. Let us know if you have any issues moving assets between folders in 4.9.


Hey , thanks for your reply.

I just checked the 4.9 ActorEditor.cpp and the way it is structured does indeed fix the problem. I must say that the 4.8 version of SetFolderPath was not really nice to look at and tried to do too many things at once (and failed), the 4.9 is much cleaner and separates concerns appropriately.

For people who are stuck with 4.8 like I am, my fix should solve most of the issues with SetFolderPath. :slight_smile: