Fixed crash after detele tool.
--HG-- branch : develop
This commit is contained in:
parent
d066c6ed84
commit
b81614d1a1
|
@ -2091,12 +2091,12 @@ QString MainWindow::PatternPieceName(const QString &text)
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
{
|
{
|
||||||
CancelTool();
|
CancelTool();
|
||||||
delete ui;
|
|
||||||
|
|
||||||
delete pattern;
|
delete pattern;
|
||||||
delete doc;
|
delete doc;
|
||||||
delete sceneDetails;
|
delete sceneDetails;
|
||||||
delete sceneDraw;
|
delete sceneDraw;
|
||||||
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -180,7 +180,7 @@ void VAbstractSpline::keyReleaseEvent(QKeyEvent *event)
|
||||||
{
|
{
|
||||||
case Qt::Key_Delete:
|
case Qt::Key_Delete:
|
||||||
DeleteTool();
|
DeleteTool();
|
||||||
break;
|
return; //Leave this method immediately after call!!!
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,8 +45,8 @@ qreal VDrawTool::factor = 1;
|
||||||
* @param data container with variables.
|
* @param data container with variables.
|
||||||
* @param id object id in container.
|
* @param id object id in container.
|
||||||
*/
|
*/
|
||||||
VDrawTool::VDrawTool(VPattern *doc, VContainer *data, quint32 id)
|
VDrawTool::VDrawTool(VPattern *doc, VContainer *data, quint32 id, QObject *parent)
|
||||||
:VAbstractTool(doc, data, id), ignoreFullUpdate(false),
|
:VAbstractTool(doc, data, id, parent), ignoreFullUpdate(false),
|
||||||
nameActivDraw(doc->GetNameActivPP()), dialog(nullptr)
|
nameActivDraw(doc->GetNameActivPP()), dialog(nullptr)
|
||||||
{
|
{
|
||||||
connect(this->doc, &VPattern::ChangedActivPP, this, &VDrawTool::ChangedActivDraw);
|
connect(this->doc, &VPattern::ChangedActivPP, this, &VDrawTool::ChangedActivDraw);
|
||||||
|
|
|
@ -45,7 +45,7 @@ class VDrawTool : public VAbstractTool
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
|
||||||
VDrawTool(VPattern *doc, VContainer *data, quint32 id);
|
VDrawTool(VPattern *doc, VContainer *data, quint32 id, QObject *parent = nullptr);
|
||||||
virtual ~VDrawTool();
|
virtual ~VDrawTool();
|
||||||
|
|
||||||
/** @brief factor scene scale factor. */
|
/** @brief factor scene scale factor. */
|
||||||
|
@ -134,6 +134,7 @@ protected:
|
||||||
if (selectedAction == actionRemove)
|
if (selectedAction == actionRemove)
|
||||||
{
|
{
|
||||||
DeleteTool();
|
DeleteTool();
|
||||||
|
return; //Leave this method immediately after call!!!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
template <typename Item>
|
template <typename Item>
|
||||||
|
|
|
@ -64,6 +64,10 @@ VToolEndLine::VToolEndLine(VPattern *doc, VContainer *data, const quint32 &id,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
VToolEndLine::~VToolEndLine()
|
||||||
|
{}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief setDialog set dialog when user want change tool option.
|
* @brief setDialog set dialog when user want change tool option.
|
||||||
|
|
|
@ -42,6 +42,7 @@ public:
|
||||||
VToolEndLine(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine,
|
VToolEndLine(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine,
|
||||||
const QString &formulaLength, const QString &formulaAngle, const quint32 &basePointId,
|
const QString &formulaLength, const QString &formulaAngle, const quint32 &basePointId,
|
||||||
const Source &typeCreation, QGraphicsItem * parent = nullptr);
|
const Source &typeCreation, QGraphicsItem * parent = nullptr);
|
||||||
|
virtual ~VToolEndLine();
|
||||||
virtual void setDialog();
|
virtual void setDialog();
|
||||||
static VToolEndLine *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
|
static VToolEndLine *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
|
||||||
static VToolEndLine *Create(const quint32 _id, const QString &pointName, const QString &typeLine,
|
static VToolEndLine *Create(const quint32 _id, const QString &pointName, const QString &typeLine,
|
||||||
|
|
|
@ -350,7 +350,7 @@ void VToolLine::keyReleaseEvent(QKeyEvent *event)
|
||||||
{
|
{
|
||||||
case Qt::Key_Delete:
|
case Qt::Key_Delete:
|
||||||
DeleteTool();
|
DeleteTool();
|
||||||
break;
|
return; //Leave this method immediately after call!!!
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,6 +56,12 @@ VToolLinePoint::VToolLinePoint(VPattern *doc, VContainer *data, const quint32 &i
|
||||||
mainLine->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
|
mainLine->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
VToolLinePoint::~VToolLinePoint()
|
||||||
|
{
|
||||||
|
delete mainLine;
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief ChangedActivDraw disable or enable context menu after change active pattern peace.
|
* @brief ChangedActivDraw disable or enable context menu after change active pattern peace.
|
||||||
|
|
|
@ -41,6 +41,7 @@ class VToolLinePoint : public VToolPoint
|
||||||
public:
|
public:
|
||||||
VToolLinePoint(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, const QString &formula,
|
VToolLinePoint(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, const QString &formula,
|
||||||
const quint32 &basePointId, const qreal &angle, QGraphicsItem * parent = nullptr);
|
const quint32 &basePointId, const qreal &angle, QGraphicsItem * parent = nullptr);
|
||||||
|
virtual ~VToolLinePoint();
|
||||||
virtual int type() const {return Type;}
|
virtual int type() const {return Type;}
|
||||||
enum { Type = UserType + static_cast<int>(Tool::LinePoint)};
|
enum { Type = UserType + static_cast<int>(Tool::LinePoint)};
|
||||||
VFormula getFormulaLength() const;
|
VFormula getFormulaLength() const;
|
||||||
|
|
|
@ -59,6 +59,10 @@ VToolPoint::VToolPoint(VPattern *doc, VContainer *data, quint32 id, QGraphicsIte
|
||||||
RefreshPointGeometry(*VAbstractTool::data.GeometricObject<VPointF>(id));
|
RefreshPointGeometry(*VAbstractTool::data.GeometricObject<VPointF>(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
VToolPoint::~VToolPoint()
|
||||||
|
{}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VToolPoint::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
void VToolPoint::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||||
{
|
{
|
||||||
|
@ -315,7 +319,7 @@ void VToolPoint::keyReleaseEvent(QKeyEvent *event)
|
||||||
{
|
{
|
||||||
case Qt::Key_Delete:
|
case Qt::Key_Delete:
|
||||||
DeleteTool();
|
DeleteTool();
|
||||||
break;
|
return; //Leave this method immediately after call!!!
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ class VToolPoint: public VDrawTool, public QGraphicsEllipseItem
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
VToolPoint(VPattern *doc, VContainer *data, quint32 id, QGraphicsItem * parent = nullptr);
|
VToolPoint(VPattern *doc, VContainer *data, quint32 id, QGraphicsItem * parent = nullptr);
|
||||||
virtual ~VToolPoint(){}
|
virtual ~VToolPoint();
|
||||||
virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0);
|
virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0);
|
||||||
QString name() const;
|
QString name() const;
|
||||||
void setName(const QString &name);
|
void setName(const QString &name);
|
||||||
|
|
|
@ -40,6 +40,10 @@ VDataTool::VDataTool(VContainer *data, QObject *parent)
|
||||||
SCASSERT(data != nullptr);
|
SCASSERT(data != nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
VDataTool::~VDataTool()
|
||||||
|
{}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief operator = assignment operator.
|
* @brief operator = assignment operator.
|
||||||
|
|
|
@ -42,7 +42,7 @@ class VDataTool : public QObject
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
VDataTool(VContainer *data, QObject *parent = nullptr);
|
VDataTool(VContainer *data, QObject *parent = nullptr);
|
||||||
virtual ~VDataTool(){}
|
virtual ~VDataTool();
|
||||||
VDataTool &operator= (const VDataTool &tool);
|
VDataTool &operator= (const VDataTool &tool);
|
||||||
VContainer getData() const;
|
VContainer getData() const;
|
||||||
void setData(const VContainer *value);
|
void setData(const VContainer *value);
|
||||||
|
|
|
@ -363,7 +363,7 @@ void VToolDetail::keyReleaseEvent(QKeyEvent *event)
|
||||||
{
|
{
|
||||||
case Qt::Key_Delete:
|
case Qt::Key_Delete:
|
||||||
DeleteTool();
|
DeleteTool();
|
||||||
break;
|
return; //Leave this method immediately after call!!!
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -423,6 +423,7 @@ void VToolDetail::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||||
if (selectedAction == actionRemove)
|
if (selectedAction == actionRemove)
|
||||||
{
|
{
|
||||||
DeleteTool();
|
DeleteTool();
|
||||||
|
return; //Leave this method immediately after call!!!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,10 +42,14 @@
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
GraphicsViewZoom::GraphicsViewZoom(QGraphicsView* view)
|
GraphicsViewZoom::GraphicsViewZoom(QGraphicsView* view)
|
||||||
: QObject(view), _view(view), _modifiers(Qt::ControlModifier), _zoom_factor_base(1.0015),
|
: QObject(view), _view(view), _modifiers(Qt::ControlModifier), _zoom_factor_base(1.0015),
|
||||||
target_scene_pos(QPointF()), target_viewport_pos(QPointF()), _numScheduledScalings(0)
|
target_scene_pos(QPointF()), target_viewport_pos(QPointF()), _numScheduledScalings(0), anim(nullptr)
|
||||||
{
|
{
|
||||||
_view->viewport()->installEventFilter(this);
|
_view->viewport()->installEventFilter(this);
|
||||||
_view->setMouseTracking(true);
|
_view->setMouseTracking(true);
|
||||||
|
anim = new QTimeLine(300, this);
|
||||||
|
anim->setUpdateInterval(20);
|
||||||
|
connect(anim, &QTimeLine::valueChanged, this, &GraphicsViewZoom::scrollingTime, Qt::UniqueConnection);
|
||||||
|
connect(anim, &QTimeLine::finished, this, &GraphicsViewZoom::animFinished, Qt::UniqueConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -101,7 +105,7 @@ void GraphicsViewZoom::animFinished()
|
||||||
{
|
{
|
||||||
_numScheduledScalings++;
|
_numScheduledScalings++;
|
||||||
}
|
}
|
||||||
sender()->~QObject();
|
anim->stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -140,10 +144,6 @@ bool GraphicsViewZoom::eventFilter(QObject *object, QEvent *event)
|
||||||
_numScheduledScalings = numSteps; // previously scheduled scalings
|
_numScheduledScalings = numSteps; // previously scheduled scalings
|
||||||
}
|
}
|
||||||
|
|
||||||
QTimeLine *anim = new QTimeLine(300, this);
|
|
||||||
anim->setUpdateInterval(20);
|
|
||||||
connect(anim, &QTimeLine::valueChanged, this, &GraphicsViewZoom::scrollingTime);
|
|
||||||
connect(anim, &QTimeLine::finished, this, &GraphicsViewZoom::animFinished);
|
|
||||||
anim->start();
|
anim->start();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,6 +62,9 @@
|
||||||
* (see QWheelEvent::angleDelta).
|
* (see QWheelEvent::angleDelta).
|
||||||
* The default zoom factor base is 1.0015.
|
* The default zoom factor base is 1.0015.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
class QTimeLine;
|
||||||
|
|
||||||
class GraphicsViewZoom : public QObject
|
class GraphicsViewZoom : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -81,6 +84,7 @@ private:
|
||||||
double _zoom_factor_base;
|
double _zoom_factor_base;
|
||||||
QPointF target_scene_pos;
|
QPointF target_scene_pos;
|
||||||
QPointF target_viewport_pos;
|
QPointF target_viewport_pos;
|
||||||
|
QTimeLine *anim;
|
||||||
|
|
||||||
bool eventFilter(QObject* object, QEvent* event);
|
bool eventFilter(QObject* object, QEvent* event);
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -2448,11 +2448,11 @@ void VPattern::PrepareForParse(const Document &parse)
|
||||||
if (parse == Document::FullParse)
|
if (parse == Document::FullParse)
|
||||||
{
|
{
|
||||||
TestUniqueId();
|
TestUniqueId();
|
||||||
|
sceneDraw->clear();
|
||||||
|
sceneDetail->clear();
|
||||||
data->Clear();
|
data->Clear();
|
||||||
UpdateMeasurements();
|
UpdateMeasurements();
|
||||||
nameActivPP.clear();
|
nameActivPP.clear();
|
||||||
sceneDraw->clear();
|
|
||||||
sceneDetail->clear();
|
|
||||||
patternPieces.clear();
|
patternPieces.clear();
|
||||||
tools.clear();
|
tools.clear();
|
||||||
cursor = 0;
|
cursor = 0;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user