summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/uml/duse-mt/src/app/example3.xmi4
-rw-r--r--scripts/templates/common.tmpl1
-rw-r--r--scripts/templates/qclass.cpp8
-rw-r--r--scripts/templates/qclass.h3
-rw-r--r--src/modeling/qmodelingelement.cpp5
-rw-r--r--src/modeling/qmodelingelement.h9
-rw-r--r--tests/auto/auto.pro7
-rw-r--r--tests/auto/qtumlguardedcollection/qtumlguardedcollection.pro7
-rw-r--r--tests/auto/qtumlguardedcollection/tst_qtumlguardedcollection.cpp73
-rw-r--r--tests/auto/qtumlprovidedrequiredinterfaces/test.xmi4
-rw-r--r--tests/auto/qtumlprovidedrequiredinterfaces/tst_qtumlprovidedrequiredinterfaces.cpp2
11 files changed, 107 insertions, 16 deletions
diff --git a/examples/uml/duse-mt/src/app/example3.xmi b/examples/uml/duse-mt/src/app/example3.xmi
index 901e7345..caa8a58a 100644
--- a/examples/uml/duse-mt/src/app/example3.xmi
+++ b/examples/uml/duse-mt/src/app/example3.xmi
@@ -17,24 +17,20 @@
<clientDependency href="_g59JXE_rEeOrf6v5LQGc0Q"/>
<interfaceRealization xmi:type="uml:InterfaceRealization" xmi:id="_g59JXE_rEeOrf6v5LQGc0Q" name="MaxClientsControl-IMaxClientsControl-Realization" contract="_g59JWU_rEeOrf6v5LQGc0Q">
<supplier href="_g59JWU_rEeOrf6v5LQGc0Q"/>
- <client href="_g59JW0_rEeOrf6v5LQGc0Q"/>
</interfaceRealization>
</packagedElement>
<packagedElement xmi:type="uml:Dependency" xmi:id="_g59JXU_rEeOrf6v5LQGc0Q" name="MaxClientsControl-IAvgResponseTimeMonitor-Dependency">
<supplier href="_g59JWk_rEeOrf6v5LQGc0Q"/>
- <client href="_g59JW0_rEeOrf6v5LQGc0Q"/>
</packagedElement>
<packagedElement xmi:type="uml:Class" xmi:id="_g59JW0_rEeOrf6v5LQGc0R" name="BaseClass">
<clientDependency href="_g59JXU_rEeOrf6v5LQGc0R"/>
<clientDependency href="_g59JXE_rEeOrf6v5LQGc0R"/>
<interfaceRealization xmi:type="uml:InterfaceRealization" xmi:id="_g59JXE_rEeOrf6v5LQGc0R" name="BaseClass-IBaseProvidedInterface-Realization" contract="_g59JWU_rEeOrf6v5LQGc0R">
<supplier href="_g59JWU_rEeOrf6v5LQGc0R"/>
- <client href="_g59JW0_rEeOrf6v5LQGc0R"/>
</interfaceRealization>
</packagedElement>
<packagedElement xmi:type="uml:Dependency" xmi:id="_g59JXU_rEeOrf6v5LQGc0R" name="BaseClass-IBaseRequiredInterface-Dependency">
<supplier href="_g59JWk_rEeOrf6v5LQGc0R"/>
- <client href="_g59JW0_rEeOrf6v5LQGc0R"/>
</packagedElement>
</uml:Model>
</xmi:XMI>
diff --git a/scripts/templates/common.tmpl b/scripts/templates/common.tmpl
index 1db78b48..82e8deb4 100644
--- a/scripts/templates/common.tmpl
+++ b/scripts/templates/common.tmpl
@@ -535,6 +535,7 @@ void Q${namespace}${originalClassName}Object::unset${qtAttribute.remove("^is").u
[%- SET attributeName = attribute.findvalue("@name") -%]
[%- SET qtAttribute = QT_ATTRIBUTE(attribute) -%]
[%- NEXT IF redefinedProperties.grep("^${className}-${qtAttribute}$").size > 0 -%]
+ [%- NEXT IF attribute.findvalue("@aggregation") != "composite" -%]
[%- IF qtType.match("QList|QSet") %]
foreach (${qtType.remove("QList<").remove("QSet<").remove(">").replace('\* ', '*')}element, ${PLURALFORM(qtAttribute, attribute)}())
[%- IF qtType.match('\*') %]
diff --git a/scripts/templates/qclass.cpp b/scripts/templates/qclass.cpp
index 5148170e..687d1805 100644
--- a/scripts/templates/qclass.cpp
+++ b/scripts/templates/qclass.cpp
@@ -139,6 +139,14 @@ Q${namespace}${className}::Q${namespace}${className}([%- IF class.findvalue("@is
[%- END %]
}
+/*!
+ Destroys the Q${namespace}${className}.
+ */
+Q${namespace}${className}::~Q${namespace}${className}()
+{
+ QUmlElement::deleteQModelingObject();
+}
+
[%- IF documentation != "" %]
/*!
Returns a deep-copied clone of the Q${namespace}${className}.
diff --git a/scripts/templates/qclass.h b/scripts/templates/qclass.h
index 4f08e497..72acc673 100644
--- a/scripts/templates/qclass.h
+++ b/scripts/templates/qclass.h
@@ -90,8 +90,9 @@ public QModelingElement
public:
[%- IF class.findvalue("@isAbstract") != "true" %]
explicit Q${namespace}${className}(bool createQModelingObject = true);
-
[%- END %]
+ virtual ~Q${namespace}${className}();
+
[% IF class.findvalue("@isAbstract") == "true" %]Q_DECL_HIDDEN [% END %]virtual QModelingElement *clone() const;
[% FOREACH attribute = class.findnodes("ownedAttribute") -%]
[%- IF loop.first %]
diff --git a/src/modeling/qmodelingelement.cpp b/src/modeling/qmodelingelement.cpp
index 31133a9a..369dc781 100644
--- a/src/modeling/qmodelingelement.cpp
+++ b/src/modeling/qmodelingelement.cpp
@@ -55,11 +55,6 @@ QT_BEGIN_NAMESPACE
*/
QModelingElement::~QModelingElement()
{
- if (!deletingFromQModelingObject) {
- if (_qModelingObject)
- _qModelingObject->setProperty("deletingFromModelingObject", true);
- delete _qModelingObject;
- }
}
/*!
diff --git a/src/modeling/qmodelingelement.h b/src/modeling/qmodelingelement.h
index 77bdc6ec..96e863c6 100644
--- a/src/modeling/qmodelingelement.h
+++ b/src/modeling/qmodelingelement.h
@@ -66,6 +66,15 @@ public:
protected:
QModelingElement();
QPointer<QModelingObject> _qModelingObject;
+
+ inline void deleteQModelingObject()
+ {
+ if (!deletingFromQModelingObject) {
+ if (_qModelingObject)
+ _qModelingObject->setProperty("deletingFromModelingObject", true);
+ delete _qModelingObject;
+ }
+ }
};
inline QModelingElement *qModelingElement(const QObject * const object)
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index d33bf4c7..4197a886 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -1,2 +1,7 @@
TEMPLATE=subdirs
-SUBDIRS = qtmofcontainment qtumlcontainment qtumlprovidedrequiredinterfaces qtumlconnectortypeandcomponentparts
+SUBDIRS = \
+ qtmofcontainment \
+ qtumlcontainment \
+ qtumlprovidedrequiredinterfaces \
+ qtumlconnectortypeandcomponentparts \
+ qtumlguardedcollection
diff --git a/tests/auto/qtumlguardedcollection/qtumlguardedcollection.pro b/tests/auto/qtumlguardedcollection/qtumlguardedcollection.pro
new file mode 100644
index 00000000..a5ddacc9
--- /dev/null
+++ b/tests/auto/qtumlguardedcollection/qtumlguardedcollection.pro
@@ -0,0 +1,7 @@
+CONFIG += testcase
+TARGET = tst_qtumlguardedcollection
+
+QT = modeling uml testlib
+
+SOURCES += \
+ tst_qtumlguardedcollection.cpp \
diff --git a/tests/auto/qtumlguardedcollection/tst_qtumlguardedcollection.cpp b/tests/auto/qtumlguardedcollection/tst_qtumlguardedcollection.cpp
new file mode 100644
index 00000000..4fcee5a8
--- /dev/null
+++ b/tests/auto/qtumlguardedcollection/tst_qtumlguardedcollection.cpp
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Sandro S. Andrade <sandroandrade@kde.org>
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtUml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QtTest/QtTest>
+
+#include <QtUml/QUmlComment>
+
+class TestQtUmlGuardedCollection : public QObject
+{
+ Q_OBJECT
+
+private Q_SLOTS:
+ void qtumlguardedcollection();
+};
+
+void TestQtUmlGuardedCollection::qtumlguardedcollection()
+{
+ QUmlComment *c1 = new QUmlComment;
+ c1->asQModelingObject()->setObjectName("c1");
+ QUmlComment *c2 = new QUmlComment;
+ c2->asQModelingObject()->setObjectName("c2");
+
+ c1->addOwnedComment(c2);
+
+ QCOMPARE(c1->ownedComments().size(), 1);
+
+ delete c2;
+
+ QCOMPARE(c1->ownedComments().size(), 0);
+
+ delete c1;
+}
+
+QTEST_MAIN(TestQtUmlGuardedCollection)
+#include "tst_qtumlguardedcollection.moc"
+
diff --git a/tests/auto/qtumlprovidedrequiredinterfaces/test.xmi b/tests/auto/qtumlprovidedrequiredinterfaces/test.xmi
index 901e7345..caa8a58a 100644
--- a/tests/auto/qtumlprovidedrequiredinterfaces/test.xmi
+++ b/tests/auto/qtumlprovidedrequiredinterfaces/test.xmi
@@ -17,24 +17,20 @@
<clientDependency href="_g59JXE_rEeOrf6v5LQGc0Q"/>
<interfaceRealization xmi:type="uml:InterfaceRealization" xmi:id="_g59JXE_rEeOrf6v5LQGc0Q" name="MaxClientsControl-IMaxClientsControl-Realization" contract="_g59JWU_rEeOrf6v5LQGc0Q">
<supplier href="_g59JWU_rEeOrf6v5LQGc0Q"/>
- <client href="_g59JW0_rEeOrf6v5LQGc0Q"/>
</interfaceRealization>
</packagedElement>
<packagedElement xmi:type="uml:Dependency" xmi:id="_g59JXU_rEeOrf6v5LQGc0Q" name="MaxClientsControl-IAvgResponseTimeMonitor-Dependency">
<supplier href="_g59JWk_rEeOrf6v5LQGc0Q"/>
- <client href="_g59JW0_rEeOrf6v5LQGc0Q"/>
</packagedElement>
<packagedElement xmi:type="uml:Class" xmi:id="_g59JW0_rEeOrf6v5LQGc0R" name="BaseClass">
<clientDependency href="_g59JXU_rEeOrf6v5LQGc0R"/>
<clientDependency href="_g59JXE_rEeOrf6v5LQGc0R"/>
<interfaceRealization xmi:type="uml:InterfaceRealization" xmi:id="_g59JXE_rEeOrf6v5LQGc0R" name="BaseClass-IBaseProvidedInterface-Realization" contract="_g59JWU_rEeOrf6v5LQGc0R">
<supplier href="_g59JWU_rEeOrf6v5LQGc0R"/>
- <client href="_g59JW0_rEeOrf6v5LQGc0R"/>
</interfaceRealization>
</packagedElement>
<packagedElement xmi:type="uml:Dependency" xmi:id="_g59JXU_rEeOrf6v5LQGc0R" name="BaseClass-IBaseRequiredInterface-Dependency">
<supplier href="_g59JWk_rEeOrf6v5LQGc0R"/>
- <client href="_g59JW0_rEeOrf6v5LQGc0R"/>
</packagedElement>
</uml:Model>
</xmi:XMI>
diff --git a/tests/auto/qtumlprovidedrequiredinterfaces/tst_qtumlprovidedrequiredinterfaces.cpp b/tests/auto/qtumlprovidedrequiredinterfaces/tst_qtumlprovidedrequiredinterfaces.cpp
index a5ba7c9f..115a5ff8 100644
--- a/tests/auto/qtumlprovidedrequiredinterfaces/tst_qtumlprovidedrequiredinterfaces.cpp
+++ b/tests/auto/qtumlprovidedrequiredinterfaces/tst_qtumlprovidedrequiredinterfaces.cpp
@@ -84,7 +84,7 @@ void TestQtUmlProvidedRequiredInterfaces::qtumlprovidedrequiredinterfaces()
QCOMPARE(port3->required().contains(qmodelingelementproperty_cast<QUmlInterface *>(rootElements.first()->asQModelingObject()->findChild<QObject *>("IAvgResponseTimeMonitor"))), true);
QCOMPARE(port3->required().contains(qmodelingelementproperty_cast<QUmlInterface *>(rootElements.first()->asQModelingObject()->findChild<QObject *>("IBaseRequiredInterface"))), true);
-// qDeleteAll(rootElements);
+ qDeleteAll(rootElements);
}
QTEST_MAIN(TestQtUmlProvidedRequiredInterfaces)