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 segfault (lambda reference capture) of VisualizerWithCustomAnimation::Play #6804

Merged
merged 3 commits into from
Jun 14, 2024
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
- Fix RANSAC early stop if no inliers in a specific iteration (PR #6789)
- Fix segmentation fault (infinite recursion) of DetectPlanarPatches if multiple points have same coordinates (PR #6794)
- Fix build with fmt v10.2.0 (#6783)
- Fix segmentation fault (lambda reference capture) of VisualizerWithCustomAnimation::Play (PR #6804)

## 0.13

Expand Down
1 change: 1 addition & 0 deletions cpp/open3d/utility/ProgressBar.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class ProgressBar {
virtual ProgressBar &operator++();
void SetCurrentCount(size_t n);
size_t GetCurrentCount() const;
virtual ~ProgressBar() = default;

protected:
const size_t resolution_ = 40;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ void VisualizerWithCustomAnimation::Play(
is_redraw_required_ = true;
UpdateWindowTitle();
recording_file_index_ = 0;
utility::ProgressBar progress_bar(view_control.NumOfFrames(),
"Play animation: ");
auto progress_bar_ptr = std::make_shared<utility::ProgressBar>(
view_control.NumOfFrames(), "Play animation: ");
auto trajectory_ptr = std::make_shared<camera::PinholeCameraTrajectory>();
bool recording_trajectory = view_control.IsValidPinholeCameraTrajectory();
if (recording) {
Expand All @@ -94,7 +94,7 @@ void VisualizerWithCustomAnimation::Play(
RegisterAnimationCallback([this, recording, recording_depth,
close_window_when_animation_ends,
recording_trajectory, trajectory_ptr,
&progress_bar](Visualizer *vis) {
progress_bar_ptr](Visualizer *vis) {
// The lambda function captures no references to avoid dangling
// references
auto &view_control =
Expand All @@ -121,7 +121,7 @@ void VisualizerWithCustomAnimation::Play(
}
}
view_control.Step(1.0);
++progress_bar;
++(*progress_bar_ptr);
if (view_control.IsPlayingEnd(recording_file_index_)) {
view_control.SetAnimationMode(
ViewControlWithCustomAnimation::AnimationMode::FreeMode);
Expand Down
Loading