Gui: tmp. redirect stderr to a file to suppress an error message from spnav
This commit is contained in:
@@ -21,17 +21,42 @@
|
||||
***************************************************************************/
|
||||
|
||||
#include <FCConfig.h>
|
||||
#include <cstdio>
|
||||
|
||||
#include "GuiNativeEventLinux.h"
|
||||
|
||||
#include "GuiApplicationNativeEventAware.h"
|
||||
#include <Base/Console.h>
|
||||
#include <Base/FileInfo.h>
|
||||
#include <QMainWindow>
|
||||
|
||||
#include <QSocketNotifier>
|
||||
|
||||
#include <spnav.h>
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user