aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorStig Bjørlykke <stig@bjorlykke.org>2020-10-26 13:15:42 +0100
committerStig Bjørlykke <stig@bjorlykke.org>2020-10-26 13:15:42 +0100
commita88d72dc8e91312a1fe95ef54d7a1dc0a1350a7d (patch)
treef11f6c21177e38c0810d5172e6209a5cd4b742c4 /ui
parentcea3bdca9daee1b208d12c016434b6e970204e01 (diff)
Qt: Avoid crash on ProtoTree item deselect
Handle the case of deselecting a ProtoTree item.
Diffstat (limited to 'ui')
-rw-r--r--ui/qt/proto_tree.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/ui/qt/proto_tree.cpp b/ui/qt/proto_tree.cpp
index e28f795fce..bcafb37fd4 100644
--- a/ui/qt/proto_tree.cpp
+++ b/ui/qt/proto_tree.cpp
@@ -587,8 +587,11 @@ void ProtoTree::collapseAll()
updateContentWidth();
}
-void ProtoTree::itemClicked(const QModelIndex &index) {
- if (index == selectionModel()->selectedIndexes().first()) {
+void ProtoTree::itemClicked(const QModelIndex &index)
+{
+ if (selectionModel()->selectedIndexes().isEmpty()) {
+ emit fieldSelected(0);
+ } else if (index == selectionModel()->selectedIndexes().first()) {
FieldInformation finfo(proto_tree_model_->protoNodeFromIndex(index).protoNode());
if (finfo.isValid()) {
@@ -597,7 +600,8 @@ void ProtoTree::itemClicked(const QModelIndex &index) {
}
}
-void ProtoTree::itemDoubleClicked(const QModelIndex &index) {
+void ProtoTree::itemDoubleClicked(const QModelIndex &index)
+{
FieldInformation finfo(proto_tree_model_->protoNodeFromIndex(index).protoNode());
if (!finfo.isValid()) return;