Skip to content

Commit f04759d

Browse files
authored
Flow Breakpoint fixes (#290)
Add CanPlaceBreakpoints() functionality in UFlowGraphNode, return false on UFlowGraphNode_Reroute. In SFlowGraphEditor, in Breakpoint() functions, add conditions to check if CanPlaceBreakpoint() on the selected node is true. Also, since multiple breakpoints on nodes can be set/unset at the same time, make the checks in these functions too. Since they are in a for loop, don't return immediately at the first element, but check if it makes sense to return true on the first item that returns true. Fix breakpoints that could erroneously be added on reroute nodes through the context menu, or through F9, while not being visible at all. In UFlowDebuggerSubsystem::MarkAsHit() functions, check if the NodeBreakpoint is enabled.
1 parent 31a1c39 commit f04759d

File tree

6 files changed

+139
-28
lines changed

6 files changed

+139
-28
lines changed

Source/FlowDebugger/Private/Debugger/FlowDebuggerSubsystem.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,17 +248,23 @@ void UFlowDebuggerSubsystem::MarkAsHit(const FGuid& NodeGuid)
248248
{
249249
if (FFlowBreakpoint* NodeBreakpoint = FindBreakpoint(NodeGuid))
250250
{
251-
NodeBreakpoint->MarkAsHit(true);
252-
PauseSession();
251+
if (NodeBreakpoint->IsEnabled())
252+
{
253+
NodeBreakpoint->MarkAsHit(true);
254+
PauseSession();
255+
}
253256
}
254257
}
255258

256259
void UFlowDebuggerSubsystem::MarkAsHit(const FGuid& NodeGuid, const FName& PinName)
257260
{
258261
if (FFlowBreakpoint* PinBreakpoint = FindBreakpoint(NodeGuid, PinName))
259262
{
260-
PinBreakpoint->MarkAsHit(true);
261-
PauseSession();
263+
if (PinBreakpoint->IsEnabled())
264+
{
265+
PinBreakpoint->MarkAsHit(true);
266+
PauseSession();
267+
}
262268
}
263269
}
264270

Source/FlowEditor/Private/Graph/FlowGraphEditor.cpp

Lines changed: 116 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,7 +1119,10 @@ void SFlowGraphEditor::OnAddBreakpoint() const
11191119
check(DebuggerSubsystem.IsValid());
11201120
for (const UFlowGraphNode* SelectedNode : GetSelectedFlowNodes())
11211121
{
1122-
DebuggerSubsystem->AddBreakpoint(SelectedNode->NodeGuid);
1122+
if (SelectedNode->CanPlaceBreakpoints())
1123+
{
1124+
DebuggerSubsystem->AddBreakpoint(SelectedNode->NodeGuid);
1125+
}
11231126
}
11241127
}
11251128

@@ -1128,7 +1131,11 @@ void SFlowGraphEditor::OnAddPinBreakpoint()
11281131
check(DebuggerSubsystem.IsValid());
11291132
if (const UEdGraphPin* Pin = GetGraphPinForMenu())
11301133
{
1131-
DebuggerSubsystem->AddBreakpoint(Pin->GetOwningNode()->NodeGuid, Pin->PinName);
1134+
const UFlowGraphNode* OwningNode = Cast<const UFlowGraphNode>(Pin->GetOwningNode());
1135+
if (!OwningNode || OwningNode->CanPlaceBreakpoints())
1136+
{
1137+
DebuggerSubsystem->AddBreakpoint(Pin->GetOwningNode()->NodeGuid, Pin->PinName);
1138+
}
11321139
}
11331140
}
11341141

