summaryrefslogtreecommitdiffabout
path: root/kabc
authorulf69 <ulf69>2004-08-19 23:29:05 (UTC)
committer ulf69 <ulf69>2004-08-19 23:29:05 (UTC)
commitd81fbb0a720ba6eb0fbfa1d1eb0748877237a27e (patch) (side-by-side diff)
tree9b723a5c4f7da306036495e35d1863fbee646984 /kabc
parentd9b7a7296b031b3cf3e510a163367b9c4ab42d7a (diff)
downloadkdepimpi-d81fbb0a720ba6eb0fbfa1d1eb0748877237a27e.zip
kdepimpi-d81fbb0a720ba6eb0fbfa1d1eb0748877237a27e.tar.gz
kdepimpi-d81fbb0a720ba6eb0fbfa1d1eb0748877237a27e.tar.bz2
bugfix: memoryleak in vCards during loading of addressbooks
Diffstat (limited to 'kabc') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/vcard/ContentLine.cpp103
-rw-r--r--kabc/vcard/VCardEntity.cpp23
-rw-r--r--kabc/vcard/VCardv.cpp23
3 files changed, 97 insertions, 52 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
@@ -4,3 +4,3 @@
Copyright (C) 1999 Rik Hemsley rik@kde.org
-
+
Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -70,2 +70,3 @@ ContentLine::ContentLine()
{
+ paramList_.setAutoDelete( TRUE );
}
@@ -76,5 +77,20 @@ ContentLine::ContentLine(const ContentLine & x)
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);
+ }
+
}
@@ -85,2 +101,3 @@ ContentLine::ContentLine(const QCString & s)
{
+ paramList_.setAutoDelete( TRUE );
}
@@ -91,4 +108,12 @@ 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();
@@ -112,5 +137,5 @@ ContentLine::operator == (ContentLine & x)
x.parse();
-
+
QPtrListIterator<Param> it(x.paramList());
-
+
if (!paramList_.find(it.current()))
@@ -131,8 +156,8 @@ ContentLine::_parse()
vDebug("parse");
-
+
// Unqote newlines
strRep_ = strRep_.replace( QRegExp( "\\\\n" ), "\n" );
-
+
int split = strRep_.find(':');
-
+
if (split == -1) { // invalid content line
@@ -141,8 +166,8 @@ ContentLine::_parse()
}
-
+
QCString firstPart(strRep_.left(split));
QCString valuePart(strRep_.mid(split + 1));
-
+
split = firstPart.find('.');
-
+
if (split != -1) {
@@ -151,3 +176,3 @@ ContentLine::_parse()
}
-
+
vDebug("Group == " + group_);
@@ -155,9 +180,9 @@ ContentLine::_parse()
vDebug("valuePart == " + valuePart);
-
+
// Now we have the group, the name and param list together and the value.
-
+
QStrList l;
-
+
RTokenise(firstPart, ";", l);
-
+
if (l.count() == 0) {// invalid - no name !
@@ -166,3 +191,3 @@ ContentLine::_parse()
}
-
+
name_ = l.at(0);
@@ -172,8 +197,8 @@ ContentLine::_parse()
l.remove(0u);
-
+
entityType_ = EntityNameToEntityType(name_);
paramType_ = EntityTypeToParamType(entityType_);
-
+
unsigned int i = 0;
-
+
// For each parameter, create a new parameter of the correct type.
@@ -181,3 +206,3 @@ ContentLine::_parse()
QStrListIterator it(l);
-
+
for (; it.current(); ++it, i++) {
@@ -191,13 +216,13 @@ ContentLine::_parse()
}
-
+
QCString paraName = str.left(split);
QCString paraValue = str.mid(split + 1);
-
+
QStrList paraValues;
RTokenise(paraValue, ",", paraValues);
-
+
QStrListIterator it2( paraValues );
-
- for(; it2.current(); ++it2) {
-
+
+ for(; it2.current(); ++it2) {
+
Param *p = new Param;
@@ -205,3 +230,3 @@ ContentLine::_parse()
p->setValue( *it2 );
-
+
paramList_.append(p);
@@ -213,7 +238,7 @@ ContentLine::_parse()
valueType_ = EntityTypeToValueType(entityType_);
-
+
// kdDebug(5710) << "valueType: " << valueType_ << endl;
-
+
switch (valueType_) {
-
+
case ValueSound: value_ = new SoundValue; break;
@@ -237,3 +262,3 @@ ContentLine::_parse()
}
-
+
*value_ = valuePart;
@@ -248,6 +273,6 @@ ContentLine::_assemble()
QCString line;
-
+
if (!group_.isEmpty())
line += group_ + '.';
-
+
line += name_;
@@ -256,6 +281,6 @@ ContentLine::_assemble()
ParamListIterator it(paramList_);
-
+
for (; it.current(); ++it)
line += ";" + it.current()->asString();
-
+
vDebug("Adding value");
@@ -268,3 +293,3 @@ ContentLine::_assemble()
line = line.replace( QRegExp( "\n" ), "\\n" );
-
+
// Fold lines longer than 72 chars
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
@@ -4,3 +4,3 @@
Copyright (C) 1998 Rik Hemsley rik@kde.org
-
+
Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -33,2 +33,3 @@ VCardEntity::VCardEntity()
{
+ cardList_.setAutoDelete( TRUE );
}
@@ -38,2 +39,3 @@ VCardEntity::VCardEntity(const VCardEntity & x)
{
+ cardList_.setAutoDelete( TRUE );
}
@@ -43,2 +45,3 @@ VCardEntity::VCardEntity(const QCString & s)
{
+ cardList_.setAutoDelete( TRUE );
}
@@ -77,17 +80,17 @@ VCardEntity::_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);
@@ -100,3 +103,3 @@ VCardEntity::_assemble()
VCardListIterator it(cardList_);
-
+
for (; it.current(); ++it)
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
@@ -38,2 +38,3 @@ VCard::VCard()
{
+ contentLineList_.setAutoDelete( TRUE );
}
@@ -42,5 +43,14 @@ 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);
+ }
+
}
@@ -50,2 +60,3 @@ VCard::VCard(const QCString & s)
{
+ contentLineList_.setAutoDelete( TRUE );
}
@@ -55,2 +66,4 @@ VCard::operator = (VCard & x)
{
+ //US
+ qDebug("VCard::operator =");
if (*this == x) return *this;
@@ -58,3 +71,7 @@ VCard::operator = (VCard & x)
group_ = x.group();
- contentLineList_ = x.contentLineList_;
+ QPtrListIterator<ContentLine> it(x.contentLineList_);
+ for (; it.current(); ++it) {
+ ContentLine * c = new ContentLine(*it.current());
+ contentLineList_.append(c);
+ }