Commit 0b436148 authored by Thiago Santini's avatar Thiago Santini

Homogenizes null pointers

Moving from C to C++ null pointer style
parent d1ac2a74
......@@ -19,7 +19,7 @@ void AudioRecorder::startRecording()
{
if (recorder) {
recorder->deleteLater();
recorder = NULL;
recorder = nullptr;
}
QUrl target = QUrl::fromLocalFile(QDir::currentPath() + "/audio.wav");
......@@ -45,6 +45,6 @@ void AudioRecorder::stopRecording()
}
recording = false;
recorder->deleteLater();
recorder = NULL;
recorder = nullptr;
}
}
......@@ -21,7 +21,7 @@ public slots:
void stopRecording();
private:
QAudioRecorder *recorder = NULL;
QAudioRecorder *recorder = nullptr;
bool recording = false;
Timestamp start;
};
......
......@@ -13,8 +13,8 @@ QMutex Camera::setCameraMutex;
Camera::Camera(QString id, QObject *parent)
: QObject(parent),
colorCode(CV_8UC3),
camera(NULL),
frameGrabber(NULL),
camera(nullptr),
frameGrabber(nullptr),
retriesLeft(0),
maxRetries(15)
{
......@@ -45,17 +45,17 @@ void Camera::reset()
if (camera) {
camera->stop();
camera->unload();
camera->setViewfinder( static_cast<FrameGrabber*>(NULL) );
camera->setViewfinder( static_cast<FrameGrabber*>(nullptr) );
// Delete straight away so the destructor from uvcengine service get's
// called and the device is not busy anymore
//camera->deleteLater();
delete camera;
camera = NULL;
camera = nullptr;
}
if (frameGrabber) {
frameGrabber->deleteLater();
frameGrabber = NULL;
frameGrabber = nullptr;
}
}
......
......@@ -37,8 +37,8 @@ CameraWidget::CameraWidget(QString id, ImageProcessor::Type type, QWidget *paren
gPerformanceMonitor.enrol(id, "Image Processor");
gPerformanceMonitor.enrol(id, "Data Recorder");
camera = NULL;
imageProcessor = NULL;
camera = nullptr;
imageProcessor = nullptr;
// Camera
cameraThread = new QThread();
......@@ -131,17 +131,17 @@ CameraWidget::~CameraWidget()
if (camera) {
camera->deleteLater();
camera = NULL;
camera = nullptr;
}
if (imageProcessor) {
imageProcessor->deleteLater();
imageProcessor = NULL;
imageProcessor = nullptr;
}
if (recorder) {
recorder->deleteLater();
recorder = NULL;
recorder = nullptr;
}
cameraThread->quit();
......
......@@ -55,7 +55,7 @@ public:
explicit DataRecorderThread(QString id, QString header, QObject *parent = 0)
: id(id),
header(header),
dataRecorder(NULL),
dataRecorder(nullptr),
QObject(parent)
{}
......@@ -63,7 +63,7 @@ public:
{
if (dataRecorder)
dataRecorder->deleteLater();
dataRecorder = NULL;
dataRecorder = nullptr;
}
DataRecorder *dataRecorder;
......
......@@ -8,12 +8,12 @@ static int gEyeDataId = qRegisterMetaType<EyeData>("EyeData");
EyeImageProcessor::EyeImageProcessor(QString id, QObject *parent)
:
QObject(parent),
cameraCalibration(NULL),
cameraCalibration(nullptr),
id(id),
sROI(QPointF(0,0)),
eROI(QPointF(1,1)),
pupilDetectionMethod(NULL),
pupilTrackingMethod(NULL)
pupilDetectionMethod(nullptr),
pupilTrackingMethod(nullptr)
{
availablePupilDetectionMethods.push_back(std::make_shared<PuRe>());
availablePupilDetectionMethods.push_back(std::make_shared<ElSe>());
......@@ -37,7 +37,7 @@ void EyeImageProcessor::updateConfig()
QMutexLocker locker(&cfgMutex);
cfg.load(settings);
pupilDetectionMethod = NULL;
pupilDetectionMethod = nullptr;
for (int i=0; i<availablePupilDetectionMethods.size(); i++)
if (cfg.pupilDetectionMethod == QString(availablePupilDetectionMethods[i]->description().c_str()) )
pupilDetectionMethod = availablePupilDetectionMethods[i];
......@@ -82,7 +82,7 @@ void EyeImageProcessor::process(Timestamp timestamp, const Mat &frame)
data.pupil = Pupil();
data.validPupil = false;
if (pupilDetectionMethod != NULL) {
if (pupilDetectionMethod != nullptr) {
Rect userROI = Rect(
Point( static_cast<int>(sROI.x() * data.input.cols),
static_cast<int>(sROI.y() * data.input.rows) ),
......
......@@ -12,7 +12,7 @@ FieldImageProcessor::FieldImageProcessor(QString id, QObject *parent)
sROI(QPointF(0,0)),
eROI(QPointF(1,1)),
forceSanitize(false),
cameraCalibration(NULL),
cameraCalibration(nullptr),
QObject(parent)
{
settings = new QSettings(gCfgDir + "/" + id + " ImageProcessor.ini", QSettings::IniFormat);
......
......@@ -9,7 +9,7 @@ FrameGrabber::FrameGrabber(QString id, int code, QObject *parent) :
QAbstractVideoSurface(parent),
id(id),
code(code),
yuvBuffer(NULL),
yuvBuffer(nullptr),
yuvBufferSize(0),
timestampOffset(0),
timeoutMs(2e3)
......
......@@ -7,9 +7,9 @@ GazeEstimation::GazeEstimation(QObject *parent)
: QObject(parent),
calibrated(false),
isCalibrating(false),
gazeEstimationMethod(NULL),
gazeEstimationMethod(nullptr),
lastOverlayIdx(0),
settings(NULL)
settings(nullptr)
{
availableGazeEstimationMethods.push_back( new PolyFit(PolyFit::POLY_1_X_Y_XY_XX_YY_XYY_YXX_XXYY) );
availableGazeEstimationMethods.push_back( new PolyFit(PolyFit::POLY_1_X_Y_XY) );
......
......@@ -23,7 +23,7 @@ public:
rw2(pow(w/2.0,2)),
rh2(pow(h/2.0,2)),
mn(DBL_MAX),
selected(NULL) {}
selected(nullptr) {}
int x, y, w, h, rw2, rh2;
double mn;
CollectionTuple *selected;
......
......@@ -3,11 +3,11 @@
ImageProcessor::ImageProcessor(QString id, Type type, QObject *parent)
: id(id),
type(type),
cameraCalibration(NULL),
eyeProcessor(NULL),
fieldProcessor(NULL),
eyeProcessorUI(NULL),
fieldProcessorUI(NULL)
cameraCalibration(nullptr),
eyeProcessor(nullptr),
fieldProcessor(nullptr),
eyeProcessorUI(nullptr),
fieldProcessorUI(nullptr)
{
Q_UNUSED(parent)
}
......
......@@ -204,19 +204,19 @@ void MainWindow::closeEvent(QCloseEvent *event)
if ( lEyeWidget ) {
lEyeWidget->close();
lEyeWidget->deleteLater();
lEyeWidget = NULL;
lEyeWidget = nullptr;
}
qInfo() << "Closing Right Eye Widget...";
if ( rEyeWidget ) {
rEyeWidget->close();
rEyeWidget->deleteLater();
rEyeWidget = NULL;
rEyeWidget = nullptr;
}
qInfo() << "Closing Field Widget...";
if ( fieldWidget ) {
fieldWidget->close();
fieldWidget->deleteLater();
fieldWidget = NULL;
fieldWidget = nullptr;
}
qInfo() << "Closing Gaze Estimation Widget...";
......@@ -235,37 +235,37 @@ void MainWindow::closeEvent(QCloseEvent *event)
if (performanceMonitorWidget) {
performanceMonitorWidget->close();
performanceMonitorWidget->deleteLater();
performanceMonitorWidget = NULL;
performanceMonitorWidget = nullptr;
}
qInfo() << "Closing Log Widget...";
if (logWidget) {
gLogWidget = NULL;
gLogWidget = nullptr;
logWidget->close();
logWidget->deleteLater();
logWidget = NULL;
logWidget = nullptr;
}
qInfo() << "Stopping journal and synchronizer";
if (journal) {
journal->deleteLater();
journal = NULL;
journal = nullptr;
}
if (audioRecorder) {
audioRecorder->deleteLater();
audioRecorder = NULL;
audioRecorder = nullptr;
}
if (synchronizer) {
synchronizer->deleteLater();
synchronizer = NULL;
synchronizer = nullptr;
}
if (settings) {
settings->deleteLater();
settings = NULL;
settings = nullptr;
}
event->accept();
......@@ -298,7 +298,7 @@ void MainWindow::setSubjectName(QString newSubjectName)
Q_ASSERT(re.isValid());
if (!re.exactMatch(newSubjectName)) {
QMessageBox::warning(NULL,
QMessageBox::warning(nullptr,
"Invalid subject name.",
QString("Invalid name: \"%1\".\n\nSubject names may contain only letters, numbers, dashes (-), and underscores (_).\nIn regex terms: %2").arg(newSubjectName,re.pattern()),
QMessageBox::Ok,
......@@ -318,7 +318,7 @@ void MainWindow::setSubjectName(QString newSubjectName)
void MainWindow::on_changeSubjectButton_clicked()
{
QString newSubjectName = QInputDialog::getText(this, "Set subject", "Subject name:", QLineEdit::Normal, QString(), NULL, Qt::CustomizeWindowHint);
QString newSubjectName = QInputDialog::getText(this, "Set subject", "Subject name:", QLineEdit::Normal, QString(), nullptr, Qt::CustomizeWindowHint);
setSubjectName(newSubjectName);
}
......
......@@ -100,7 +100,7 @@ private:
void setWorkingDirectory(QString dir);
void widgetButtonReact(QMainWindow *window, bool checked);
void createExtraMenus();
void setupWidget(ERWidget *widget, QSettings *settings, QPushButton *button=NULL);
void setupWidget(ERWidget *widget, QSettings *settings, QPushButton *button=nullptr);
const QString metaDataFile = "meta.tsv";
void storeMetaDataHead();
......
......@@ -8,7 +8,7 @@ using namespace std;
PerformanceMonitorWidget::PerformanceMonitorWidget(QString id, QWidget *parent) :
ERWidget(id, parent),
updateTimeMs(250),
formLayout(NULL),
formLayout(nullptr),
ui(new Ui::PerformanceMonitorWidget)
{
ui->setupUi(this);
......@@ -28,7 +28,7 @@ void PerformanceMonitorWidget::clear()
{
if (formLayout) {
delete formLayout;
formLayout = NULL;
formLayout = nullptr;
}
for (auto e = enrolled.begin(); e != enrolled.end(); e++) {
delete e->first;
......
......@@ -75,7 +75,7 @@ void Synchronizer::newFieldData(FieldData fieldData)
template<class T>
T* Synchronizer::getClosestInTime(Timestamp timestamp, list<T> &dataList)
{
T *closest = NULL;
T *closest = nullptr;
if (dataList.empty())
return closest;
......@@ -89,7 +89,7 @@ T* Synchronizer::getClosestInTime(Timestamp timestamp, list<T> &dataList)
}
if (minimum > maxAgeMs)
return NULL;
return nullptr;
return closest;
}
......
......@@ -2,7 +2,7 @@
bool gCalibrating = false;
bool gFreezePreview = false;
LogWidget *gLogWidget = NULL;
LogWidget *gLogWidget = nullptr;
// Initialized on startup
QElapsedTimer gTimer;
......
......@@ -34,7 +34,7 @@ public:
virtual ~PupilTrackingMethod() {}
// Tracking and detection logic
virtual void detectAndTrack(const Timestamp &ts, const cv::Mat &frame, const cv::Rect &roi, Pupil &pupil, std::shared_ptr<PupilDetectionMethod> pupilDetectionMethod=NULL, const float &minPupilDiameterPx=-1, const float &maxPupilDiameterPx=-1);
virtual void detectAndTrack(const Timestamp &ts, const cv::Mat &frame, const cv::Rect &roi, Pupil &pupil, std::shared_ptr<PupilDetectionMethod> pupilDetectionMethod=nullptr, const float &minPupilDiameterPx=-1, const float &maxPupilDiameterPx=-1);
// Detection implementation (can be overridden by providing a valid pointer to the detectAndTrack method, allowing the user to mix detectors and trackers)
virtual Pupil detect(const cv::Mat &frame, const cv::Rect &roi, const float &minPupilDiameterPx=-1, const float &maxPupilDiameterPx=-1) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment