Fixed crash after detele tool.

--HG--
branch : develop
This commit is contained in:
dismine 2014-10-04 22:12:46 +03:00
parent d066c6ed84
commit b81614d1a1
17 changed files with 44 additions and 18 deletions

View File

@ -2091,12 +2091,12 @@ QString MainWindow::PatternPieceName(const QString &text)
MainWindow::~MainWindow()
{
CancelTool();
delete ui;
delete pattern;
delete doc;
delete sceneDetails;
delete sceneDraw;
delete ui;
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -180,7 +180,7 @@ void VAbstractSpline::keyReleaseEvent(QKeyEvent *event)
{
case Qt::Key_Delete:
DeleteTool();
break;
return; //Leave this method immediately after call!!!
default:
break;
}

View File

@ -45,8 +45,8 @@ qreal VDrawTool::factor = 1;
* @param data container with variables.
* @param id object id in container.
*/
VDrawTool::VDrawTool(VPattern *doc, VContainer *data, quint32 id)
:VAbstractTool(doc, data, id), ignoreFullUpdate(false),
VDrawTool::VDrawTool(VPattern *doc, VContainer *data, quint32 id, QObject *parent)
:VAbstractTool(doc, data, id, parent), ignoreFullUpdate(false),
nameActivDraw(doc->GetNameActivPP()), dialog(nullptr)
{
connect(this->doc, &VPattern::ChangedActivPP, this, &VDrawTool::ChangedActivDraw);

View File

@ -45,7 +45,7 @@ class VDrawTool : public VAbstractTool
Q_OBJECT
public:
VDrawTool(VPattern *doc, VContainer *data, quint32 id);
VDrawTool(VPattern *doc, VContainer *data, quint32 id, QObject *parent = nullptr);
virtual ~VDrawTool();
/** @brief factor scene scale factor. */
@ -134,6 +134,7 @@ protected:
if (selectedAction == actionRemove)
{
DeleteTool();
return; //Leave this method immediately after call!!!
}
}
template <typename Item>

View File

@ -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.

View File

@ -42,6 +42,7 @@ public:
VToolEndLine(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine,
const QString &formulaLength, const QString &formulaAngle, const quint32 &basePointId,
const Source &typeCreation, QGraphicsItem * parent = nullptr);
virtual ~VToolEndLine();
virtual void setDialog();
static VToolEndLine *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
static VToolEndLine *Create(const quint32 _id, const QString &pointName, const QString &typeLine,

View File

@ -350,7 +350,7 @@ void VToolLine::keyReleaseEvent(QKeyEvent *event)
{
case Qt::Key_Delete:
DeleteTool();
break;
return; //Leave this method immediately after call!!!
default:
break;
}

View File

@ -56,6 +56,12 @@ VToolLinePoint::VToolLinePoint(VPattern *doc, VContainer *data, const quint32 &i
mainLine->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
}
//---------------------------------------------------------------------------------------------------------------------
VToolLinePoint::~VToolLinePoint()
{
delete mainLine;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ChangedActivDraw disable or enable context menu after change active pattern peace.

View File

@ -41,6 +41,7 @@ class VToolLinePoint : public VToolPoint
public:
VToolLinePoint(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, const QString &formula,
const quint32 &basePointId, const qreal &angle, QGraphicsItem * parent = nullptr);
virtual ~VToolLinePoint();
virtual int type() const {return Type;}
enum { Type = UserType + static_cast<int>(Tool::LinePoint)};
VFormula getFormulaLength() const;

View File

@ -59,6 +59,10 @@ VToolPoint::VToolPoint(VPattern *doc, VContainer *data, quint32 id, QGraphicsIte
RefreshPointGeometry(*VAbstractTool::data.GeometricObject<VPointF>(id));
}
//---------------------------------------------------------------------------------------------------------------------
VToolPoint::~VToolPoint()
{}
//---------------------------------------------------------------------------------------------------------------------
void VToolPoint::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
@ -315,7 +319,7 @@ void VToolPoint::keyReleaseEvent(QKeyEvent *event)
{
case Qt::Key_Delete:
DeleteTool();
break;
return; //Leave this method immediately after call!!!
default:
break;
}

View File

@ -43,7 +43,7 @@ class VToolPoint: public VDrawTool, public QGraphicsEllipseItem
Q_OBJECT
public:
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);
QString name() const;
void setName(const QString &name);

View File

@ -40,6 +40,10 @@ VDataTool::VDataTool(VContainer *data, QObject *parent)
SCASSERT(data != nullptr);
}
//---------------------------------------------------------------------------------------------------------------------
VDataTool::~VDataTool()
{}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief operator = assignment operator.

View File

@ -42,7 +42,7 @@ class VDataTool : public QObject
Q_OBJECT
public:
VDataTool(VContainer *data, QObject *parent = nullptr);
virtual ~VDataTool(){}
virtual ~VDataTool();
VDataTool &operator= (const VDataTool &tool);
VContainer getData() const;
void setData(const VContainer *value);

View File

@ -363,7 +363,7 @@ void VToolDetail::keyReleaseEvent(QKeyEvent *event)
{
case Qt::Key_Delete:
DeleteTool();
break;
return; //Leave this method immediately after call!!!
default:
break;
}
@ -423,6 +423,7 @@ void VToolDetail::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
if (selectedAction == actionRemove)
{
DeleteTool();
return; //Leave this method immediately after call!!!
}
}

View File

@ -42,10 +42,14 @@
//---------------------------------------------------------------------------------------------------------------------
GraphicsViewZoom::GraphicsViewZoom(QGraphicsView* view)
: 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->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++;
}
sender()->~QObject();
anim->stop();
}
//---------------------------------------------------------------------------------------------------------------------
@ -140,10 +144,6 @@ bool GraphicsViewZoom::eventFilter(QObject *object, QEvent *event)
_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();
return true;
}

View File

@ -62,6 +62,9 @@
* (see QWheelEvent::angleDelta).
* The default zoom factor base is 1.0015.
*/
class QTimeLine;
class GraphicsViewZoom : public QObject
{
Q_OBJECT
@ -81,6 +84,7 @@ private:
double _zoom_factor_base;
QPointF target_scene_pos;
QPointF target_viewport_pos;
QTimeLine *anim;
bool eventFilter(QObject* object, QEvent* event);
private:

View File

@ -2448,11 +2448,11 @@ void VPattern::PrepareForParse(const Document &parse)
if (parse == Document::FullParse)
{
TestUniqueId();
sceneDraw->clear();
sceneDetail->clear();
data->Clear();
UpdateMeasurements();
nameActivPP.clear();
sceneDraw->clear();
sceneDetail->clear();
patternPieces.clear();
tools.clear();
cursor = 0;