Skip to content

Commit 01fa1b9

Browse files
committedSep 1, 2023
Editor: Ensure CreateItemAction is not activated fom invalid state, thanks @pthom
1 parent 388e925 commit 01fa1b9

File tree

5 files changed

+18
-12
lines changed

5 files changed

+18
-12
lines changed
 

‎docs/CHANGELOG.txt

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
v0.10.0 (WIP):
22

3+
BREAKING: Editor: Ensure CreateItemAction is not activated fom invalid state, thanks @pthom
4+
From this point ed::EndCreate() and ed::EndDelete() can only be called when
5+
ed::BeginCreate() and ed::BeginDelete() calls were successful.
6+
7+
BUGFIX: Examples: Call ed::EndCreate() and ed::EndDelete() only when ed::BeginCreate() and ed::BeginDelete() returned true
8+
39

410
v0.9.2 (2023-09-01):
511

‎examples/basic-interaction-example/basic-interaction-example.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ struct Example:
153153
// visual feedback by changing link thickness and color.
154154
}
155155
}
156+
ed::EndCreate(); // Wraps up object creation action handling.
156157
}
157-
ed::EndCreate(); // Wraps up object creation action handling.
158158

159159

160160
// Handle deletion action
@@ -181,9 +181,8 @@ struct Example:
181181
// You may reject link deletion by calling:
182182
// ed::RejectDeletedItem();
183183
}
184+
ed::EndDelete(); // Wrap up deletion action
184185
}
185-
ed::EndDelete(); // Wrap up deletion action
186-
187186

188187

189188
// End of interaction with editor.

‎examples/blueprints-example/blueprints-example.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -1543,12 +1543,12 @@ struct Example:
15431543
ed::Resume();
15441544
}
15451545
}
1546+
1547+
ed::EndCreate();
15461548
}
15471549
else
15481550
newLinkPin = nullptr;
15491551

1550-
ed::EndCreate();
1551-
15521552
if (ed::BeginDelete())
15531553
{
15541554
ed::NodeId nodeId = 0;
@@ -1572,8 +1572,9 @@ struct Example:
15721572
m_Links.erase(id);
15731573
}
15741574
}
1575+
1576+
ed::EndDelete();
15751577
}
1576-
ed::EndDelete();
15771578
}
15781579

15791580
ImGui::SetCursorScreenPos(cursorTopLeft);

‎examples/widgets-example/widgets-example.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -384,8 +384,8 @@ struct Example:
384384
}
385385
}
386386
}
387+
ed::EndCreate();
387388
}
388-
ed::EndCreate();
389389

390390
// Handle deletion action ---------------------------------------------------------------------------
391391
if (ed::BeginDelete())
@@ -405,8 +405,8 @@ struct Example:
405405
}
406406
}
407407
}
408+
ed::EndDelete();
408409
}
409-
ed::EndDelete();
410410

411411
ed::End();
412412
ed::SetCurrentEditor(nullptr);

‎imgui_node_editor.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -4709,23 +4709,23 @@ bool ed::CreateItemAction::Begin()
47094709
{
47104710
IM_ASSERT(false == m_InActive);
47114711

4712+
if (m_NextStage == None)
4713+
return false;
4714+
47124715
m_InActive = true;
47134716
m_CurrentStage = m_NextStage;
47144717
m_UserAction = Unknown;
47154718
m_LinkColor = IM_COL32_WHITE;
47164719
m_LinkThickness = 1.0f;
47174720

4718-
if (m_CurrentStage == None)
4719-
return false;
4720-
47214721
m_LastChannel = Editor->GetDrawList()->_Splitter._Current;
47224722

47234723
return true;
47244724
}
47254725

47264726
void ed::CreateItemAction::End()
47274727
{
4728-
IM_ASSERT(m_InActive);
4728+
IM_ASSERT(m_InActive && "Please call End() only when Begin() was successful");
47294729

47304730
if (m_IsInGlobalSpace)
47314731
{

0 commit comments

Comments
 (0)
Please sign in to comment.