diff --git a/src/keys/CompositeKey.cpp b/src/keys/CompositeKey.cpp index fc72dd6a..094e669a 100644 --- a/src/keys/CompositeKey.cpp +++ b/src/keys/CompositeKey.cpp @@ -36,6 +36,12 @@ CompositeKey::~CompositeKey() qDeleteAll(m_keys); } +void CompositeKey::clear() +{ + qDeleteAll(m_keys); + m_keys.clear(); +} + CompositeKey* CompositeKey::clone() const { return new CompositeKey(*this); diff --git a/src/keys/CompositeKey.h b/src/keys/CompositeKey.h index 017ffbfd..d17e76fb 100644 --- a/src/keys/CompositeKey.h +++ b/src/keys/CompositeKey.h @@ -28,6 +28,7 @@ public: CompositeKey(); CompositeKey(const CompositeKey& key); ~CompositeKey(); + void clear(); CompositeKey* clone() const; CompositeKey& operator=(const CompositeKey& key); diff --git a/tests/TestKeys.cpp b/tests/TestKeys.cpp index 6fd9967d..116de363 100644 --- a/tests/TestKeys.cpp +++ b/tests/TestKeys.cpp @@ -56,6 +56,17 @@ void TestKeys::testComposite() QVERIFY(compositeKey2->transform(QByteArray(32, '\0'), 1).size() == 32); delete compositeKey2; + + CompositeKey* compositeKey3 = new CompositeKey(); + CompositeKey* compositeKey4 = new CompositeKey(); + + compositeKey3->addKey(PasswordKey("test")); + compositeKey3->clear(); + + QCOMPARE(compositeKey3->rawKey(), compositeKey4->rawKey()); + + delete compositeKey3; + delete compositeKey4; } void TestKeys::testFileKey()