Skip to content

Commit

Permalink
Fixed crash that happens when changing a component name
Browse files Browse the repository at this point in the history
  • Loading branch information
adamkewley committed Apr 7, 2022
1 parent 7e210f0 commit b95fc98
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Screens/ModelEditorScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@ static void DrawTopLevelMembersEditor(osc::UndoableUiModel& st)
{
if (std::strlen(nambuf) > 0)
{
st.updSelected()->setName(nambuf);
OpenSim::Component* selectedComponent = st.updSelected();
selectedComponent->setName(nambuf);
st.setSelected(selectedComponent); // CARE: the selection depends on the name of the component
st.commit("changed component name");
}
}
Expand Down Expand Up @@ -1242,6 +1244,12 @@ class osc::ModelEditorScreen::Impl final {
DrawTopLevelMembersEditor(uim);
}

// top-level member edits may have changed this
if (!uim.getSelected())
{
return;
}

// property editors
{
auto maybeUpdater = m_ObjectPropsEditor.draw(*uim.getSelected());
Expand Down

0 comments on commit b95fc98

Please sign in to comment.