aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
Diffstat (limited to 'ui')
-rw-r--r--ui/qt/byte_view_tab.cpp7
-rw-r--r--ui/qt/byte_view_text.h1
2 files changed, 7 insertions, 1 deletions
diff --git a/ui/qt/byte_view_tab.cpp b/ui/qt/byte_view_tab.cpp
index c374db29bd..f57edf9611 100644
--- a/ui/qt/byte_view_tab.cpp
+++ b/ui/qt/byte_view_tab.cpp
@@ -38,8 +38,12 @@ ByteViewTab::ByteViewTab(QWidget *parent) :
}
void ByteViewTab::addTab(const char *name, tvbuff_t *tvb, proto_tree *tree, QTreeWidget *protoTree, packet_char_enc encoding) {
- ByteViewText *byte_view_text = new ByteViewText(this, tvb, tree, protoTree, encoding);
+ if (count() == 1) { // Remove empty placeholder.
+ ByteViewText *cur_text = qobject_cast<ByteViewText *>(currentWidget());
+ if (cur_text && cur_text->isEmpty()) delete currentWidget();
+ }
+ ByteViewText *byte_view_text = new ByteViewText(this, tvb, tree, protoTree, encoding);
byte_view_text->setAccessibleName(name);
byte_view_text->setMonospaceFont(mono_font_);
connect(this, SIGNAL(monospaceFontChanged(QFont)), byte_view_text, SLOT(setMonospaceFont(QFont)));
@@ -53,6 +57,7 @@ void ByteViewTab::clear()
while (currentWidget()) {
delete currentWidget();
}
+ addTab();
show();
}
diff --git a/ui/qt/byte_view_text.h b/ui/qt/byte_view_text.h
index 4ba8da99f1..805a0880e8 100644
--- a/ui/qt/byte_view_text.h
+++ b/ui/qt/byte_view_text.h
@@ -55,6 +55,7 @@ public:
void setProtocolHighlight(int start, int end);
void setFieldHighlight(int start, int end, guint32 mask = 0, int mask_le = 0);
void setFieldAppendixHighlight(int start, int end);
+ bool isEmpty() { return tvb_ == NULL || proto_tree_ == NULL; }
signals:
void byteFieldHovered(const QString &);