diff --git a/src/chatlog/chatlog.cpp b/src/chatlog/chatlog.cpp index 979ba0c38..4d3698cac 100644 --- a/src/chatlog/chatlog.cpp +++ b/src/chatlog/chatlog.cpp @@ -99,6 +99,17 @@ ChatLog::ChatLog(QWidget* parent) connect(workerTimer, &QTimer::timeout, this, &ChatLog::onWorkerTimeout); } +ChatLog::~ChatLog() +{ + // Drop ownership of items of type ChatLineContentType + // as they are owned by ChatLine + for(QGraphicsItem* item : items()) + { + if(item->type() == ChatLineContent::ChatLineContentType) + scene->removeItem(item); + } +} + void ChatLog::clearSelection() { if(selectionMode == None) diff --git a/src/chatlog/chatlog.h b/src/chatlog/chatlog.h index ffc1bf876..0ab495e4d 100644 --- a/src/chatlog/chatlog.h +++ b/src/chatlog/chatlog.h @@ -36,6 +36,7 @@ class ChatLog : public QGraphicsView Q_OBJECT public: explicit ChatLog(QWidget* parent = 0); + virtual ~ChatLog(); void insertChatlineAtBottom(ChatLine::Ptr l); void insertChatlineOnTop(ChatLine::Ptr l);