Skip to content

Commit

Permalink
Merge PRs ros-visualization#1807 + ros-visualization#1808: Qt 5.15 co…
Browse files Browse the repository at this point in the history
…mpatibility
  • Loading branch information
rhaschke committed Nov 5, 2023
2 parents 4129ee4 + df72fce commit d4fbc3c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
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

0 comments on commit d4fbc3c

Please sign in to comment.