Editor crash when selecting meshes in Paint mode

Note: I have created a pull request here.

Hello,

The editor keeps crashing when I select some meshes in paint mode. Here is how to reproduce this bug:

  • Create two instances of the same mesh.
  • Go into Paint Mode
  • Select the first instance (Ctrl+Alt+Click)
  • Select the second instance (Ctrl+Alt+Click)
  • Deselect the second instance (Ctrl+Alt+Click)
  • Select the second instance again (Ctrl+Alt+Click)

I have been able to fix this by patching the file “Source\Editor\MeshPaint\Private\MeshPaintStaticMeshAdapter.cpp”. I added the following piece of code at line 183. (See the pull request here).

	StaticMeshReferencers->NumReferencers--;
//Patch start
	StaticMeshReferencers->Referencers.RemoveAllSwap(
		[=](const FStaticMeshReferencers::FReferencersInfo& Info)
		{
			return Info.StaticMeshComponent == this->StaticMeshComponent;
		}
	);
//Patch end

	// If the last reference was removed, restore the body setup for all the mesh components which referenced it.

Basically, it removes references to meshes that were deselected. This way, the check at line 125 will not be triggered next time you select the item. This seems straight-forward enough, but I would like to make sure this has no side effect.

Thank you for your help!

Using your steps above I was not able to get the crash you’ve listed the steps for.

I tried this in 4.11 and 4.12 but no luck. Not sure if I’m missing something from your description.

When I tried this I added the sphere mesh from the modes panel and made a copy of that. If you have another way of producing the crash or I missed something please let me know.

If you wouldn’t mind also including the callstack and log from the project that crashes I can attach this to a JIRA once I’m able to reproduce on my end and submit the ticket.

Thank you!

Tim