Explorar el Código

Avoid modifying Object::m_children while iterating it.

Andreas Kling hace 6 años
padre
commit
aee66e0119
Se han modificado 1 ficheros con 2 adiciones y 2 borrados
  1. 2 2
      Widgets/Object.cpp

+ 2 - 2
Widgets/Object.cpp

@@ -13,9 +13,9 @@ Object::~Object()
 {
 {
     if (m_parent)
     if (m_parent)
         m_parent->removeChild(*this);
         m_parent->removeChild(*this);
-    for (auto* child : m_children) {
+    auto childrenToDelete = std::move(m_children);
+    for (auto* child : childrenToDelete)
         delete child;
         delete child;
-    }
 }
 }
 
 
 void Object::event(Event& event)
 void Object::event(Event& event)