Skip to content

Commit 792a139

Browse files
committed
Fix segfault when removing displays
When there was an instance of a DisplayGroupVisibilityProperty (e.g. due to a CameraDisplay), the display's virtual function BoolProperty::getBool() was called from the Property destructor (when removing it from the model), which caused undefined behavior.
1 parent a4c276d commit 792a139

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/rviz/displays_panel.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,8 @@ void DisplaysPanel::onDeleteDisplay()
179179
// Displays can emit signals from other threads with self pointers. We're
180180
// freeing the display now, so ensure no one is listening to those signals.
181181
displays_to_delete[ i ]->disconnect();
182+
// Remove dipslay from property tree to avoid memory access after deletion
183+
displays_to_delete[ i ]->getParent()->takeChild(displays_to_delete[ i ]);
182184
// Delete display later in case there are pending signals to it.
183185
displays_to_delete[ i ]->deleteLater();
184186
}

0 commit comments

Comments
 (0)