Refactoring deleting visualization object.

Instead of searcing inside current graphics scene use QPointer class.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2016-07-07 14:56:55 +03:00
parent 628fdd4217
commit bd7f328a8a
31 changed files with 7 additions and 47 deletions

View File

@ -142,7 +142,6 @@ DialogAlongLine::~DialogAlongLine()
VContainer *locData = const_cast<VContainer *> (data);
locData->RemoveVariable(currentLength);
DeleteVisualization<VisToolAlongLine>();
delete ui;
}

View File

@ -113,7 +113,6 @@ void DialogArc::DeployF2TextEdit()
//---------------------------------------------------------------------------------------------------------------------
DialogArc::~DialogArc()
{
DeleteVisualization<VisToolArc>();
delete ui;
}

View File

@ -90,7 +90,6 @@ DialogArcWithLength::DialogArcWithLength(const VContainer *data, const quint32 &
//---------------------------------------------------------------------------------------------------------------------
DialogArcWithLength::~DialogArcWithLength()
{
DeleteVisualization<VisToolArcWithLength>();
delete ui;
}

View File

@ -142,7 +142,6 @@ void DialogBisector::DeployFormulaTextEdit()
//---------------------------------------------------------------------------------------------------------------------
DialogBisector::~DialogBisector()
{
DeleteVisualization<VisToolBisector>();
delete ui;
}

View File

@ -63,7 +63,6 @@ DialogCubicBezier::DialogCubicBezier(const VContainer *data, const quint32 &tool
//---------------------------------------------------------------------------------------------------------------------
DialogCubicBezier::~DialogCubicBezier()
{
DeleteVisualization<VisToolCubicBezier>();
delete ui;
}

View File

@ -61,7 +61,6 @@ DialogCubicBezierPath::DialogCubicBezierPath(const VContainer *data, const quint
//---------------------------------------------------------------------------------------------------------------------
DialogCubicBezierPath::~DialogCubicBezierPath()
{
DeleteVisualization<VisToolCubicBezierPath>();
delete ui;
}

View File

@ -77,7 +77,6 @@ DialogCurveIntersectAxis::DialogCurveIntersectAxis(const VContainer *data, const
//---------------------------------------------------------------------------------------------------------------------
DialogCurveIntersectAxis::~DialogCurveIntersectAxis()
{
DeleteVisualization<VisToolCurveIntersectAxis>();
delete ui;
}

View File

@ -106,7 +106,6 @@ void DialogCutArc::DeployFormulaTextEdit()
//---------------------------------------------------------------------------------------------------------------------
DialogCutArc::~DialogCutArc()
{
DeleteVisualization<VisToolCutArc>();
delete ui;
}

View File

@ -73,7 +73,6 @@ DialogCutSpline::DialogCutSpline(const VContainer *data, const quint32 &toolId,
//---------------------------------------------------------------------------------------------------------------------
DialogCutSpline::~DialogCutSpline()
{
DeleteVisualization<VisToolCutSpline>();
delete ui;
}

View File

@ -73,7 +73,6 @@ DialogCutSplinePath::DialogCutSplinePath(const VContainer *data, const quint32 &
//---------------------------------------------------------------------------------------------------------------------
DialogCutSplinePath::~DialogCutSplinePath()
{
DeleteVisualization<VisToolCutSplinePath>();
delete ui;
}

View File

@ -167,7 +167,7 @@ void DialogEndLine::ChosenObject(quint32 id, const SceneObject &type)
if (SetObject(id, ui->comboBoxBasePoint, ""))
{
vis->VisualMode(id);
connect(vis, &Visualization::ToolTip, this, &DialogTool::ShowVisToolTip);
connect(vis.data(), &Visualization::ToolTip, this, &DialogTool::ShowVisToolTip);
prepare = true;
}
}
@ -343,7 +343,6 @@ void DialogEndLine::closeEvent(QCloseEvent *event)
//---------------------------------------------------------------------------------------------------------------------
DialogEndLine::~DialogEndLine()
{
DeleteVisualization<VisToolEndLine>();
delete ui;
}

View File

@ -75,7 +75,6 @@ DialogHeight::DialogHeight(const VContainer *data, const quint32 &toolId, QWidge
//---------------------------------------------------------------------------------------------------------------------
DialogHeight::~DialogHeight()
{
DeleteVisualization<VisToolHeight>();
delete ui;
}

View File

@ -68,7 +68,6 @@ DialogLine::DialogLine(const VContainer *data, const quint32 &toolId, QWidget *p
//---------------------------------------------------------------------------------------------------------------------
DialogLine::~DialogLine()
{
DeleteVisualization<VisToolLine>();
delete ui;
}

View File

@ -75,7 +75,6 @@ DialogLineIntersect::DialogLineIntersect(const VContainer *data, const quint32 &
//---------------------------------------------------------------------------------------------------------------------
DialogLineIntersect::~DialogLineIntersect()
{
DeleteVisualization<VisToolLineIntersect>();
delete ui;
}

View File

@ -86,7 +86,6 @@ DialogLineIntersectAxis::DialogLineIntersectAxis(const VContainer *data, const q
//---------------------------------------------------------------------------------------------------------------------
DialogLineIntersectAxis::~DialogLineIntersectAxis()
{
DeleteVisualization<VisToolLineIntersectAxis>();
delete ui;
}

View File

@ -132,7 +132,6 @@ void DialogNormal::DeployFormulaTextEdit()
//---------------------------------------------------------------------------------------------------------------------
DialogNormal::~DialogNormal()
{
DeleteVisualization<VisToolNormal>();
delete ui;
}

View File

@ -63,7 +63,6 @@ DialogPointFromArcAndTangent::DialogPointFromArcAndTangent(const VContainer *dat
//---------------------------------------------------------------------------------------------------------------------
DialogPointFromArcAndTangent::~DialogPointFromArcAndTangent()
{
DeleteVisualization<VisToolPointFromArcAndTangent>();
delete ui;
}

View File

@ -88,7 +88,6 @@ DialogPointFromCircleAndTangent::DialogPointFromCircleAndTangent(const VContaine
//---------------------------------------------------------------------------------------------------------------------
DialogPointFromCircleAndTangent::~DialogPointFromCircleAndTangent()
{
DeleteVisualization<VisToolPointFromCircleAndTangent>();
delete ui;
}

View File

@ -81,7 +81,6 @@ DialogPointOfContact::DialogPointOfContact(const VContainer *data, const quint32
//---------------------------------------------------------------------------------------------------------------------
DialogPointOfContact::~DialogPointOfContact()
{
DeleteVisualization<VisToolPointOfContact>();
delete ui;
}

View File

@ -71,7 +71,6 @@ DialogPointOfIntersection::DialogPointOfIntersection(const VContainer *data, con
//---------------------------------------------------------------------------------------------------------------------
DialogPointOfIntersection::~DialogPointOfIntersection()
{
DeleteVisualization<VisToolPointOfIntersection>();
delete ui;
}

View File

@ -67,7 +67,6 @@ DialogPointOfIntersectionArcs::DialogPointOfIntersectionArcs(const VContainer *d
//---------------------------------------------------------------------------------------------------------------------
DialogPointOfIntersectionArcs::~DialogPointOfIntersectionArcs()
{
DeleteVisualization<VisToolPointOfIntersectionArcs>();
delete ui;
}

View File

@ -104,7 +104,6 @@ DialogPointOfIntersectionCircles::DialogPointOfIntersectionCircles(const VContai
//---------------------------------------------------------------------------------------------------------------------
DialogPointOfIntersectionCircles::~DialogPointOfIntersectionCircles()
{
DeleteVisualization<VisToolPointOfIntersectionCircles>();
delete ui;
}

View File

@ -65,7 +65,6 @@ DialogPointOfIntersectionCurves::DialogPointOfIntersectionCurves(const VContaine
//---------------------------------------------------------------------------------------------------------------------
DialogPointOfIntersectionCurves::~DialogPointOfIntersectionCurves()
{
DeleteVisualization<VisToolPointOfIntersectionCurves>();
delete ui;
}

View File

@ -81,7 +81,6 @@ DialogRotation::DialogRotation(const VContainer *data, const quint32 &toolId, QW
//---------------------------------------------------------------------------------------------------------------------
DialogRotation::~DialogRotation()
{
DeleteVisualization<VisToolRotation>();
delete ui;
}

View File

@ -143,7 +143,6 @@ void DialogShoulderPoint::DeployFormulaTextEdit()
//---------------------------------------------------------------------------------------------------------------------
DialogShoulderPoint::~DialogShoulderPoint()
{
DeleteVisualization<VisToolShoulderPoint>();
delete ui;
}

View File

@ -122,7 +122,6 @@ DialogSpline::DialogSpline(const VContainer *data, const quint32 &toolId, QWidge
//---------------------------------------------------------------------------------------------------------------------
DialogSpline::~DialogSpline()
{
DeleteVisualization<VisToolSpline>();
delete ui;
}

View File

@ -108,7 +108,6 @@ DialogSplinePath::DialogSplinePath(const VContainer *data, const quint32 &toolId
//---------------------------------------------------------------------------------------------------------------------
DialogSplinePath::~DialogSplinePath()
{
DeleteVisualization<VisToolSplinePath>();
delete ui;
}

View File

@ -78,6 +78,11 @@ DialogTool::DialogTool(const VContainer *data, const quint32 &toolId, QWidget *p
DialogTool::~DialogTool()
{
emit ToolTip("");
if (not vis.isNull())
{
delete vis;
}
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -181,7 +181,7 @@ protected:
/** @brief number number of handled objects */
qint32 number;
Visualization *vis;
QPointer<Visualization> vis;
virtual void closeEvent ( QCloseEvent * event ) Q_DECL_OVERRIDE;
virtual void showEvent( QShowEvent *event ) Q_DECL_OVERRIDE;
@ -241,9 +241,6 @@ protected:
template <typename T>
void AddVisualization();
template <typename T>
void DeleteVisualization();
void ChangeColor(QWidget *widget, const QColor &color);
virtual void ShowVisualization() {}
/**
@ -360,19 +357,6 @@ inline void DialogTool::AddVisualization()
}
}
//---------------------------------------------------------------------------------------------------------------------
template <typename T>
inline void DialogTool::DeleteVisualization()
{
T *toolVis = qobject_cast<T *>(vis);
SCASSERT(toolVis != nullptr);
if (qApp->getCurrentScene()->items().contains(toolVis))
{ // In some cases scene delete object yourself. If not make check program will crash.
delete vis;
}
}
//---------------------------------------------------------------------------------------------------------------------
template <typename T>
inline T DialogTool::getCurrentCrossPoint(QComboBox *box) const

View File

@ -75,7 +75,6 @@ DialogTriangle::DialogTriangle(const VContainer *data, const quint32 &toolId, QW
//---------------------------------------------------------------------------------------------------------------------
DialogTriangle::~DialogTriangle()
{
DeleteVisualization<VisToolTriangle>();
delete ui;
}

View File

@ -80,7 +80,6 @@ DialogTrueDarts::DialogTrueDarts(const VContainer *data, const quint32 &toolId,
//---------------------------------------------------------------------------------------------------------------------
DialogTrueDarts::~DialogTrueDarts()
{
DeleteVisualization<VisToolTrueDarts>();
delete ui;
}