From 73eacaf08f695bb3261f072d82ba9fe88366f1c1 Mon Sep 17 00:00:00 2001 From: Thales Lima Oliveira Date: Mon, 29 May 2017 20:51:26 -0300 Subject: Unit data and control import bugs fixed --- Project/ControlEditor.cpp | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'Project/ControlEditor.cpp') diff --git a/Project/ControlEditor.cpp b/Project/ControlEditor.cpp index 4ee12ac..c86477d 100644 --- a/Project/ControlEditor.cpp +++ b/Project/ControlEditor.cpp @@ -735,18 +735,7 @@ void ControlEditor::OnImportClick(wxCommandEvent& event) msgDialog.ShowModal(); } - // Get the highest id number - int majorElementID = 0; - for(auto it = m_elementList.begin(), itEnd = m_elementList.end(); it != itEnd; ++it) { - ControlElement* element = *it; - if(element->GetID() > majorElementID) majorElementID = element->GetID(); - } - for(auto it = m_connectionList.begin(), itEnd = m_connectionList.end(); it != itEnd; ++it) { - ConnectionLine* line = *it; - if(line->GetID() > majorElementID) majorElementID = line->GetID(); - } - m_lastElementID = ++majorElementID; - + SetLastElementID(); Redraw(); event.Skip(); } @@ -860,3 +849,17 @@ void ControlEditor::ConsolidateTexts() m_firstDraw = false; } } + +void ControlEditor::SetLastElementID() +{ + int id = 0; + for(auto it = m_elementList.begin(), itEnd = m_elementList.end(); it != itEnd; ++it) { + int elementID = (*it)->GetID(); + if(id < elementID) id = elementID; + } + for(auto it = m_connectionList.begin(), itEnd = m_connectionList.end(); it != itEnd; ++it) { + int elementID = (*it)->GetID(); + if(id < elementID) id = elementID; + } + m_lastElementID = ++id; +} -- cgit