author | ulf69 <ulf69> | 2004-08-19 23:29:05 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-08-19 23:29:05 (UTC) |
commit | d81fbb0a720ba6eb0fbfa1d1eb0748877237a27e (patch) (unidiff) | |
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,11 +1,11 @@ | |||
1 | /* | 1 | /* |
2 | libvcard - vCard parsing library for vCard version 3.0 | 2 | libvcard - vCard parsing library for vCard version 3.0 |
3 | 3 | ||
4 | Copyright (C) 1998 Rik Hemsley rik@kde.org | 4 | Copyright (C) 1998 Rik Hemsley rik@kde.org |
5 | 5 | ||
6 | Permission is hereby granted, free of charge, to any person obtaining a copy | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy |
7 | of this software and associated documentation files (the "Software"), to | 7 | of this software and associated documentation files (the "Software"), to |
8 | deal in the Software without restriction, including without limitation the | 8 | deal in the Software without restriction, including without limitation the |
9 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or | 9 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
10 | sell copies of the Software, and to permit persons to whom the Software is | 10 | sell copies of the Software, and to permit persons to whom the Software is |
11 | furnished to do so, subject to the following conditions: | 11 | furnished to do so, subject to the following conditions: |
@@ -28,22 +28,25 @@ | |||
28 | 28 | ||
29 | using namespace VCARD; | 29 | using namespace VCARD; |
30 | 30 | ||
31 | VCardEntity::VCardEntity() | 31 | VCardEntity::VCardEntity() |
32 | :Entity() | 32 | :Entity() |
33 | { | 33 | { |
34 | cardList_.setAutoDelete( TRUE ); | ||
34 | } | 35 | } |
35 | 36 | ||
36 | VCardEntity::VCardEntity(const VCardEntity & x) | 37 | VCardEntity::VCardEntity(const VCardEntity & x) |
37 | :Entity(x) | 38 | :Entity(x) |
38 | { | 39 | { |
40 | cardList_.setAutoDelete( TRUE ); | ||
39 | } | 41 | } |
40 | 42 | ||
41 | VCardEntity::VCardEntity(const QCString & s) | 43 | VCardEntity::VCardEntity(const QCString & s) |
42 | :Entity(s) | 44 | :Entity(s) |
43 | { | 45 | { |
46 | cardList_.setAutoDelete( TRUE ); | ||
44 | } | 47 | } |
45 | 48 | ||
46 | VCardEntity & | 49 | VCardEntity & |
47 | VCardEntity::operator = (VCardEntity & x) | 50 | VCardEntity::operator = (VCardEntity & x) |
48 | { | 51 | { |
49 | if (*this == x) return *this; | 52 | if (*this == x) return *this; |
@@ -72,36 +75,36 @@ VCardEntity::~VCardEntity() | |||
72 | 75 | ||
73 | void | 76 | void |
74 | VCardEntity::_parse() | 77 | VCardEntity::_parse() |
75 | { | 78 | { |
76 | vDebug("parse"); | 79 | vDebug("parse"); |
77 | QCString s(strRep_); | 80 | QCString s(strRep_); |
78 | 81 | ||
79 | int i = s.find(QRegExp("BEGIN:VCARD", false)); | 82 | int i = s.find(QRegExp("BEGIN:VCARD", false)); |
80 | 83 | ||
81 | while (i != -1) { | 84 | while (i != -1) { |
82 | 85 | ||
83 | i = s.find(QRegExp("BEGIN:VCARD", false), 11); | 86 | i = s.find(QRegExp("BEGIN:VCARD", false), 11); |
84 | 87 | ||
85 | QCString cardStr(s.left(i)); | 88 | QCString cardStr(s.left(i)); |
86 | 89 | ||
87 | VCard * v = new VCard(cardStr); | 90 | VCard * v = new VCard(cardStr); |
88 | 91 | ||
89 | cardList_.append(v); | 92 | cardList_.append(v); |
90 | 93 | ||
91 | v->parse(); | 94 | v->parse(); |
92 | 95 | ||
93 | s.remove(0, i); | 96 | s.remove(0, i); |
94 | } | 97 | } |
95 | } | 98 | } |
96 | 99 | ||
97 | void | 100 | void |
98 | VCardEntity::_assemble() | 101 | VCardEntity::_assemble() |
99 | { | 102 | { |
100 | VCardListIterator it(cardList_); | 103 | VCardListIterator it(cardList_); |
101 | 104 | ||
102 | for (; it.current(); ++it) | 105 | for (; it.current(); ++it) |
103 | strRep_ += it.current()->asString() + "\r\n"; // One CRLF for luck. | 106 | strRep_ += it.current()->asString() + "\r\n"; // One CRLF for luck. |
104 | } | 107 | } |
105 | 108 | ||
106 | VCardList & | 109 | VCardList & |
107 | VCardEntity::cardList() | 110 | VCardEntity::cardList() |