Browse Source

addressed fixmes and some issues from cppcheck

QGC4.4
Bryan Godbolt 15 years ago
parent
commit
2265827375
  1. 4
      src/comm/Parameter.h
  2. 6
      src/comm/ParameterList.h
  3. 10
      src/ui/RadioCalibration/RadioCalibrationData.cc
  4. 3
      src/ui/RadioCalibration/RadioCalibrationData.h
  5. 62
      src/ui/RadioCalibration/RadioCalibrationWindow.cc
  6. 7
      src/ui/RadioCalibration/RadioCalibrationWindow.h

4
src/comm/Parameter.h

@ -61,8 +61,8 @@ namespace OpalRT @@ -61,8 +61,8 @@ namespace OpalRT
const QGCParamID& getParamID() const {return *paramID;}
void setOpalID(unsigned short opalID) {this->opalID = opalID;}
const QString& getSimulinkPath() {return *simulinkPath;}
const QString& getSimulinkName() {return *simulinkName;}
const QString& getSimulinkPath() const {return *simulinkPath;}
const QString& getSimulinkName() const {return *simulinkName;}
uint8_t getComponentID() const {return componentID;}
float getValue();
void setValue(float value);

6
src/comm/ParameterList.h

@ -53,11 +53,11 @@ namespace OpalRT @@ -53,11 +53,11 @@ namespace OpalRT
const_iterator(const const_iterator& other);
const_iterator& operator+=(int i) {index += i; return *this;}
bool operator<(const const_iterator& other) {return (this->paramList == other.paramList)
bool operator<(const const_iterator& other) const {return (this->paramList == other.paramList)
&&(this->index<other.index);}
bool operator==(const const_iterator& other) {return (this->paramList == other.paramList)
bool operator==(const const_iterator& other) const {return (this->paramList == other.paramList)
&&(this->index==other.index);}
bool operator!=(const const_iterator& other) {return !((*this) == other);}
bool operator!=(const const_iterator& other) const {return !((*this) == other);}
const Parameter& operator*() const {return paramList[index];}
const Parameter* operator->() const {return &paramList[index];}

10
src/ui/RadioCalibration/RadioCalibrationData.cc

@ -48,18 +48,14 @@ const float* RadioCalibrationData::operator [](int i) const @@ -48,18 +48,14 @@ const float* RadioCalibrationData::operator [](int i) const
return NULL;
}
const QVector<float>& RadioCalibrationData::operator ()(int i) const
const QVector<float>& RadioCalibrationData::operator ()(const int i) const throw(std::out_of_range)
{
if (i < data->size())
if ((i < data->size()) && (i >=0))
{
return (*data)[i];
}
// FIXME Bryan
// FIXME James
// This is not good. If it is ever used after being returned it will cause a crash
// return QVector<float>();
throw std::out_of_range("Invalid channel index");
}
QString RadioCalibrationData::toString(RadioElement element) const

3
src/ui/RadioCalibration/RadioCalibrationData.h

@ -34,6 +34,7 @@ This file is part of the QGROUNDCONTROL project @@ -34,6 +34,7 @@ This file is part of the QGROUNDCONTROL project
#include <QDebug>
#include <QVector>
#include <QString>
#include <stdexcept>
/**
@ -66,7 +67,7 @@ public: @@ -66,7 +67,7 @@ public:
};
const float* operator[](int i) const;
const QVector<float>& operator()(int i) const;
const QVector<float>& operator()(int i) const throw(std::out_of_range);
void set(int element, int index, float value) {(*data)[element][index] = value;}
public slots:

62
src/ui/RadioCalibration/RadioCalibrationWindow.cc

@ -52,38 +52,38 @@ RadioCalibrationWindow::RadioCalibrationWindow(QWidget *parent) : @@ -52,38 +52,38 @@ RadioCalibrationWindow::RadioCalibrationWindow(QWidget *parent) :
setUASId(0);
}
void RadioCalibrationWindow::setChannelRaw(int ch, float raw)
{
/** this expects a particular channel to function mapping
\todo allow run-time channel mapping
*/
switch (ch)
{
case 0:
aileron->channelChanged(raw);
break;
case 1:
elevator->channelChanged(raw);
break;
case 2:
throttle->channelChanged(raw);
break;
case 3:
rudder->channelChanged(raw);
break;
case 4:
gyro->channelChanged(raw);
break;
case 5:
pitch->channelChanged(raw);
break;
//void RadioCalibrationWindow::setChannelRaw(int ch, float raw)
//{
// /** this expects a particular channel to function mapping
// \todo allow run-time channel mapping
// */
// switch (ch)
// {
// case 0:
// aileron->channelChanged(raw);
// break;
// case 1:
// elevator->channelChanged(raw);
// break;
// case 2:
// throttle->channelChanged(raw);
// break;
// case 3:
// rudder->channelChanged(raw);
// break;
// case 4:
// gyro->channelChanged(raw);
// break;
// case 5:
// pitch->channelChanged(raw);
// break;
}
}
// }
//}
void RadioCalibrationWindow::setChannelScaled(int ch, float normalized)
{
//void RadioCalibrationWindow::setChannelScaled(int ch, float normalized)
//{
// FIXME James
// FIXME Bryan
@ -113,9 +113,9 @@ void RadioCalibrationWindow::setChannelScaled(int ch, float normalized) @@ -113,9 +113,9 @@ void RadioCalibrationWindow::setChannelScaled(int ch, float normalized)
// }
}
//}
void RadioCalibrationWindow::setChannel(int ch, float raw, float normalized)
void RadioCalibrationWindow::setChannel(int ch, float raw)
{
/** this expects a particular channel to function mapping
\todo allow run-time channel mapping

7
src/ui/RadioCalibration/RadioCalibrationWindow.h

@ -66,9 +66,10 @@ public: @@ -66,9 +66,10 @@ public:
explicit RadioCalibrationWindow(QWidget *parent = 0);
public slots:
void setChannel(int ch, float raw, float normalized);
void setChannelRaw(int ch, float raw);
void setChannelScaled(int ch, float normalized);
void setChannel(int ch, float raw);
// @todo remove these functions if they are not needed - were added by lm on dec 14, 2010
// void setChannelRaw(int ch, float raw);
// void setChannelScaled(int ch, float normalized);
void loadFile();
void saveFile();
void send();

Loading…
Cancel
Save