Skip to content
Snippets Groups Projects
Commit b630c321 authored by Emmanuel Lepage Vallée's avatar Emmanuel Lepage Vallée Committed by Nicolas Jager
Browse files

Person : Fix a memory leak in toVCard()


Change-Id: I1afb94da51718177ab661f706c7364fa858a6fc7
Reviewed-by: default avatarNicolas Jäger <nicolas.jager@savoirfairelinux.com>
parent 0ae01498
No related branches found
No related tags found
No related merge requests found
...@@ -723,16 +723,16 @@ void Person::addCustomField(const QString& key, const QString& value) ...@@ -723,16 +723,16 @@ void Person::addCustomField(const QString& key, const QString& value)
const QByteArray Person::toVCard(QList<Account*> accounts) const const QByteArray Person::toVCard(QList<Account*> accounts) const
{ {
//serializing here //serializing here
VCardUtils* maker = new VCardUtils(); VCardUtils maker;
maker->startVCard("2.1"); maker.startVCard("2.1");
maker->addProperty(VCardUtils::Property::UID, uid()); maker.addProperty(VCardUtils::Property::UID, uid());
maker->addProperty(VCardUtils::Property::NAME, (secondName() maker.addProperty(VCardUtils::Property::NAME, (secondName()
+ VCardUtils::Delimiter::SEPARATOR_TOKEN + VCardUtils::Delimiter::SEPARATOR_TOKEN
+ firstName())); + firstName()));
maker->addProperty(VCardUtils::Property::FORMATTED_NAME, formattedName()); maker.addProperty(VCardUtils::Property::FORMATTED_NAME, formattedName());
maker->addProperty(VCardUtils::Property::ORGANIZATION, organization()); maker.addProperty(VCardUtils::Property::ORGANIZATION, organization());
maker->addEmail("PREF", preferredEmail()); maker.addEmail("PREF", preferredEmail());
foreach (ContactMethod* phone , phoneNumbers()) { foreach (ContactMethod* phone , phoneNumbers()) {
QString uri = phone->uri(); QString uri = phone->uri();
...@@ -740,23 +740,23 @@ const QByteArray Person::toVCard(QList<Account*> accounts) const ...@@ -740,23 +740,23 @@ const QByteArray Person::toVCard(QList<Account*> accounts) const
// can tell it is a RING number and not some other hash // can tell it is a RING number and not some other hash
if (phone->uri().protocolHint() == URI::ProtocolHint::RING) if (phone->uri().protocolHint() == URI::ProtocolHint::RING)
uri = phone->uri().full(); uri = phone->uri().full();
maker->addContactMethod(phone->category()->name(), uri); maker.addContactMethod(phone->category()->name(), uri);
} }
foreach (const Address& addr , d_ptr->m_lAddresses) { foreach (const Address& addr , d_ptr->m_lAddresses) {
maker->addAddress(addr); maker.addAddress(addr);
} }
foreach (const QString& key , d_ptr->m_lCustomAttributes.keys()) { foreach (const QString& key , d_ptr->m_lCustomAttributes.keys()) {
maker->addProperty(key, d_ptr->m_lCustomAttributes.value(key)); maker.addProperty(key, d_ptr->m_lCustomAttributes.value(key));
} }
foreach (Account* acc , accounts) { foreach (Account* acc , accounts) {
maker->addProperty(VCardUtils::Property::X_RINGACCOUNT, acc->id()); maker.addProperty(VCardUtils::Property::X_RINGACCOUNT, acc->id());
} }
maker->addPhoto(GlobalInstances::pixmapManipulator().toByteArray(photo())); maker.addPhoto(GlobalInstances::pixmapManipulator().toByteArray(photo()));
return maker->endVCard(); return maker.endVCard();
} }
void PersonPrivate::slotLastUsedTimeChanged(::time_t t) void PersonPrivate::slotLastUsedTimeChanged(::time_t t)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment