From 171eb3cfd1ec69cb6ff72da3ca41a1a4caa74eef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20G=C3=B6rner?= Date: Tue, 12 May 2020 16:44:03 +0200 Subject: [PATCH] PropertyTree: set custom SelectionModel only with valid model (#1504) --- src/rviz/properties/property_tree_widget.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/rviz/properties/property_tree_widget.cpp b/src/rviz/properties/property_tree_widget.cpp index 28c25a16d7..c284af5453 100644 --- a/src/rviz/properties/property_tree_widget.cpp +++ b/src/rviz/properties/property_tree_widget.cpp @@ -103,11 +103,12 @@ void PropertyTreeWidget::setModel(PropertyTreeModel* model) } model_ = model; QTreeView::setModel(model_); - QItemSelectionModel* m = selectionModel(); - setSelectionModel(new PropertySelectionModel(model_)); - m->deleteLater(); if (model_) { + QItemSelectionModel* m = selectionModel(); + setSelectionModel(new PropertySelectionModel(model_)); + m->deleteLater(); + connect(model_, SIGNAL(propertyHiddenChanged(const Property*)), this, SLOT(propertyHiddenChanged(const Property*)), Qt::QueuedConnection); connect(model_, SIGNAL(expand(const QModelIndex&)), this, SLOT(expand(const QModelIndex&)));