Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix vanishing "Global Options" property when adding a RobotModelDisplay #1808

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/rviz/properties/property.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include <QPalette>
#include <QLineEdit>
#include <QSpinBox>
#include <QTimer>

#include <rviz/properties/float_edit.h>
#include <rviz/properties/property_tree_model.h>
Expand Down Expand Up @@ -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++)
Expand Down
4 changes: 0 additions & 4 deletions src/rviz/properties/property_tree_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
8 changes: 7 additions & 1 deletion src/rviz/properties/property_tree_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include <rviz/properties/status_list.h>

#include <rviz/properties/property_tree_widget.h>
#include <ros/console.h>

namespace rviz
{
Expand Down Expand Up @@ -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.");
}
}

Expand Down
Loading