Qt: Avoid crash on ProtoTree item deselect

Handle the case of deselecting a ProtoTree item.
This commit is contained in:
Stig Bjørlykke 2020-10-26 13:15:42 +01:00
parent cea3bdca9d
commit a88d72dc8e
1 changed files with 7 additions and 3 deletions

View File

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