Commit 4c3098fb authored by Ralf Habacker's avatar Ralf Habacker

Fix crash caused by dangling pointers in UMLPackage::m_objects on document close.

(cherry picked from commit 01633284)
parent af8679be
......@@ -95,7 +95,7 @@ UMLObject* createNewUMLObject(UMLObject::ObjectType type, const QString &name,
uError() << name << ": parentPkg is NULL";
return NULL;
}
UMLObject *o = NULL;
QPointer<UMLObject> o = NULL;
switch (type) {
case UMLObject::ot_Actor:
o = new UMLActor(name, g_predefinedId);
......
......@@ -241,6 +241,8 @@ UMLObject * UMLPackage::findObject(const QString &name)
const bool caseSensitive = UMLApp::app()->activeLanguageIsCaseSensitive();
for (UMLObjectListIt oit(m_objects); oit.hasNext();) {
UMLObject *obj = oit.next();
if (!obj)
continue;
if (caseSensitive) {
if (obj->name() == name)
return obj;
......
......@@ -13,17 +13,19 @@
#define UMLOBJECTLIST_H
#include <QList>
#include <QPointer>
// forward declarations
class UMLObject;
typedef QListIterator<UMLObject*> UMLObjectListIt;
typedef QListIterator<QPointer<UMLObject>>
UMLObjectListIt;
/**
* This sub-class adds copyInto and clone to the QList<UMLObject*>
* base class.
*/
class UMLObjectList : public QList<UMLObject*>
class UMLObjectList : public QList<QPointer<UMLObject>>
{
public:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment