Skip to content

Commit 9015e54

Browse files
fix crash (ros2#1587) (ros2#1589)
(cherry picked from commit 9fc8054) Co-authored-by: nelson <[email protected]>
1 parent 9dd78d5 commit 9015e54

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

rviz_common/src/rviz_common/properties/property_tree_widget.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ void PropertyTreeWidget::setModel(PropertyTreeModel * model)
101101
if (model_) {
102102
connect(
103103
model_, SIGNAL(propertyHiddenChanged(const Property*)),
104-
this, SLOT(propertyHiddenChanged(const Property*)), Qt::QueuedConnection);
104+
this, SLOT(propertyHiddenChanged(const Property*)), Qt::DirectConnection);
105105
connect(
106106
model_, SIGNAL(expand(const QModelIndex&)),
107107
this, SLOT(expand(const QModelIndex&)));
@@ -117,12 +117,14 @@ void PropertyTreeWidget::setModel(PropertyTreeModel * model)
117117
void PropertyTreeWidget::propertyHiddenChanged(const Property * property)
118118
{
119119
if (model_) {
120-
const auto & parent_index = model_->parentIndex(property);
121-
if (parent_index.isValid()) {
122-
setRowHidden(property->rowNumberInParent(), parent_index, property->getHidden());
123-
} else {
124-
printf("Trying to hide property '%s' that is not part of the model.\n",
125-
qPrintable(property->getName()));
120+
if (property->parent() != nullptr) {
121+
const auto & parent_index = model_->parentIndex(property);
122+
if (parent_index.isValid()) {
123+
setRowHidden(property->rowNumberInParent(), parent_index, property->getHidden());
124+
} else {
125+
printf("Trying to hide property '%s' that is not part of the model.\n",
126+
qPrintable(property->getName()));
127+
}
126128
}
127129
}
128130
}

0 commit comments

Comments
 (0)