Qt: Plug memory leak in ByteViewText.

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 <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
This commit is contained in:
Stig Bjørlykke 2015-12-22 14:51:08 +01:00
parent 3bd69dac73
commit 2997178795
2 changed files with 7 additions and 0 deletions

View File

@ -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;

View File

@ -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);