X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fjogshuttle.cpp;h=6a61812e8b927d5cfad461961ef8ceb185b7d895;hb=9d7083dc62a7c6cb319a00efcc7a279db0305abc;hp=04ee736082d3923942696297196f4998975d63e0;hpb=400911277ef75457aabf0a2c020096cfec093cc2;p=kdenlive diff --git a/src/jogshuttle.cpp b/src/jogshuttle.cpp index 04ee7360..6a61812e 100644 --- a/src/jogshuttle.cpp +++ b/src/jogshuttle.cpp @@ -68,7 +68,7 @@ #define JOG_STOP 10020 #define MAX_SHUTTLE_RANGE 7 -void ShuttleThread::init(QObject *parent, QString device) +void ShuttleThread::init(QObject *parent, const QString &device) { m_parent = parent; m_device = device; @@ -105,17 +105,19 @@ void ShuttleThread::run() fd_set readset; struct timeval timeout; - int num_warnings, readResult = 0; + int num_warnings = 0, readResult = 0; int result, iof = -1; /* get fd settings */ - if ((iof = fcntl(fd, F_GETFL, 0)) != -1) { - /* set fd non blocking */ - fcntl(fd, F_SETFL, iof | O_NONBLOCK); - } else { - fprintf(stderr, "Can't set Jog Shuttle FILE DESCRIPTOR to O_NONBLOCK and stop thread\n"); - return; - } + if ((iof = fcntl(fd, F_GETFL, 0)) == -1) { + fprintf(stderr, "Can't get Jog Shuttle file status\n"); + close(fd); + return; + } else if (fcntl(fd, F_SETFL, iof | O_NONBLOCK) == -1) { + fprintf(stderr, "Can't set Jog Shuttle FILE DESCRIPTOR to O_NONBLOCK and stop thread\n"); + close(fd); + return; + } /* enter thread loop */ while (!stop_me) { @@ -265,7 +267,7 @@ void ShuttleThread::jog(unsigned int value) } -JogShuttle::JogShuttle(QString device, QObject *parent) : +JogShuttle::JogShuttle(const QString &device, QObject *parent) : QObject(parent) { initDevice(device); @@ -276,7 +278,7 @@ JogShuttle::~JogShuttle() stopDevice(); } -void JogShuttle::initDevice(QString device) +void JogShuttle::initDevice(const QString &device) { if (m_shuttleProcess.isRunning()) { if (device == m_shuttleProcess.m_device) return; @@ -332,3 +334,5 @@ void JogShuttle::customEvent(QEvent* e) // #include "jogshuttle.moc" + +#include "jogshuttle.moc"