-
Notifications
You must be signed in to change notification settings - Fork 463
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 OSX crash (fix #1531) #1532
base: noetic-devel
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,6 +72,7 @@ ImageDisplay::ImageDisplay() : ImageDisplayBase(), texture_() | |
this, SLOT(updateNormalizeOptions())); | ||
|
||
got_float_image_ = false; | ||
has_run_once_ = false; | ||
} | ||
|
||
void ImageDisplay::onInitialize() | ||
|
@@ -114,12 +115,13 @@ void ImageDisplay::onInitialize() | |
screen_rect_->setBoundingBox(aabInf); | ||
setMaterial(*screen_rect_, material_); | ||
img_scene_node_->attachObject(screen_rect_); | ||
img_scene_node_->setVisible(false); | ||
} | ||
|
||
render_panel_ = new RenderPanel(); | ||
render_panel_->getRenderWindow()->addListener(this); | ||
render_panel_->getRenderWindow()->setAutoUpdated(false); | ||
render_panel_->getRenderWindow()->setActive(false); | ||
|
||
render_panel_->resize(640, 480); | ||
render_panel_->initialize(img_scene_manager_, context_); | ||
|
||
|
@@ -136,12 +138,32 @@ ImageDisplay::~ImageDisplay() | |
{ | ||
if (initialized()) | ||
{ | ||
render_panel_->getRenderWindow()->removeListener(this); | ||
|
||
delete render_panel_; | ||
delete screen_rect_; | ||
removeAndDestroyChildNode(img_scene_node_->getParentSceneNode(), img_scene_node_); | ||
} | ||
} | ||
|
||
void ImageDisplay::preRenderTargetUpdate(const Ogre::RenderTargetEvent& /*evt*/) | ||
{ | ||
if (has_run_once_) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems to be at the core of this PR: You need to ignore the first rendering of the scene. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unfortunately I didn't get to the root of the race condition. I don't understand the rviz code and the OSX specifics well enough I'm afraid. |
||
{ | ||
img_scene_node_->setVisible(true); | ||
} | ||
else | ||
{ | ||
has_run_once_ = true; | ||
img_scene_node_->setVisible(false); | ||
} | ||
} | ||
|
||
void ImageDisplay::postRenderTargetUpdate(const Ogre::RenderTargetEvent& /*evt*/) | ||
{ | ||
img_scene_node_->setVisible(false); | ||
} | ||
|
||
void ImageDisplay::onEnable() | ||
{ | ||
ImageDisplayBase::subscribe(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you create a separate SceneManager? Isn't this rendering an empty scene - only comprising the camera image, but not the default rviz scene anymore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I just use the standard SceneManager, rviz crashes when adding a second camera display. I took the idea of having a separate SceneManager from the image display code where this exact code is being used. Again though I'm not sure about the internals; I agree that it should work just using the default SceneManager but I don't understand the code well enough to make this work. On a general note, quite a bit of code is duplicated between the image and camera displays and could probably be abstracted away.