@@ -1137,7 +1144,13 @@ bool SFlowGraphEditor::CanAddBreakpoint() const
11371144
check(DebuggerSubsystem.IsValid());
11381145
for (const UFlowGraphNode* SelectedNode : GetSelectedFlowNodes())
11391146
{
1140-
return DebuggerSubsystem->FindBreakpoint(SelectedNode->NodeGuid) == nullptr;
1147+
if (SelectedNode->CanPlaceBreakpoints())
1148+
{
1149+
if (DebuggerSubsystem->FindBreakpoint(SelectedNode->NodeGuid) == nullptr)
1150+
{
1151+
return true;
1152+
}
1153+
}
11411154
}
11421155

11431156
return false;
@@ -1148,7 +1161,11 @@ bool SFlowGraphEditor::CanAddPinBreakpoint()
11481161
check(DebuggerSubsystem.IsValid());
11491162
if (const UEdGraphPin* Pin = GetGraphPinForMenu())
11501163
{
1151-
return DebuggerSubsystem->FindBreakpoint(Pin->GetOwningNode()->NodeGuid, Pin->PinName) == nullptr;
1164+
const UFlowGraphNode* OwningNode = Cast<const UFlowGraphNode>(Pin->GetOwningNode());
1165+
if (!OwningNode || OwningNode->CanPlaceBreakpoints())
1166+
{
1167+
return DebuggerSubsystem->FindBreakpoint(Pin->GetOwningNode()->NodeGuid, Pin->PinName) == nullptr;
1168+
}
11521169
}
11531170

11541171
return false;
@@ -1159,7 +1176,10 @@ void SFlowGraphEditor::OnRemoveBreakpoint() const
11591176
check(DebuggerSubsystem.IsValid());
11601177
for (const UFlowGraphNode* SelectedNode : GetSelectedFlowNodes())
11611178
{
1162-
DebuggerSubsystem->RemoveNodeBreakpoint(SelectedNode->NodeGuid);
1179+
if (SelectedNode->CanPlaceBreakpoints())
1180+
{
1181+
DebuggerSubsystem->RemoveNodeBreakpoint(SelectedNode->NodeGuid);
1182+
}
11631183
}
11641184
}
11651185

@@ -1168,7 +1188,11 @@ void SFlowGraphEditor::OnRemovePinBreakpoint()
11681188
check(DebuggerSubsystem.IsValid());
11691189
if (const UEdGraphPin* Pin = GetGraphPinForMenu())
11701190
{
1171-
DebuggerSubsystem->RemovePinBreakpoint(Pin->GetOwningNode()->NodeGuid, Pin->PinName);
1191+
const UFlowGraphNode* OwningNode = Cast<const UFlowGraphNode>(Pin->GetOwningNode());
1192+
if (!OwningNode || OwningNode->CanPlaceBreakpoints())
1193+
{
1194+
DebuggerSubsystem->RemovePinBreakpoint(Pin->GetOwningNode()->NodeGuid, Pin->PinName);
1195+
}
11721196
}
11731197
}
11741198

@@ -1177,7 +1201,13 @@ bool SFlowGraphEditor::CanRemoveBreakpoint() const
11771201
check(DebuggerSubsystem.IsValid());
11781202
for (const UFlowGraphNode* SelectedNode : GetSelectedFlowNodes())
11791203
{
1180-
return DebuggerSubsystem->FindBreakpoint(SelectedNode->NodeGuid) != nullptr;
1204+
if (SelectedNode->CanPlaceBreakpoints())
1205+
{
1206+
if (DebuggerSubsystem->FindBreakpoint(SelectedNode->NodeGuid) != nullptr)
1207+
{
1208+
return true;
1209+
}
1210+
}
11811211
}
11821212

11831213
return false;
@@ -1188,7 +1218,11 @@ bool SFlowGraphEditor::CanRemovePinBreakpoint()
11881218
check(DebuggerSubsystem.IsValid());
11891219
if (const UEdGraphPin* Pin = GetGraphPinForMenu())
11901220
{
1191-
return DebuggerSubsystem->FindBreakpoint(Pin->GetOwningNode()->NodeGuid, Pin->PinName) != nullptr;
1221+
const UFlowGraphNode* OwningNode = Cast<const UFlowGraphNode>(Pin->GetOwningNode());
1222+
if (!OwningNode || OwningNode->CanPlaceBreakpoints())
1223+
{
1224+
return DebuggerSubsystem->FindBreakpoint(Pin->GetOwningNode()->NodeGuid, Pin->PinName) != nullptr;
1225+
}
11921226
}
11931227

