author | ulf69 <ulf69> | 2004-08-19 23:29:05 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-08-19 23:29:05 (UTC) |
commit | d81fbb0a720ba6eb0fbfa1d1eb0748877237a27e (patch) (side-by-side diff) | |
tree | 9b723a5c4f7da306036495e35d1863fbee646984 /kabc/vcard/VCardEntity.cpp | |
parent | d9b7a7296b031b3cf3e510a163367b9c4ab42d7a (diff) | |
download | kdepimpi-d81fbb0a720ba6eb0fbfa1d1eb0748877237a27e.zip kdepimpi-d81fbb0a720ba6eb0fbfa1d1eb0748877237a27e.tar.gz kdepimpi-d81fbb0a720ba6eb0fbfa1d1eb0748877237a27e.tar.bz2 |
bugfix: memoryleak in vCards during loading of addressbooks
-rw-r--r-- | kabc/vcard/VCardEntity.cpp | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/kabc/vcard/VCardEntity.cpp b/kabc/vcard/VCardEntity.cpp index 0c21e2f..0cd2086 100644 --- a/kabc/vcard/VCardEntity.cpp +++ b/kabc/vcard/VCardEntity.cpp @@ -1,17 +1,17 @@ /* libvcard - vCard parsing library for vCard version 3.0 Copyright (C) 1998 Rik Hemsley rik@kde.org - + Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, @@ -22,34 +22,37 @@ */ #include <qregexp.h> #include <VCardDefines.h> #include <VCardVCardEntity.h> using namespace VCARD; VCardEntity::VCardEntity() : Entity() { + cardList_.setAutoDelete( TRUE ); } VCardEntity::VCardEntity(const VCardEntity & x) : Entity(x) { + cardList_.setAutoDelete( TRUE ); } VCardEntity::VCardEntity(const QCString & s) : Entity(s) { + cardList_.setAutoDelete( TRUE ); } VCardEntity & VCardEntity::operator = (VCardEntity & x) { if (*this == x) return *this; Entity::operator = (x); return *this; } VCardEntity & @@ -66,48 +69,48 @@ VCardEntity::operator == (VCardEntity & x) return false; } VCardEntity::~VCardEntity() { } void VCardEntity::_parse() { vDebug("parse"); QCString s(strRep_); - + int i = s.find(QRegExp("BEGIN:VCARD", false)); - + while (i != -1) { - + i = s.find(QRegExp("BEGIN:VCARD", false), 11); - + QCString cardStr(s.left(i)); - + VCard * v = new VCard(cardStr); - + cardList_.append(v); - + v->parse(); - + s.remove(0, i); } } void VCardEntity::_assemble() { VCardListIterator it(cardList_); - + for (; it.current(); ++it) strRep_ += it.current()->asString() + "\r\n"; // One CRLF for luck. } VCardList & VCardEntity::cardList() { parse(); return cardList_; } void |