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 | |
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/ContentLine.cpp | 31 | ||||
-rw-r--r-- | kabc/vcard/VCardEntity.cpp | 3 | ||||
-rw-r--r-- | kabc/vcard/VCardv.cpp | 23 |
3 files changed, 51 insertions, 6 deletions
diff --git a/kabc/vcard/ContentLine.cpp b/kabc/vcard/ContentLine.cpp index 6fa1a8f..0fb5b5d 100644 --- a/kabc/vcard/ContentLine.cpp +++ b/kabc/vcard/ContentLine.cpp @@ -47,71 +47,96 @@ #include <VCardNValue.h> #include <VCardURIValue.h> #include <VCardSoundValue.h> #include <VCardClassValue.h> #include <VCardFloatValue.h> #include <VCardOrgValue.h> #include <VCardTelValue.h> #include <VCardTextListValue.h> #include <VCardUTCValue.h> #include <VCardGeoValue.h> #include <VCardRToken.h> #include <VCardContentLine.h> #include <VCardEntity.h> #include <VCardEnum.h> #include <VCardDefines.h> using namespace VCARD; ContentLine::ContentLine() : Entity(), value_(0) { + paramList_.setAutoDelete( TRUE ); } ContentLine::ContentLine(const ContentLine & x) : Entity(x), group_ (x.group_), name_ (x.name_), - paramList_(x.paramList_), - value_(x.value_->clone()) +/*US paramList_(x.paramList_),*/ + value_(x.value_->clone()), + paramType_(x.paramType_), + valueType_(x.valueType_), + entityType_(x.entityType_) { + paramList_.setAutoDelete( TRUE ); + + + ParamListIterator it(x.paramList_); + for (; it.current(); ++it) + { + Param *p = new Param; + p->setName( it.current()->name() ); + p->setValue( it.current()->value() ); + paramList_.append(p); + } + } ContentLine::ContentLine(const QCString & s) : Entity(s), value_(0) { + paramList_.setAutoDelete( TRUE ); } ContentLine & ContentLine::operator = (ContentLine & x) { if (*this == x) return *this; - paramList_ = x.paramList(); + ParamListIterator it(x.paramList_); + for (; it.current(); ++it) + { + Param *p = new Param; + p->setName( it.current()->name() ); + p->setValue( it.current()->value() ); + paramList_.append(p); + } + value_ = x.value_->clone(); Entity::operator = (x); return *this; } ContentLine & ContentLine::operator = (const QCString & s) { Entity::operator = (s); delete value_; value_ = 0; return *this; } bool ContentLine::operator == (ContentLine & x) { x.parse(); QPtrListIterator<Param> it(x.paramList()); if (!paramList_.find(it.current())) return false; 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 @@ -10,58 +10,61 @@ 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, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #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 & VCardEntity::operator = (const QCString & s) { Entity::operator = (s); return *this; } bool VCardEntity::operator == (VCardEntity & x) { x.parse(); return false; } diff --git a/kabc/vcard/VCardv.cpp b/kabc/vcard/VCardv.cpp index 8d271f4..3f0a5e5 100644 --- a/kabc/vcard/VCardv.cpp +++ b/kabc/vcard/VCardv.cpp @@ -15,69 +15,86 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include <qcstring.h> #include <qstrlist.h> #include <VCardEntity.h> #include <VCardVCard.h> #include <VCardContentLine.h> #include <VCardRToken.h> #include <VCardDefines.h> using namespace VCARD; VCard::VCard() : Entity() { + contentLineList_.setAutoDelete( TRUE ); } VCard::VCard(const VCard & x) : Entity(x), - group_(x.group_), - contentLineList_(x.contentLineList_) + group_(x.group_) { + contentLineList_.setAutoDelete( TRUE ); + //US + qDebug("VCard::VCard"); + + QPtrListIterator<ContentLine> it(x.contentLineList_); + for (; it.current(); ++it) { + ContentLine * c = new ContentLine(*it.current()); + contentLineList_.append(c); + } + } VCard::VCard(const QCString & s) : Entity(s) { + contentLineList_.setAutoDelete( TRUE ); } VCard & VCard::operator = (VCard & x) { + //US + qDebug("VCard::operator ="); if (*this == x) return *this; group_ = x.group(); - contentLineList_ = x.contentLineList_; + QPtrListIterator<ContentLine> it(x.contentLineList_); + for (; it.current(); ++it) { + ContentLine * c = new ContentLine(*it.current()); + contentLineList_.append(c); + } Entity::operator = (x); return *this; } VCard & VCard::operator = (const QCString & s) { Entity::operator = (s); return *this; } bool VCard::operator == (VCard & x) { x.parse(); return false; } VCard::~VCard() { } void |