summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRalf Habacker <ralf.habacker@freenet.de>2016-09-07 07:06:47 (GMT)
committerRalf Habacker <ralf.habacker@freenet.de>2016-09-07 07:06:47 (GMT)
commitd9b4afea8444320ca51f62dc5fa49d4ee2bfa8b3 (patch)
treead56eb82fa80ef3c96e12c699d73306b1e76d249
parent191e52ef5dc2e9a03b3a6c42a6566c4a82630d66 (diff)
Do not exclude parents of UMLClassifierListItem instances from copying and comparing.
After adding a related testcase it raises the issue that the parent of UMLClassifierListItem based objects are not been copied. Because we use the same parent store for all UMLObject based objects now it is possible to unify this behavior. CCBUG:368282
-rw-r--r--umbrello/umlmodel/umlobject.cpp6
-rw-r--r--unittests/TEST_umlobject.cpp10
2 files changed, 13 insertions, 3 deletions
diff --git a/umbrello/umlmodel/umlobject.cpp b/umbrello/umlmodel/umlobject.cpp
index 4858172..1cf0c1c 100644
--- a/umbrello/umlmodel/umlobject.cpp
+++ b/umbrello/umlmodel/umlobject.cpp
@@ -256,7 +256,7 @@ bool UMLObject::operator==(const UMLObject & rhs) const
// Packages create different namespaces, therefore they should be
// part of the equality test.
- if (umlPackage() != rhs.umlPackage())
+ if (umlParent() != rhs.umlParent())
return false;
// Making the type part of an object's identity has its problems:
@@ -310,7 +310,7 @@ void UMLObject::copyInto(UMLObject *lhs) const
lhs->m_bStatic = m_bStatic;
lhs->m_BaseType = m_BaseType;
lhs->m_visibility = m_visibility;
- lhs->setUMLPackage(umlPackage());
+ lhs->setUMLParent(umlParent());
// We don't want the same name existing twice.
lhs->m_name = Model_Utils::uniqObjectName(m_BaseType, umlPackage(), m_name);
@@ -319,7 +319,7 @@ void UMLObject::copyInto(UMLObject *lhs) const
lhs->m_nId = UniqueID::gen();
// Hope that the parent from QObject is okay.
- if (lhs->umlPackage() != umlPackage())
+ if (lhs->umlParent() != umlParent())
uDebug() << "copyInto has a wrong parent";
}
diff --git a/unittests/TEST_umlobject.cpp b/unittests/TEST_umlobject.cpp
index 6a4d70d..0401b26 100644
--- a/unittests/TEST_umlobject.cpp
+++ b/unittests/TEST_umlobject.cpp
@@ -21,7 +21,10 @@
#include "TEST_umlobject.h"
// app include
+#include "attribute.h"
+#include "classifier.h"
#include "folder.h"
+#include "operation.h"
#include "package.h"
#include "stereotype.h"
#include "uml.h"
@@ -44,6 +47,13 @@ void TEST_UMLObject::test_copyInto()
b.setUMLPackage(&parent);
b.copyInto(&a);
QCOMPARE(a, b);
+ UMLClassifier c("Test Classifier");
+ UMLOperation op(&c, "Test Parent");
+ UMLAttribute at(&op, "Attribute");
+ UMLAttribute at2(&op,"Attribute 2");
+ at2.copyInto(&at);
+ QCOMPARE(at, at2);
+ QCOMPARE(at2.umlParent(), at.umlParent());
}
void TEST_UMLObject::test_clone()