Skip to content

Commit

Permalink
- Removed FilterProperty: it had possible memory leak and could retu…
Browse files Browse the repository at this point in the history
…rn references to already deleted memory.

 - AccelerometerChain transformation matrix is now instance specific.
  • Loading branch information
Antti Virtanen committed Feb 17, 2011
1 parent 06a31da commit a751ba8
Show file tree
Hide file tree
Showing 18 changed files with 70 additions and 252 deletions.
1 change: 0 additions & 1 deletion adaptors/mrstaccelerometer/mrstaccelerometeradaptor.h
Expand Up @@ -4,7 +4,6 @@
#include <QString>
#include <QStringList>
#include <linux/input.h>
#include <filterproperty.h>
#include "deviceadaptorringbuffer.h"
#include "datatypes/orientationdata.h"
#include <QTime>
Expand Down
15 changes: 6 additions & 9 deletions adaptors/touchadaptor/touchadaptor.cpp
Expand Up @@ -7,6 +7,7 @@
@author Ustun Ergenoglu <ext-ustun.ergenoglu@nokia.com>
@author Timo Rongas <ext-timo.2.rongas@nokia.com>
@author Antti Virtanen <antti.i.virtanen@nokia.com>
This file is part of Sensord.
Expand All @@ -33,9 +34,8 @@

const int TouchAdaptor::HARD_MAX_TOUCH_POINTS = 5;

