TaskPanel: Fix assertion

When loading an .rviz config with MTC displays disabled, the mainloop_job to create a TaskPanel
will never be executed (because the display is disabled). Removing the display will then hit the
assertion that DISPLAY_COUNT > 0.
Fixed, by not relying on Display::update, but just scheduling a Qt GUI job via QTimer::singleShot().
This commit is contained in:
Robert Haschke 2020-10-22 17:33:40 +02:00
parent cb0f20cad7
commit 8b8666c64e
2 changed files with 3 additions and 3 deletions

View File

@ -98,8 +98,8 @@ void TaskDisplay::onInitialize() {
trajectory_visual_->onInitialize(scene_node_, context_);
task_list_model_->setDisplayContext(context_);
// create a new TaskPanel by default
// by post-poning this to main loop, we can ensure that rviz has loaded everything before
mainloop_jobs_.addJob([this]() { TaskPanel::incDisplayCount(context_->getWindowManager()); });
// by post-poning this to Qt's GUI loop, we can ensure that rviz has loaded everything before
QTimer::singleShot(0, [this]() { TaskPanel::incDisplayCount(context_->getWindowManager()); });
}
void TaskDisplay::loadRobotModel() {

View File

@ -135,7 +135,7 @@ void TaskPanel::incDisplayCount(rviz::WindowManagerInterface* window_manager) {
rviz::VisualizationFrame* vis_frame = dynamic_cast<rviz::VisualizationFrame*>(window_manager);
if (SINGLETON || !vis_frame)
return; // already define, nothing to do
return; // already defined, nothing to do
QDockWidget* dock =
vis_frame->addPanelByName("Motion Planning Tasks", "moveit_task_constructor/Motion Planning Tasks",