Skip to content

Commit

Permalink
Fixed Issue where editor would remove a parent node (which would resu…
Browse files Browse the repository at this point in the history
…lt in removal of child node) and then attempt to remove child node again resulting in a crash.
  • Loading branch information
TrevorCash committed May 4, 2018
1 parent 1909e52 commit 67a9c67
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Source/Tools/Editor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ if (NOT URHO3D_SYSTEMUI)
endif ()

file (GLOB_RECURSE SOURCE_FILES *.cpp *.h *.hpp)
add_executable (Editor WIN32 ${SOURCE_FILES})
add_executable (Editor ${SOURCE_FILES})
target_link_libraries (Editor Toolbox Urho3D nativefiledialog)
install(TARGETS Editor RUNTIME DESTINATION ${DEST_TOOLS_DIR})
15 changes: 13 additions & 2 deletions Source/Tools/Editor/Tabs/Scene/SceneTab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -858,11 +858,22 @@ void SceneTab::OnEditorUserCodeReLoadStart(StringHash event, VariantMap& data)
Pause();
SceneStateSave();
PODVector<Node*> nodes = GetScene()->GetChildren(true);
//copy vector to temp vector of shared pts just in case we remove a parent node in the scene in the next pass below.
Vector<SharedPtr<Node>> nodesSharedPtrs;
for (Node* node : nodes)
{
if (!node->HasTag("__EDITOR_OBJECT__"))
node->Remove();
nodesSharedPtrs.Push(SharedPtr<Node>(node));
}

//remove what we need from the scene graph..
for (SharedPtr<Node> node : nodesSharedPtrs)
{
if(node.NotNull())
if (!node->HasTag("__EDITOR_OBJECT__"))
node->Remove();
}

//shared ptrs released so actual nodes that need released will be released at this point.
}

}

0 comments on commit 67a9c67

Please sign in to comment.