diff options
author | Kevin Smith <git@kismith.co.uk> | 2014-08-01 14:42:30 (GMT) |
---|---|---|
committer | Swift Review <review@swift.im> | 2014-08-10 10:58:32 (GMT) |
commit | 5e9e715e49a5ddb6ce9c76ec61e7ecfd6eacdb58 (patch) | |
tree | c51e752f938c7fc564fe3b84ce12bc374087e918 /Swift/QtUI | |
parent | cdc8e88963e2f12cf0a6398a4dd6bb787b456b46 (diff) | |
download | swift-contrib-5e9e715e49a5ddb6ce9c76ec61e7ecfd6eacdb58.zip swift-contrib-5e9e715e49a5ddb6ce9c76ec61e7ecfd6eacdb58.tar.bz2 |
Address memory leak
I'd rather do this with shared_ptr, as there's an ownership transfer. This just gets it into somewhere we'll remember it
Change-Id: I5f6872bce8070cbcce44de84eff5e9ed83f88fb9
Diffstat (limited to 'Swift/QtUI')
-rw-r--r-- | Swift/QtUI/ChatList/ChatListGroupItem.h | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/Swift/QtUI/ChatList/ChatListGroupItem.h b/Swift/QtUI/ChatList/ChatListGroupItem.h index 17defea..3bb4b8e 100644 --- a/Swift/QtUI/ChatList/ChatListGroupItem.h +++ b/Swift/QtUI/ChatList/ChatListGroupItem.h @@ -1,3 +1,3 @@ /* - * Copyright (c) 2010-2011 Kevin Smith + * Copyright (c) 2010-2014 Kevin Smith * Licensed under the GNU General Public License v3. @@ -10,2 +10,4 @@ +#include <Swiften/Base/foreach.h> + #include "Swift/QtUI/ChatList/ChatListItem.h" @@ -16,2 +18,3 @@ namespace Swift { ChatListGroupItem(const QString& name, ChatListGroupItem* parent, bool sorted = true) : ChatListItem(parent), name_(name), sorted_(sorted) {} + virtual ~ChatListGroupItem() {clear();} void addItem(ChatListItem* item) {items_.push_back(item); if (sorted_) {qStableSort(items_.begin(), items_.end(), pointerItemLessThan);}} @@ -22,3 +25,10 @@ namespace Swift { QVariant data(int role) const {return (role == Qt::DisplayRole) ? name_ : QVariant();} - void clear() {items_.clear();} + void clear() { + foreach (ChatListItem* item, items_) { + delete item; + } + items_.clear(); + } + + private: |