mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Remove the pInfo pointer, make it a real structure instead.
This fixes the invalid pointer stage crash. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
0d62efaa39
commit
0a24e13469
2 changed files with 27 additions and 17 deletions
|
@ -9,7 +9,7 @@
|
||||||
#include "profile.h"
|
#include "profile.h"
|
||||||
#include "display.h"
|
#include "display.h"
|
||||||
|
|
||||||
RulerNodeItem2::RulerNodeItem2() : entry(NULL) , ruler(NULL)
|
RulerNodeItem2::RulerNodeItem2(struct plot_info& info) : pInfo(info), entry(NULL) , ruler(NULL)
|
||||||
{
|
{
|
||||||
setRect(QRect(QPoint(-8,8),QPoint(8,-8)));
|
setRect(QRect(QPoint(-8,8),QPoint(8,-8)));
|
||||||
setBrush(QColor(0xff, 0, 0, 127));
|
setBrush(QColor(0xff, 0, 0, 127));
|
||||||
|
@ -26,17 +26,17 @@ void RulerNodeItem2::setRuler(RulerItem2 *r)
|
||||||
|
|
||||||
void RulerNodeItem2::recalculate()
|
void RulerNodeItem2::recalculate()
|
||||||
{
|
{
|
||||||
struct plot_data *data = pInfo->entry+(pInfo->nr-1);
|
struct plot_data *data = pInfo.entry+(pInfo.nr-1);
|
||||||
uint16_t count = 0;
|
uint16_t count = 0;
|
||||||
if (x() < 0) {
|
if (x() < 0) {
|
||||||
setPos(0, y());
|
setPos(0, y());
|
||||||
} else if (x() > timeAxis->posAtValue(data->sec)) {
|
} else if (x() > timeAxis->posAtValue(data->sec)) {
|
||||||
setPos(timeAxis->posAtValue(data->sec), y());
|
setPos(timeAxis->posAtValue(data->sec), y());
|
||||||
} else {
|
} else {
|
||||||
data = pInfo->entry;
|
data = pInfo.entry;
|
||||||
count=0;
|
count=0;
|
||||||
while (timeAxis->posAtValue(data->sec) < x() && count < pInfo->nr) {
|
while (timeAxis->posAtValue(data->sec) < x() && count < pInfo.nr) {
|
||||||
data = pInfo->entry+count;
|
data = pInfo.entry+count;
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
setPos(timeAxis->posAtValue(data->sec), depthAxis->posAtValue(data->depth));
|
setPos(timeAxis->posAtValue(data->sec), depthAxis->posAtValue(data->depth));
|
||||||
|
@ -58,13 +58,12 @@ QVariant RulerNodeItem2::itemChange(GraphicsItemChange change, const QVariant &v
|
||||||
}
|
}
|
||||||
|
|
||||||
RulerItem2::RulerItem2():
|
RulerItem2::RulerItem2():
|
||||||
pInfo(NULL),
|
|
||||||
timeAxis(NULL),
|
timeAxis(NULL),
|
||||||
depthAxis(NULL),
|
depthAxis(NULL),
|
||||||
source(new RulerNodeItem2()),
|
source(new RulerNodeItem2(pInfo)),
|
||||||
dest(new RulerNodeItem2())
|
dest(new RulerNodeItem2(pInfo))
|
||||||
{
|
{
|
||||||
|
memset(&pInfo, 0, sizeof(pInfo));
|
||||||
source->setRuler(this);
|
source->setRuler(this);
|
||||||
dest->setRuler(this);
|
dest->setRuler(this);
|
||||||
}
|
}
|
||||||
|
@ -76,7 +75,7 @@ void RulerItem2::recalculate()
|
||||||
QFont font;
|
QFont font;
|
||||||
QFontMetrics fm(font);
|
QFontMetrics fm(font);
|
||||||
|
|
||||||
if (timeAxis == NULL || depthAxis == NULL || pInfo == NULL)
|
if (timeAxis == NULL || depthAxis == NULL || pInfo.nr == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
prepareGeometryChange();
|
prepareGeometryChange();
|
||||||
|
@ -168,10 +167,19 @@ QPainterPath RulerItem2::shape() const
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RulerItem2::setPlotInfo(plot_info* info)
|
void RulerItem2::setPlotInfo(plot_info info)
|
||||||
{
|
{
|
||||||
pInfo = info;
|
pInfo = info;
|
||||||
dest->pInfo = info;
|
recalculate();
|
||||||
source->pInfo = info;
|
}
|
||||||
|
|
||||||
|
void RulerItem2::setAxis(DiveCartesianAxis* time, DiveCartesianAxis* depth)
|
||||||
|
{
|
||||||
|
timeAxis = time;
|
||||||
|
depthAxis = depth;
|
||||||
|
dest->depthAxis = depth;
|
||||||
|
dest->timeAxis = time;
|
||||||
|
source->depthAxis = depth;
|
||||||
|
source->timeAxis = time;
|
||||||
recalculate();
|
recalculate();
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <QGraphicsEllipseItem>
|
#include <QGraphicsEllipseItem>
|
||||||
#include <QGraphicsObject>
|
#include <QGraphicsObject>
|
||||||
#include "divecartesianaxis.h"
|
#include "divecartesianaxis.h"
|
||||||
|
#include "display.h"
|
||||||
|
|
||||||
struct plot_data;
|
struct plot_data;
|
||||||
class RulerItem2;
|
class RulerItem2;
|
||||||
|
@ -14,7 +15,7 @@ class RulerNodeItem2 : public QObject, public QGraphicsEllipseItem
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
friend class RulerItem2;
|
friend class RulerItem2;
|
||||||
public:
|
public:
|
||||||
explicit RulerNodeItem2();
|
explicit RulerNodeItem2(struct plot_info& info);
|
||||||
void setRuler(RulerItem2 *r);
|
void setRuler(RulerItem2 *r);
|
||||||
void recalculate();
|
void recalculate();
|
||||||
|
|
||||||
|
@ -22,7 +23,7 @@ protected:
|
||||||
QVariant itemChange(GraphicsItemChange change, const QVariant & value );
|
QVariant itemChange(GraphicsItemChange change, const QVariant & value );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct plot_info *pInfo;
|
struct plot_info &pInfo;
|
||||||
struct plot_data *entry;
|
struct plot_data *entry;
|
||||||
RulerItem2* ruler;
|
RulerItem2* ruler;
|
||||||
DiveCartesianAxis *timeAxis;
|
DiveCartesianAxis *timeAxis;
|
||||||
|
@ -36,15 +37,16 @@ public:
|
||||||
explicit RulerItem2();
|
explicit RulerItem2();
|
||||||
void recalculate();
|
void recalculate();
|
||||||
|
|
||||||
void setPlotInfo(struct plot_info *pInfo);
|
void setPlotInfo(struct plot_info pInfo);
|
||||||
RulerNodeItem2* sourceNode() const;
|
RulerNodeItem2* sourceNode() const;
|
||||||
RulerNodeItem2* destNode() const;
|
RulerNodeItem2* destNode() const;
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget * widget = 0);
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget * widget = 0);
|
||||||
QRectF boundingRect() const;
|
QRectF boundingRect() const;
|
||||||
QPainterPath shape() const;
|
QPainterPath shape() const;
|
||||||
|
void setAxis(DiveCartesianAxis *time, DiveCartesianAxis *depth);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct plot_info *pInfo;
|
struct plot_info pInfo;
|
||||||
QPointF startPoint, endPoint;
|
QPointF startPoint, endPoint;
|
||||||
RulerNodeItem2 *source, *dest;
|
RulerNodeItem2 *source, *dest;
|
||||||
QString text;
|
QString text;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue