Qt: Avoid crash on ProtoTree item deselect

Handle the case of deselecting a ProtoTree item.


(cherry picked from commit a88d72dc8e)
This commit is contained in:
Stig Bjørlykke 2020-10-26 12:15:42 +00:00
parent 38207edc52
commit fe86435dd7
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;