diff --git a/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp b/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp index aaec4ebaf2..7f0ddd75d2 100644 --- a/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp +++ b/src/Gui/3Dconnexion/GuiNativeEventLinux.cpp @@ -21,17 +21,42 @@ ***************************************************************************/ #include +#include #include "GuiNativeEventLinux.h" #include "GuiApplicationNativeEventAware.h" #include +#include #include #include #include +namespace { +class RedirectStdErr +{ +public: + RedirectStdErr() + : fi(Base::FileInfo::getTempFileName()) + , file(stderr) + { + stderr = fopen(fi.filePath().c_str(), "w"); + } + ~RedirectStdErr() + { + fclose(stderr); + fi.deleteFile(); + stderr = file; + } + +private: + Base::FileInfo fi; + FILE* file; +}; +} + Gui::GuiNativeEvent::GuiNativeEvent(Gui::GUIApplicationNativeEventAware *app) : GuiAbstractNativeEvent(app) { @@ -47,14 +72,16 @@ Gui::GuiNativeEvent::~GuiNativeEvent() void Gui::GuiNativeEvent::initSpaceball(QMainWindow *window) { - Q_UNUSED(window) + // tmp. redirect stderr to a file to suppress an error message from spnav_open() + RedirectStdErr err; + Q_UNUSED(window) if (spnav_open() == -1) { Base::Console().Log("Couldn't connect to spacenav daemon. Please ignore if you don't have a spacemouse.\n"); } else { Base::Console().Log("Connected to spacenav daemon\n"); - QSocketNotifier* SpacenavNotifier = new QSocketNotifier(spnav_fd(), QSocketNotifier::Read, this); - connect(SpacenavNotifier, SIGNAL(activated(int)), this, SLOT(pollSpacenav())); - mainApp->setSpaceballPresent(true); + QSocketNotifier* SpacenavNotifier = new QSocketNotifier(spnav_fd(), QSocketNotifier::Read, this); + connect(SpacenavNotifier, SIGNAL(activated(int)), this, SLOT(pollSpacenav())); + mainApp->setSpaceballPresent(true); } }