11941228
return false;
@@ -1199,7 +1233,10 @@ void SFlowGraphEditor::OnEnableBreakpoint() const
11991233
check(DebuggerSubsystem.IsValid());
12001234
for (const UFlowGraphNode* SelectedNode : GetSelectedFlowNodes())
12011235
{
1202-
DebuggerSubsystem->SetBreakpointEnabled(SelectedNode->NodeGuid, true);
1236+
if (SelectedNode->CanPlaceBreakpoints())
1237+
{
1238+
DebuggerSubsystem->SetBreakpointEnabled(SelectedNode->NodeGuid, true);
1239+
}
12031240
}
12041241
}
12051242

@@ -1208,16 +1245,26 @@ void SFlowGraphEditor::OnEnablePinBreakpoint()
12081245
check(DebuggerSubsystem.IsValid());
12091246
if (const UEdGraphPin* Pin = GetGraphPinForMenu())
12101247
{
1211-
DebuggerSubsystem->SetBreakpointEnabled(Pin->GetOwningNode()->NodeGuid, Pin->PinName, true);
1248+
const UFlowGraphNode* OwningNode = Cast<const UFlowGraphNode>(Pin->GetOwningNode());
1249+
if (!OwningNode || OwningNode->CanPlaceBreakpoints())
1250+
{
1251+
DebuggerSubsystem->SetBreakpointEnabled(Pin->GetOwningNode()->NodeGuid, Pin->PinName, true);
1252+
}
12121253
}
12131254
}
12141255

12151256
bool SFlowGraphEditor::CanEnableBreakpoint() const
12161257
{
12171258
for (const UFlowGraphNode* SelectedNode : GetSelectedFlowNodes())
12181259
{
1219-
const FFlowBreakpoint* Breakpoint = DebuggerSubsystem->FindBreakpoint(SelectedNode->NodeGuid);
1220-
return Breakpoint && !Breakpoint->IsEnabled();
1260+
if (SelectedNode->CanPlaceBreakpoints())
1261+
{
1262+
const FFlowBreakpoint* Breakpoint = DebuggerSubsystem->FindBreakpoint(SelectedNode->NodeGuid);
1263+
if (Breakpoint && !Breakpoint->IsEnabled())
1264+
{
1265+
return true;
1266+
}
1267+
}
12211268
}
12221269

12231270
return false;
@@ -1227,8 +1274,12 @@ bool SFlowGraphEditor::CanEnablePinBreakpoint()
12271274
{
12281275
if (const UEdGraphPin* Pin = GetGraphPinForMenu())
12291276
{
1230-
const FFlowBreakpoint* Breakpoint = DebuggerSubsystem->FindBreakpoint(Pin->GetOwningNode()->NodeGuid, Pin->PinName);
1231-
return Breakpoint && !Breakpoint->IsEnabled();
1277+
const UFlowGraphNode* OwningNode = Cast<const UFlowGraphNode>(Pin->GetOwningNode());
1278+
if (!OwningNode || OwningNode->CanPlaceBreakpoints())
1279+
{
1280+
const FFlowBreakpoint* Breakpoint = DebuggerSubsystem->FindBreakpoint(Pin->GetOwningNode()->NodeGuid, Pin->PinName);
1281+
return Breakpoint && !Breakpoint->IsEnabled();
1282+
}
12321283
}
12331284

12341285
return false;
@@ -1239,7 +1290,10 @@ void SFlowGraphEditor::OnDisableBreakpoint() const
12391290
check(DebuggerSubsystem.IsValid());
12401291
for (const UFlowGraphNode* SelectedNode : GetSelectedFlowNodes())
12411292
{
1242-
DebuggerSubsystem->SetBreakpointEnabled(SelectedNode->NodeGuid, false);
1293+
if (SelectedNode->CanPlaceBreakpoints())
1294+
{
1295+
DebuggerSubsystem->SetBreakpointEnabled(SelectedNode->NodeGuid, false);
1296+
}
12431297
}
12441298
}
12451299

@@ -1248,7 +1302,11 @@ void SFlowGraphEditor::OnDisablePinBreakpoint()
12481302
check(DebuggerSubsystem.IsValid());
12491303
if (const UEdGraphPin* Pin = GetGraphPinForMenu())
12501304
{
1251-
DebuggerSubsystem->SetBreakpointEnabled(Pin->GetOwningNode()->NodeGuid, Pin->PinName, false);
1305+
const UFlowGraphNode* OwningNode = Cast<const UFlowGraphNode>(Pin->GetOwningNode());
1306+
if (!OwningNode || OwningNode->CanPlaceBreakpoints())
1307+
{
1308+
DebuggerSubsystem->SetBreakpointEnabled(Pin->GetOwningNode()->NodeGuid, Pin->PinName, false);
1309+
}
12521310
}
12531311
}
12541312

