Skip to content

Commit e55597e

Browse files
kaichiemergify[bot]
authored andcommitted
fix crash (#1587)
(cherry picked from commit 9fc8054)
1 parent d824b02 commit e55597e

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
@@ -103,7 +103,7 @@ void PropertyTreeWidget::setModel(PropertyTreeModel * model)
103103
if (model_) {
104104
connect(
105105
model_, SIGNAL(propertyHiddenChanged(const Property*)),
106-
this, SLOT(propertyHiddenChanged(const Property*)), Qt::QueuedConnection);
106+
this, SLOT(propertyHiddenChanged(const Property*)), Qt::DirectConnection);
107107
connect(
108108
model_, SIGNAL(expand(const QModelIndex&)),
109109
this, SLOT(expand(const QModelIndex&)));
@@ -119,12 +119,14 @@ void PropertyTreeWidget::setModel(PropertyTreeModel * model)
119119
void PropertyTreeWidget::propertyHiddenChanged(const Property * property)
120120
{
121121
if (model_) {
122-
const auto & parent_index = model_->parentIndex(property);
123-
if (parent_index.isValid()) {
124-
setRowHidden(property->rowNumberInParent(), parent_index, property->getHidden());
125-
} else {
126-
printf("Trying to hide property '%s' that is not part of the model.\n",
127-
qPrintable(property->getName()));
122+
if (property->parent() != nullptr) {
123+
const auto & parent_index = model_->parentIndex(property);
124+
if (parent_index.isValid()) {
125+
setRowHidden(property->rowNumberInParent(), parent_index, property->getHidden());
126+
} else {
127+
printf("Trying to hide property '%s' that is not part of the model.\n",
128+
qPrintable(property->getName()));
129+
}
128130
}
129131
}
130132
}

0 commit comments

Comments
 (0)