TouchAdaptor::TouchAdaptor(const QString& id) : InputDevAdaptor(id, HARD_MAX_TOUCH_POINTS), rangeInfo_(*this)
TouchAdaptor::TouchAdaptor(const QString& id) : InputDevAdaptor(id, HARD_MAX_TOUCH_POINTS)
{
rangeInfo_((RangeInfo){0, 0, 0, 0});

//This was previously in the base class, but it's not
//possible call virtual methods from base class constructor.
Expand Down Expand Up @@ -65,7 +65,6 @@ bool TouchAdaptor::checkInputDevice(QString path, QString matchString)
int fd;
char deviceName[256];
unsigned char evtype_bitmask[20+1];
RangeInfo rInfo;

fd = open(path.toLocal8Bit().constData(), O_RDONLY);
if (fd == -1) {
Expand Down Expand Up @@ -105,14 +104,12 @@ bool TouchAdaptor::checkInputDevice(QString path, QString matchString)
// Make separate for each input device if necessary.
struct input_absinfo info;
ioctl(fd, EVIOCGABS(ABS_X), &info);
rInfo.xMin = info.minimum;
rInfo.xRange = info.maximum - info.minimum;
rangeInfo_.xMin = info.minimum;
rangeInfo_.xRange = info.maximum - info.minimum;

ioctl(fd, EVIOCGABS(ABS_Y), &info);
rInfo.yMin = info.minimum;
rInfo.yRange = info.maximum - info.minimum;

rangeInfo_(rInfo);
rangeInfo_.yMin = info.minimum;
rangeInfo_.yRange = info.maximum - info.minimum;

close(fd);

Expand Down
13 changes: 6 additions & 7 deletions adaptors/touchadaptor/touchadaptor.h
Expand Up @@ -7,6 +7,7 @@
@author Ustun Ergenoglu <ext-ustun.ergenoglu@nokia.com>
@author Timo Rongas <ext-timo.2.rongas@nokia.com>
@author Antti Virtanen <antti.i.virtanen@nokia.com>
This file is part of Sensord.
Expand All @@ -29,7 +30,6 @@

#include "inputdevadaptor.h"
#include "deviceadaptorringbuffer.h"
#include "filterproperty.h"
#include <QObject>
#include "touchdata.h"

Expand All @@ -44,7 +44,6 @@
class TouchAdaptor : public InputDevAdaptor
{
Q_OBJECT;
Q_PROPERTY(TouchAdaptor::RangeInfo rangeinfo READ rangeInfo_)
public:
/**
* Factory method for gaining a new instance of TouchAdaptor class.
Expand All @@ -70,26 +69,26 @@ class TouchAdaptor : public InputDevAdaptor
/**
* Holds values read from the driver.
*/
struct TouchValues_ {
struct TouchValues {
int x;
int y;
int z;
int volume;
int toolWidth;
TouchData::FingerState fingerState;
};
typedef struct TouchValues_ TouchValues;

/**
* Holds information related to screen properties.
*/
struct RangeInfo_ {
struct RangeInfo {
RangeInfo() : xMin(0), yMin(0), xRange(0), yRange(0) {};

int xMin; /**< Minimum value from the driver for X-axis */
int yMin; /**< Minimum value from the driver for Y-axis */
int xRange; /**< Width of X-axis */
int yRange; /**< Width of Y-axis */
};
typedef struct RangeInfo_ RangeInfo;

/**
* Verify whether the input device handle on given path is a touchscreen device.
Expand All @@ -114,7 +113,7 @@ class TouchAdaptor : public InputDevAdaptor

DeviceAdaptorRingBuffer<TouchData>* outputBuffer_;
TouchValues touchValues_[5];
FilterProperty<RangeInfo> rangeInfo_;
RangeInfo rangeInfo_;
};

#endif
13 changes: 6 additions & 7 deletions chains/accelerometerchain/accelerometerchain.cpp
Expand Up @@ -7,6 +7,7 @@
@author Timo Rongas <ext-timo.2.rongas@nokia.com>
@author Ustun Ergenoglu <ext-ustun.ergenoglu@nokia.com>
@author Antti Virtanen <antti.i.virtanen@nokia.com>
This file is part of Sensord.
Expand Down Expand Up @@ -35,13 +36,12 @@

#include "coordinatealignfilter/coordinatealignfilter.h"

double AccelerometerChain::aconv_[3][3] = { { 1.0, 0.0, 0.0 },
{ 0.0, 1.0, 0.0 },
{ 0.0, 0.0, 1.0 } };

AccelerometerChain::AccelerometerChain(const QString& id) :
AbstractChain(id)
{
aconv_ = { { 1.0, 0.0, 0.0 },
{ 0.0, 1.0, 0.0 },
{ 0.0, 0.0, 1.0 } };
SensorManager& sm = SensorManager::instance();

accelerometerAdaptor_ = sm.requestDeviceAdaptor("accelerometeradaptor");
Expand All @@ -64,8 +64,7 @@ AccelerometerChain::AccelerometerChain(const QString& id) :

accCoordinateAlignFilter_ = sm.instantiateFilter("coordinatealignfilter");
Q_ASSERT(accCoordinateAlignFilter_);
qRegisterMetaType<TMatrix>("TMatrix");
((CoordinateAlignFilter*)accCoordinateAlignFilter_)->setProperty("transMatrix", QVariant::fromValue(TMatrix(aconv_)));
((CoordinateAlignFilter*)accCoordinateAlignFilter_)->setMatrix(TMatrix(aconv_));

outputBuffer_ = new RingBuffer<AccelerationData>(128);
nameOutputBuffer("accelerometer", outputBuffer_);
Expand Down Expand Up @@ -132,7 +131,7 @@ bool AccelerometerChain::setMatrixFromString(const QString& str)
return false;
}

for (int i = 0; i < 9; i++)
for (int i = 0; i < 9; ++i)
{
aconv_[i/3][i%3] = strList.at(i).toInt();
}
Expand Down
3 changes: 2 additions & 1 deletion chains/accelerometerchain/accelerometerchain.h
Expand Up @@ -6,6 +6,7 @@
Copyright (C) 2009-2010 Nokia Corporation
@author Timo Rongas <ext-timo.2.rongas@nokia.com>
@author Antti Virtanen <antti.i.virtanen@nokia.com>
This file is part of Sensord.
Expand Down Expand Up @@ -71,7 +72,7 @@ public Q_SLOTS:

bool setMatrixFromString(const QString& str);

static double aconv_[3][3];
double aconv_[3][3];
Bin* filterBin_;

DeviceAdaptor* accelerometerAdaptor_;
Expand Down
1 change: 0 additions & 1 deletion core/core.pro
Expand Up @@ -30,7 +30,6 @@ SOURCES += sensormanager.cpp \
deviceadaptor.cpp \
loader.cpp \
plugin.cpp \
filterproperty.cpp \
abstractsensor_a.cpp \
abstractsensor.cpp \
logging.cpp \
Expand Down
27 changes: 0 additions & 27 deletions core/filterproperty.cpp

This file was deleted.

159 changes: 0 additions & 159 deletions core/filterproperty.h

This file was deleted.

1 change: 0 additions & 1 deletion core/inputdevadaptor.h
Expand Up @@ -33,7 +33,6 @@
#include <QStringList>
#include <QFile>
#include <linux/input.h>
#include "filterproperty.h"

/**
* @brief Base class for adaptors accessing device drivers through Linux Input
Expand Down

0 comments on commit a751ba8

Please sign in to comment.