Skip to content

Commit

Permalink
Merge pull request #2104 from SergioRAgostinho/vis-external-interactor
Browse files Browse the repository at this point in the history
Add pcl visualizer interactor null guards
  • Loading branch information
taketwo committed Nov 26, 2017
2 parents c00e7eb + 728f870 commit 5d18757
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions visualization/src/pcl_visualizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,8 @@ pcl::visualization::PCLVisualizer::spin ()
resetStoppedFlag ();
// Render the window before we start the interactor
win_->Render ();
interactor_->Start ();
if (interactor_)
interactor_->Start ();
}

/////////////////////////////////////////////////////////////////////////////////////////////
Expand All @@ -551,6 +552,9 @@ pcl::visualization::PCLVisualizer::spinOnce (int time, bool force_redraw)
}
#endif

if (!interactor_)
return;

if (time <= 0)
time = 1;

Expand Down Expand Up @@ -4457,14 +4461,18 @@ void
pcl::visualization::PCLVisualizer::close ()
{
#if ((VTK_MAJOR_VERSION == 5) && (VTK_MINOR_VERSION <= 4))
interactor_->stopped = true;
// This tends to close the window...
interactor_->stopLoop ();
if (interactor_)
{
interactor_->stopped = true;
// This tends to close the window...
interactor_->stopLoop ();
}
#else
stopped_ = true;
// This tends to close the window...
win_->Finalize ();
interactor_->TerminateApp ();
if (interactor_)
interactor_->TerminateApp ();
#endif
}

Expand Down Expand Up @@ -4556,10 +4564,11 @@ pcl::visualization::PCLVisualizer::ExitMainLoopTimerCallback::Execute (
if (timer_id != right_timer_id)
return;
// Stop vtk loop and send notification to app to wake it up
if (pcl_visualizer->interactor_)
#if ((VTK_MAJOR_VERSION == 5) && (VTK_MINOR_VERSION <= 4))
pcl_visualizer->interactor_->stopLoop ();
pcl_visualizer->interactor_->stopLoop ();
#else
pcl_visualizer->interactor_->TerminateApp ();
pcl_visualizer->interactor_->TerminateApp ();
#endif
}

Expand All @@ -4571,13 +4580,17 @@ pcl::visualization::PCLVisualizer::ExitCallback::Execute (
if (event_id != vtkCommand::ExitEvent)
return;
#if ((VTK_MAJOR_VERSION == 5) && (VTK_MINOR_VERSION <= 4))
pcl_visualizer->interactor_->stopped = true;
// This tends to close the window...
pcl_visualizer->interactor_->stopLoop ();
if (pcl_visualizer->interactor_)
{
pcl_visualizer->interactor_->stopped = true;
// This tends to close the window...
pcl_visualizer->interactor_->stopLoop ();
}
#else
pcl_visualizer->stopped_ = true;
// This tends to close the window...
pcl_visualizer->interactor_->TerminateApp ();
if (pcl_visualizer->interactor_)
pcl_visualizer->interactor_->TerminateApp ();
#endif
}

Expand Down

0 comments on commit 5d18757

Please sign in to comment.