From 299717879554ee2fc7d06fedded6207cfdcd1f22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stig=20Bj=C3=B8rlykke?= Date: Tue, 22 Dec 2015 14:51:08 +0100 Subject: [PATCH] Qt: Plug memory leak in ByteViewText. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Each time we create a ByteViewText, which is twice when a packet is selected, the menu items leaks. Ensure we clear the items when done. Change-Id: Idf0c7b82bf241120dd4c42ba85c56c0a2bf8db46 Reviewed-on: https://code.wireshark.org/review/12826 Petri-Dish: Stig Bjørlykke Tested-by: Petri Dish Buildbot Reviewed-by: Stig Bjørlykke --- ui/qt/byte_view_text.cpp | 5 +++++ ui/qt/byte_view_text.h | 2 ++ 2 files changed, 7 insertions(+) diff --git a/ui/qt/byte_view_text.cpp b/ui/qt/byte_view_text.cpp index 6355732940..8f05a3d087 100644 --- a/ui/qt/byte_view_text.cpp +++ b/ui/qt/byte_view_text.cpp @@ -86,6 +86,11 @@ ByteViewText::ByteViewText(QWidget *parent, tvbuff_t *tvb, proto_tree *tree, QTr setMouseTracking(true); } +ByteViewText::~ByteViewText() +{ + ctx_menu_.clear(); +} + void ByteViewText::setEncoding(packet_char_enc encoding) { encoding_ = encoding; diff --git a/ui/qt/byte_view_text.h b/ui/qt/byte_view_text.h index 89e3e6674d..c7958a58b5 100644 --- a/ui/qt/byte_view_text.h +++ b/ui/qt/byte_view_text.h @@ -43,6 +43,8 @@ class ByteViewText : public QAbstractScrollArea Q_OBJECT public: explicit ByteViewText(QWidget *parent = 0, tvbuff_t *tvb = NULL, proto_tree *tree = NULL, QTreeWidget *protoTree = NULL, packet_char_enc encoding = PACKET_CHAR_ENC_CHAR_ASCII); + ~ByteViewText(); + bool hasDataSource(const tvbuff_t *ds_tvb = NULL); void setEncoding(packet_char_enc encoding); void setFormat(bytes_view_type format);