diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index fe0a5915e..c69baabc2 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -20,6 +20,8 @@ v0.9.2 (WIP): CHANGE: Editor: Unary operator- for ImVec2 is defined by ImGui since r18955 (#248) + CHANGE: Editor: Ensure CreateItemAction is not activated fom invalid state, thanks @pthom + BUGFIX: Editor: Correctly initialize 'width' for view resize code (thx @gnif) BUGFIX: Examples: Handle node deletion before links (#182) @@ -45,6 +47,8 @@ v0.9.2 (WIP): BUGFIX: Editor: Don't call Canvas.End() when Canvas.Begin() failed (#186), thanks @pthom, @TheZoc + BUGFIX: Examples: Call ed::EndCreate() and ed::EndDelete() only when ed::BeginCreate() and ed::BeginDelete() returned true + v0.9.1 (2022-08-27): diff --git a/examples/basic-interaction-example/basic-interaction-example.cpp b/examples/basic-interaction-example/basic-interaction-example.cpp index 425353351..cc8fbf66b 100644 --- a/examples/basic-interaction-example/basic-interaction-example.cpp +++ b/examples/basic-interaction-example/basic-interaction-example.cpp @@ -153,8 +153,8 @@ struct Example: // visual feedback by changing link thickness and color. } } + ed::EndCreate(); // Wraps up object creation action handling. } - ed::EndCreate(); // Wraps up object creation action handling. // Handle deletion action @@ -181,9 +181,8 @@ struct Example: // You may reject link deletion by calling: // ed::RejectDeletedItem(); } + ed::EndDelete(); // Wrap up deletion action } - ed::EndDelete(); // Wrap up deletion action - // End of interaction with editor. diff --git a/examples/blueprints-example/blueprints-example.cpp b/examples/blueprints-example/blueprints-example.cpp index f72f3ad14..1b7fdc1c0 100644 --- a/examples/blueprints-example/blueprints-example.cpp +++ b/examples/blueprints-example/blueprints-example.cpp @@ -1543,12 +1543,12 @@ struct Example: ed::Resume(); } } + + ed::EndCreate(); } else newLinkPin = nullptr; - ed::EndCreate(); - if (ed::BeginDelete()) { ed::NodeId nodeId = 0; @@ -1572,8 +1572,9 @@ struct Example: m_Links.erase(id); } } + + ed::EndDelete(); } - ed::EndDelete(); } ImGui::SetCursorScreenPos(cursorTopLeft); diff --git a/examples/widgets-example/widgets-example.cpp b/examples/widgets-example/widgets-example.cpp index 64314261a..c6f741aaa 100644 --- a/examples/widgets-example/widgets-example.cpp +++ b/examples/widgets-example/widgets-example.cpp @@ -384,8 +384,8 @@ struct Example: } } } + ed::EndCreate(); } - ed::EndCreate(); // Handle deletion action --------------------------------------------------------------------------- if (ed::BeginDelete()) @@ -405,8 +405,8 @@ struct Example: } } } + ed::EndDelete(); } - ed::EndDelete(); ed::End(); ed::SetCurrentEditor(nullptr); diff --git a/imgui_node_editor.cpp b/imgui_node_editor.cpp index 41ba6f025..267d77bc4 100644 --- a/imgui_node_editor.cpp +++ b/imgui_node_editor.cpp @@ -4709,15 +4709,15 @@ bool ed::CreateItemAction::Begin() { IM_ASSERT(false == m_InActive); + if (m_NextStage == None) + return false; + m_InActive = true; m_CurrentStage = m_NextStage; m_UserAction = Unknown; m_LinkColor = IM_COL32_WHITE; m_LinkThickness = 1.0f; - if (m_CurrentStage == None) - return false; - m_LastChannel = Editor->GetDrawList()->_Splitter._Current; return true; @@ -4725,7 +4725,7 @@ bool ed::CreateItemAction::Begin() void ed::CreateItemAction::End() { - IM_ASSERT(m_InActive); + IM_ASSERT(m_InActive && "Please call End() only when Begin() was successful"); if (m_IsInGlobalSpace) {