Basic GUIPlugin causes Gazebo Client to segfault when exiting, why?
Hi,
I implemented a GUIPlugin based on this tutorial: http://gazebosim.org/tutorials?tut=gu...
I added some buttons and implemented the callback functions and it did what it was supposed to do, but whenever I close the client, I encounter a segmentation fault. (It's not the server, but the client.) I tried tracking down the cause for this and basically ended up removing every line of actual code and the segmentation fault still appears.
This is my GUIPlugin:
Source:
#include "PROJECT_NAME/ScenarioPlugin.h"
using namespace gazebo;
// Register this plugin with the simulator
GZ_REGISTER_GUI_PLUGIN(ScenarioPlugin)
// Constructor
ScenarioPlugin::ScenarioPlugin() {}
// Destructor
ScenarioPlugin::~ScenarioPlugin() {}
Header:
#include <gazebo/common/Plugin.hh>
#include <gazebo/gui/GuiPlugin.hh>
#ifndef Q_MOC_RUN // See: https://bugreports.qt-project.org/browse/QTBUG-22829
# include <gazebo/transport/transport.hh>
# include <gazebo/gui/gui.hh>
#endif
namespace gazebo
{
class GAZEBO_VISIBLE ScenarioPlugin : public GUIPlugin
{
Q_OBJECT
public:
/// \brief Constructor
ScenarioPlugin();
/// \brief Destructor
virtual ~ScenarioPlugin();
};
} // namespace gazebo
This is the corresponding passage in the CMakeLists.txt:
QT4_WRAP_CPP(headers_MOC include/${PROJECT_NAME}/ScenarioPlugin.h)
add_library(ScenarioPlugin SHARED ${headers_MOC} src/ScenarioPlugin.cpp)
target_link_libraries(ScenarioPlugin ${GAZEBO_LIBRARIES} ${QT_LIBRARIES} ${PROTOBUF_LIBRARIES})
install (TARGETS ScenarioPlugin DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION})
and here how the plugin is used in the .world file:
<world name='default'>
<gui>
<plugin name='scenario_plugin' filename='libScenarioPlugin.so'/>
</gui>
...
The client starts normally and then shows a black frame at the top right corner of the word view. If the client is then closed, it segfaults. What causes this error? What do I have to do to close the plugin gracefully? GDB gives me the following backtrace:
#0 0x0000000000000020 in ?? ()
#1 0x00007ffff7735abe in ?? () from /usr/lib/x86_64-linux-gnu/libgazebo_gui.so.6
#2 0x00007ffff7752dbc in gazebo::gui::RenderWidget::~RenderWidget() () from /usr/lib/x86_64-linux-gnu/libgazebo_gui.so.6
#3 0x00007ffff7752e69 in gazebo::gui::RenderWidget::~RenderWidget() () from /usr/lib/x86_64-linux-gnu/libgazebo_gui.so.6
#4 0x00007ffff7781fc4 in gazebo::gui::MainWindow::closeEvent(QCloseEvent*) () from /usr/lib/x86_64-linux-gnu/libgazebo_gui.so.6
#5 0x00007ffff3cd8116 in QWidget::event(QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#6 0x00007ffff4092a33 in QMainWindow::event(QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#7 0x00007ffff3c88e2c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#8 0x00007ffff3c8f4a0 in QApplication::notify(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#9 0x00007ffff73354dd in QCoreApplication::notifyInternal(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#10 0x00007ffff3cd4989 in QWidgetPrivate::close_helper(QWidgetPrivate::CloseMode) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#11 0x00007ffff3cf30b2 in QApplication::x11ClientMessage(QWidget*, _XEvent*, bool) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#12 0x00007ffff3d02892 in QApplication::x11ProcessEvent(_XEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#13 0x00007ffff3d2ab32 in ?? () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#14 0x00007ffff1bebe04 in g_main_context_dispatch () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#15 0x00007ffff1bec048 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#16 0x00007ffff1bec0ec in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#17 0x00007ffff73627a1 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#18 0x00007ffff3d2abe6 in ?? () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#19 0x00007ffff73340af in QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQtCore.so ...