Editor can promote notconnectable Pins to Variable and connects them

I’m working on a custom node, which has a unconnectable Pin (bNotConnectable=true).
But in the editor i can promote such a pin and the editor connects them.

The function is probably EdGraphSchema_K2.cpp’s bool UEdGraphSchema_K2::CanPromotePinToVariable( const UEdGraphPin& Pin ) const

bool UEdGraphSchema_K2::CanPromotePinToVariable( const UEdGraphPin& Pin ) const
{
	const FEdGraphPinType& PinType = Pin.PinType;
	bool bCanPromote = (PinType.PinCategory != PC_Wildcard && PinType.PinCategory != PC_Exec ) ? true : false;

	const UK2Node* Node = Cast<UK2Node>(Pin.GetOwningNode());
	const UBlueprint* OwningBlueprint = Node->GetBlueprint();
	
	if (!OwningBlueprint || (OwningBlueprint->BlueprintType == BPTYPE_MacroLibrary) || (OwningBlueprint->BlueprintType == BPTYPE_FunctionLibrary) || IsStaticFunctionGraph(Node->GetGraph()))
	{
		// Never allow promotion in macros, because there's not a scope to define them in
		bCanPromote = false;
	}
	else
	{
		if (PinType.PinCategory == PC_Delegate)
		{
			bCanPromote = false;
		}
		else if ((PinType.PinCategory == PC_Object) || (PinType.PinCategory == PC_Interface))
		{
			if (PinType.PinSubCategoryObject != NULL)
			{
				if (UClass* Class = Cast<UClass>(PinType.PinSubCategoryObject.Get()))
				{
					bCanPromote = UEdGraphSchema_K2::IsAllowableBlueprintVariableType(Class);
				}	
			}
		}
		else if ((PinType.PinCategory == PC_Struct) && (PinType.PinSubCategoryObject != NULL))
		{
			if (UScriptStruct* Struct = Cast<UScriptStruct>(PinType.PinSubCategoryObject.Get()))
			{
				bCanPromote = UEdGraphSchema_K2::IsAllowableBlueprintVariableType(Struct);
			}
		}
	}
	
	return bCanPromote;
}

There is no check for the pin’s bNotConnectable property.
Also in the calling functions TryInsertPromoteToVariable (SBlueprintActionMenu.cpp) and CanPromoteToVariable (BlueprintEditor.cpp) the check is missing.

PS: Probably a good idea to check the context menu creator functions too, Promote to Variable shouldnt be active.

Hey -

Where are you editing the bNotConnectable variable? Are you editing the default value in the source file EdGraphPin or are you using the variable in your own class and overriding its value? Can you post the code where you’re using bNotConnectable?

Cheers

Code is here https://github.com//klawr/blob/develop/Engine/Plugins/Klawr/KlawrEditorPlugin/Source/KlawrEditorPlugin/Private/BPNode_KlawrFunctionCall.cpp
Line 72, where i allocate my default pins. Is there another way to make a pin not connectable? Because i only need it for holding a value chosen by a context-menu click.

see ‘answer’ below…

wrong button sickness had me again :slight_smile:

Hey -

I have entered a bug report (UE-24461) to investigate promoting a pin to a variable after setting bNotConnectable. If the setting is working otherwise (can’t connect other pins to a bNotConnectable pin) then you should be okay to continue using it.

Cheers