1.修复CAttributeVector添加子项时类子项被另一个CAttributeVector释放造成内存失效闪退问题;
| | |
| | | m_attributes.clear(); |
| | | } |
| | | |
| | | void CAttributeVector::addAttribute(CAttribute* pAttribute, BOOL bReplace/* = FALSE*/) |
| | | BOOL CAttributeVector::addAttribute(CAttribute* pAttribute, BOOL bReplace/* = FALSE*/) |
| | | { |
| | | if (!pAttribute) { |
| | | return; |
| | | return FALSE; |
| | | } |
| | | |
| | | const std::string& name = pAttribute->getName(); |
| | | if (name.empty()) { |
| | | return; |
| | | return FALSE; |
| | | } |
| | | |
| | | if (bReplace) { |
| | |
| | | } |
| | | |
| | | m_attributes.push_back(pAttribute); |
| | | return TRUE; |
| | | } |
| | | |
| | | void CAttributeVector::addAttributeVector(CAttributeVector& av) |
| | |
| | | ASSERT(index < m_attributes.size()); |
| | | return m_attributes[index]; |
| | | } |
| | | |
| | | std::vector<CAttribute*>& CAttributeVector::getAttributes() |
| | | { |
| | | return m_attributes; |
| | | } |
| | | } |
| | |
| | | virtual ~CAttributeVector(); |
| | | |
| | | public: |
| | | void addAttribute(CAttribute* pAttribute, BOOL bReplace = FALSE); |
| | | BOOL addAttribute(CAttribute* pAttribute, BOOL bReplace = FALSE); |
| | | void addAttributeVector(CAttributeVector& av); |
| | | void clear(); |
| | | void sortWithWeight(); |
| | | unsigned int size(); |
| | | bool empty(); |
| | | CAttribute* getAttribute(unsigned int index); |
| | | std::vector<CAttribute*>& getAttributes(); |
| | | |
| | | private: |
| | | std::vector<CAttribute*> m_attributes; |
| | |
| | | pStep->setName(pszName[m_nIndex]); |
| | | pStep->setWriteSignalDev(0x128 + m_nIndex); |
| | | pStep->setDataDev(dev[m_nIndex]); |
| | | if (addStep(STEP_ID_PROT1_TYPE_AUTO_CHANGE_REPLY + m_nIndex, pStep) != 0) { |
| | | if (addStep(STEP_ID_PROT1_CASSETTE_TYPE_CHANGE_REPLY + m_nIndex, pStep) != 0) { |
| | | delete pStep; |
| | | } |
| | | } |
| | |
| | | void CStep::addAttributeVector(CAttributeVector& attributeVector) |
| | | { |
| | | // 添加attribute时,要前删除存在的同名的attribute |
| | | unsigned int size = attributeVector.size(); |
| | | for (unsigned int i = 0; i < size; i++) { |
| | | m_attributeVector.addAttribute(attributeVector.getAttribute(i), TRUE); |
| | | std::vector<CAttribute*>& srcs = attributeVector.getAttributes(); |
| | | auto it = srcs.begin(); |
| | | while (it != srcs.end()) { |
| | | BOOL bAdd = m_attributeVector.addAttribute((*it), TRUE); |
| | | if (bAdd) { |
| | | it = srcs.erase(it); |
| | | } |
| | | else { |
| | | ++it; |
| | | } |
| | | } |
| | | } |
| | | |