Skip to content

Commit 8432bf0

Browse files
mergify[bot]kaichieahcorde
authored
fix crash(segmentation fault) in propertyHiddenChanged (backport #1587) (#1590)
* fix crash (#1587) (cherry picked from commit 9fc8054) Signed-off-by: Alejandro Hernandez Cordero <[email protected]> Co-authored-by: nelson <[email protected]> Co-authored-by: Alejandro Hernandez Cordero <[email protected]>
1 parent 0b3aea1 commit 8432bf0

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

rviz_common/src/rviz_common/properties/property_tree_widget.cpp

Lines changed: 10 additions & 8 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,13 +117,15 @@ 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(
125-
"Trying to hide property '%s' that is not part of the model.\n",
126-
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(
126+
"Trying to hide property '%s' that is not part of the model.\n",
127+
qPrintable(property->getName()));
128+
}
127129
}
128130
}
129131
}

0 commit comments

Comments
 (0)