@@ -1257,8 +1315,14 @@ bool SFlowGraphEditor::CanDisableBreakpoint() const
12571315
check(DebuggerSubsystem.IsValid());
12581316
for (const UFlowGraphNode* SelectedNode : GetSelectedFlowNodes())
12591317
{
1260-
const FFlowBreakpoint* Breakpoint = DebuggerSubsystem->FindBreakpoint(SelectedNode->NodeGuid);
1261-
return Breakpoint && Breakpoint->IsEnabled();
1318+
if (SelectedNode->CanPlaceBreakpoints())
1319+
{
1320+
const FFlowBreakpoint* Breakpoint = DebuggerSubsystem->FindBreakpoint(SelectedNode->NodeGuid);
1321+
if (Breakpoint && Breakpoint->IsEnabled())
1322+
{
1323+
return true;
1324+
}
1325+
}
12621326
}
12631327

12641328
return false;
@@ -1269,8 +1333,12 @@ bool SFlowGraphEditor::CanDisablePinBreakpoint()
12691333
check(DebuggerSubsystem.IsValid());
12701334
if (const UEdGraphPin* Pin = GetGraphPinForMenu())
12711335
{
1272-
const FFlowBreakpoint* Breakpoint = DebuggerSubsystem->FindBreakpoint(Pin->GetOwningNode()->NodeGuid, Pin->PinName);
1273-
return Breakpoint && Breakpoint->IsEnabled();
1336+
const UFlowGraphNode* OwningNode = Cast<const UFlowGraphNode>(Pin->GetOwningNode());
1337+
if (!OwningNode || OwningNode->CanPlaceBreakpoints())
1338+
{
1339+
const FFlowBreakpoint* Breakpoint = DebuggerSubsystem->FindBreakpoint(Pin->GetOwningNode()->NodeGuid, Pin->PinName);
1340+
return Breakpoint && Breakpoint->IsEnabled();
1341+
}
12741342
}
12751343

12761344
return false;
@@ -1281,7 +1349,10 @@ void SFlowGraphEditor::OnToggleBreakpoint() const
12811349
check(DebuggerSubsystem.IsValid());
12821350
for (const UFlowGraphNode* SelectedNode : GetSelectedFlowNodes())
12831351
{
1284-
DebuggerSubsystem->ToggleBreakpoint(SelectedNode->NodeGuid);
1352+
if (SelectedNode->CanPlaceBreakpoints())
1353+
{
1354+
DebuggerSubsystem->ToggleBreakpoint(SelectedNode->NodeGuid);
1355+
}
12851356
}
12861357
}
12871358

