summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Maudsley <richard.maudsley@isode.com>2014-04-09 07:53:12 (GMT)
committerSwift Review <review@swift.im>2014-04-22 21:12:21 (GMT)
commita7fb55381ab4a5c470bf891b31ac6e201611a2c1 (patch)
tree475b3b7fc0142946863580506b00aa250ef8ca14 /Swift/QtUI/UserSearch/ContactListDelegate.cpp
parent4444aeb255f8d1712b794c31166f362bb3ec335a (diff)
downloadswift-a7fb55381ab4a5c470bf891b31ac6e201611a2c1.zip
swift-a7fb55381ab4a5c470bf891b31ac6e201611a2c1.tar.bz2
Fix crash in QtUserSearchWindow.
Avoid storing pointers to items in vectors. Using shared_ptr for Contact items. Change-Id: I3baa05fc058011b2beca14dc620ab794988a2b37
Diffstat (limited to 'Swift/QtUI/UserSearch/ContactListDelegate.cpp')
-rw-r--r--Swift/QtUI/UserSearch/ContactListDelegate.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/Swift/QtUI/UserSearch/ContactListDelegate.cpp b/Swift/QtUI/UserSearch/ContactListDelegate.cpp
index 29cab83..56c479b 100644
--- a/Swift/QtUI/UserSearch/ContactListDelegate.cpp
+++ b/Swift/QtUI/UserSearch/ContactListDelegate.cpp
@@ -4,6 +4,12 @@
* See Documentation/Licenses/BSD-simplified.txt for more information.
*/
+/*
+ * Copyright (c) 2014 Kevin Smith and Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
#include <Swift/QtUI/UserSearch/ContactListDelegate.h>
#include <Swift/QtUI/UserSearch/ContactListModel.h>
#include <Swift/Controllers/Contact.h>
@@ -21,7 +27,7 @@ void ContactListDelegate::paint(QPainter* painter, const QStyleOptionViewItem& o
if (!index.isValid()) {
return;
}
- const Contact* contact = static_cast<Contact*>(index.internalPointer());
+ const Contact::ref contact = static_cast<Contact*>(index.internalPointer())->shared_from_this();
QColor nameColor = index.data(Qt::TextColorRole).value<QColor>();
QString avatarPath = index.data(ContactListModel::AvatarRole).value<QString>();
QIcon presenceIcon =index.data(ChatListRecentItem::PresenceIconRole).isValid() && !index.data(ChatListRecentItem::PresenceIconRole).value<QIcon>().isNull()