From c608239e111215169827d1f3bbace0b97c8e9f06 Mon Sep 17 00:00:00 2001 From: Robert Haschke Date: Sun, 5 Nov 2023 10:53:54 +0100 Subject: [PATCH 1/3] Remove redundant check Validity is checked in indexOf() as well. --- src/rviz/properties/property_tree_model.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/rviz/properties/property_tree_model.cpp b/src/rviz/properties/property_tree_model.cpp index 5cf2ab3d58..6c5b737775 100644 --- a/src/rviz/properties/property_tree_model.cpp +++ b/src/rviz/properties/property_tree_model.cpp @@ -108,10 +108,6 @@ QModelIndex PropertyTreeModel::parentIndex(const Property* child) const return QModelIndex(); } Property* parent = child->getParent(); - if (parent == root_property_ || !parent) - { - return QModelIndex(); - } return indexOf(parent); } From 66791ab91b9a7546a52d9300b400c7cef89adb5f Mon Sep 17 00:00:00 2001 From: Robert Haschke Date: Sun, 5 Nov 2023 11:08:47 +0100 Subject: [PATCH 2/3] Don't hide rows of properties not within the model --- src/rviz/properties/property_tree_widget.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/rviz/properties/property_tree_widget.cpp b/src/rviz/properties/property_tree_widget.cpp index a935e29d63..7387eb6730 100644 --- a/src/rviz/properties/property_tree_widget.cpp +++ b/src/rviz/properties/property_tree_widget.cpp @@ -37,6 +37,7 @@ #include #include +#include namespace rviz { @@ -122,7 +123,12 @@ void PropertyTreeWidget::propertyHiddenChanged(const Property* property) { if (model_) { - setRowHidden(property->rowNumberInParent(), model_->parentIndex(property), property->getHidden()); + const auto& parent_index = model_->parentIndex(property); + if (parent_index.isValid()) + setRowHidden(property->rowNumberInParent(), parent_index, property->getHidden()); + else + ROS_WARN_STREAM("Trying to hide property '" << qPrintable(property->getName()) + << "' that is not part of the model."); } } From df72fce669683e01a67156bec3f847f6449b30a7 Mon Sep 17 00:00:00 2001 From: Robert Haschke Date: Sun, 5 Nov 2023 11:28:30 +0100 Subject: [PATCH 3/3] Postpone hiding of properties until insertion into model is finished When disabling and re-enabling a RobotModelDisplay, its hidden properties (e.g. Alpha of a link having no geometry), were not hidden anymore. --- src/rviz/properties/property.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/rviz/properties/property.cpp b/src/rviz/properties/property.cpp index 1c4fb32576..200ebe2133 100644 --- a/src/rviz/properties/property.cpp +++ b/src/rviz/properties/property.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -395,7 +396,8 @@ void Property::setModel(PropertyTreeModel* model) model_ = model; if (model_ && hidden_) { - model_->emitPropertyHiddenChanged(this); + // process propertyHiddenChanged after insertion into model has finished + QTimer::singleShot(0, model_, [this]() { model_->emitPropertyHiddenChanged(this); }); } int num_children = numChildren(); for (int i = 0; i < num_children; i++)