@@ -1290,18 +1361,39 @@ void SFlowGraphEditor::OnTogglePinBreakpoint()
12901361
check(DebuggerSubsystem.IsValid());
12911362
if (const UEdGraphPin* Pin = GetGraphPinForMenu())
12921363
{
1293-
DebuggerSubsystem->ToggleBreakpoint(Pin->GetOwningNode()->NodeGuid, Pin->PinName);
1364+
const UFlowGraphNode* OwningNode = Cast<const UFlowGraphNode>(Pin->GetOwningNode());
1365+
if (!OwningNode || OwningNode->CanPlaceBreakpoints())
1366+
{
1367+
DebuggerSubsystem->ToggleBreakpoint(Pin->GetOwningNode()->NodeGuid, Pin->PinName);
1368+
}
12941369
}
12951370
}
12961371

12971372
bool SFlowGraphEditor::CanToggleBreakpoint() const
12981373
{
1299-
return GetSelectedFlowNodes().Num() > 0;
1374+
for (const UFlowGraphNode* SelectedNode : GetSelectedFlowNodes())
1375+
{
1376+
if (SelectedNode->CanPlaceBreakpoints())
1377+
{
1378+
return true;
1379+
}
1380+
}
1381+
1382+
return false;
13001383
}
13011384

13021385
bool SFlowGraphEditor::CanTogglePinBreakpoint()
13031386
{
1304-
return GetGraphPinForMenu() != nullptr;
1387+
if (const UEdGraphPin* Pin = GetGraphPinForMenu())
1388+
{
1389+
const UFlowGraphNode* OwningNode = Cast<const UFlowGraphNode>(Pin->GetOwningNode());
1390+
if (!OwningNode || OwningNode->CanPlaceBreakpoints())
1391+
{
1392+
return true;
1393+
}
1394+
}
1395+
1396+
return false;
13051397
}
13061398

13071399
void SFlowGraphEditor::SetSignalMode(const EFlowSignalMode Mode) const

Source/FlowEditor/Private/Graph/Nodes/FlowGraphNode.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,11 @@ void UFlowGraphNode::OnGraphRefresh()
217217
ReconstructNode();
218218
}
219219

220+
bool UFlowGraphNode::CanPlaceBreakpoints() const
221+
{
222+
return true;
223+
}
224+
220225
bool UFlowGraphNode::CanCreateUnderSpecifiedSchema(const UEdGraphSchema* Schema) const
221226
{
222227
return Schema->IsA(UFlowGraphSchema::StaticClass());

Source/FlowEditor/Private/Graph/Nodes/FlowGraphNode_Reroute.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,8 @@ bool UFlowGraphNode_Reroute::ShouldDrawNodeAsControlPointOnly(int32& OutInputPin
2424
OutOutputPinIndex = 1;
2525
return true;
2626
}
27+
28+
bool UFlowGraphNode_Reroute::CanPlaceBreakpoints() const
29+
{
30+
return false;
31+
}

Source/FlowEditor/Public/Graph/Nodes/FlowGraphNode.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ class FLOWEDITOR_API UFlowGraphNode : public UEdGraphNode
7373

7474
public:
7575
virtual void OnGraphRefresh();
76+
virtual bool CanPlaceBreakpoints() const;
7677

7778
//////////////////////////////////////////////////////////////////////////
7879
// Graph node

Source/FlowEditor/Public/Graph/Nodes/FlowGraphNode_Reroute.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,6 @@ class FLOWEDITOR_API UFlowGraphNode_Reroute : public UFlowGraphNode
1414
virtual TSharedPtr<SGraphNode> CreateVisualWidget() override;
1515
virtual bool ShouldDrawNodeAsControlPointOnly(int32& OutInputPinIndex, int32& OutOutputPinIndex) const override;
1616
// --
17+
18+
virtual bool CanPlaceBreakpoints() const override;
1719
};

0 commit comments

Comments
 (0)