Fixed crash after undo creating a pattern piece.
--HG-- branch : develop
This commit is contained in:
parent
9aa8713203
commit
345b0e5c7f
|
@ -277,6 +277,13 @@ bool MApplication::notify(QObject *receiver, QEvent *event)
|
|||
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
||||
exit(V_EX_DATAERR);
|
||||
}
|
||||
catch (const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
qCCritical(mApp, "%s\n\n%s\n\n%s",
|
||||
qUtf8Printable("Unhadled deleting tool. Continue use object after deleting!"),
|
||||
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
||||
exit(V_EX_DATAERR);
|
||||
}
|
||||
catch (const VException &e)
|
||||
{
|
||||
qCCritical(mApp, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Something's wrong!!")),
|
||||
|
|
|
@ -335,6 +335,13 @@ bool VApplication::notify(QObject *receiver, QEvent *event)
|
|||
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
||||
exit(V_EX_DATAERR);
|
||||
}
|
||||
catch (const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
qCCritical(vApp, "%s\n\n%s\n\n%s",
|
||||
qUtf8Printable("Unhadled deleting tool. Continue use object after deleting"),
|
||||
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
||||
exit(V_EX_DATAERR);
|
||||
}
|
||||
catch (const VException &e)
|
||||
{
|
||||
qCCritical(vApp, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Something's wrong!!")),
|
||||
|
|
|
@ -42,7 +42,8 @@
|
|||
* @brief VException constructor exception
|
||||
* @param what string with error
|
||||
*/
|
||||
VException::VException(const QString &what):QException(), what(what), moreInfo(QString())
|
||||
VException::VException(const QString &what) V_NOEXCEPT_EXPR (true)
|
||||
:QException(), what(what), moreInfo(QString())
|
||||
{
|
||||
Q_ASSERT_X(not what.isEmpty(), Q_FUNC_INFO, "Error message is empty");
|
||||
}
|
||||
|
@ -135,3 +136,42 @@ Q_NORETURN void VException::raise() const
|
|||
{
|
||||
throw *this;
|
||||
}
|
||||
|
||||
//-----------------------------------------VExceptionToolWasDeleted----------------------------------------------------
|
||||
VExceptionToolWasDeleted::VExceptionToolWasDeleted(const QString &what) V_NOEXCEPT_EXPR (true)
|
||||
:VException(what)
|
||||
{
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VExceptionToolWasDeleted::VExceptionToolWasDeleted(const VExceptionToolWasDeleted &e)
|
||||
:VException(e)
|
||||
{
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VExceptionToolWasDeleted &VExceptionToolWasDeleted::operator=(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
if ( &e == this )
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
VException::operator=(e);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief raise method raise for exception
|
||||
*/
|
||||
// cppcheck-suppress unusedFunction
|
||||
Q_NORETURN void VExceptionToolWasDeleted::VExceptionToolWasDeleted::raise() const
|
||||
{
|
||||
throw *this;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VExceptionToolWasDeleted *VExceptionToolWasDeleted::clone() const
|
||||
{
|
||||
return new VExceptionToolWasDeleted(*this);
|
||||
}
|
||||
|
|
|
@ -34,8 +34,6 @@
|
|||
#include <QCoreApplication>
|
||||
#include "../ifcdef.h"
|
||||
|
||||
class QWidget;
|
||||
|
||||
/**
|
||||
* @brief The VException class parent for all exception. Could be use for abstract exception
|
||||
*/
|
||||
|
@ -43,7 +41,7 @@ class VException : public QException
|
|||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(VException)
|
||||
public:
|
||||
explicit VException(const QString &what);
|
||||
explicit VException(const QString &what) V_NOEXCEPT_EXPR (true);
|
||||
VException(const VException &e);
|
||||
VException &operator=(const VException &e);
|
||||
virtual ~VException() V_NOEXCEPT_EXPR (true) Q_DECL_OVERRIDE {}
|
||||
|
@ -86,4 +84,19 @@ inline QString VException::MoreInformation() const
|
|||
return moreInfo;
|
||||
}
|
||||
|
||||
// Want have special exception for catching unhadled deleting a tool
|
||||
class VExceptionToolWasDeleted : public VException
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(VExceptionToolDeleted)
|
||||
public:
|
||||
explicit VExceptionToolWasDeleted(const QString &what) V_NOEXCEPT_EXPR (true);
|
||||
VExceptionToolWasDeleted(const VExceptionToolWasDeleted &e);
|
||||
VExceptionToolWasDeleted &operator=(const VExceptionToolWasDeleted &e);
|
||||
virtual ~VExceptionToolWasDeleted() V_NOEXCEPT_EXPR (true) Q_DECL_OVERRIDE {}
|
||||
|
||||
Q_NORETURN virtual void raise() const Q_DECL_OVERRIDE;
|
||||
// cppcheck-suppress unusedFunction
|
||||
virtual VExceptionToolWasDeleted *clone() const Q_DECL_OVERRIDE;
|
||||
};
|
||||
|
||||
#endif // VEXCEPTION_H
|
||||
|
|
|
@ -186,8 +186,16 @@ void VAbstractSpline::keyReleaseEvent(QKeyEvent *event)
|
|||
switch (event->key())
|
||||
{
|
||||
case Qt::Key_Delete:
|
||||
try
|
||||
{
|
||||
DeleteTool();
|
||||
return; //Leave this method immediately after call!!!
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -292,9 +292,17 @@ void VToolArc::ShowVisualization(bool show)
|
|||
* @param event context menu event.
|
||||
*/
|
||||
void VToolArc::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogArc>(this, event);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
|
|
|
@ -254,9 +254,17 @@ void VToolArcWithLength::ShowVisualization(bool show)
|
|||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolArcWithLength::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogArcWithLength>(this, event);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolArcWithLength::RemoveReferens()
|
||||
|
|
|
@ -269,9 +269,17 @@ void VToolSpline::EnableToolMove(bool move)
|
|||
* @param event context menu event.
|
||||
*/
|
||||
void VToolSpline::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogSpline>(this, event);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
|
|
|
@ -316,9 +316,17 @@ void VToolSplinePath::ShowVisualization(bool show)
|
|||
* @param event context menu event.
|
||||
*/
|
||||
void VToolSplinePath::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogSplinePath>(this, event);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
|
|
|
@ -231,8 +231,16 @@ void VToolDoublePoint::keyReleaseEvent(QKeyEvent *event)
|
|||
switch (event->key())
|
||||
{
|
||||
case Qt::Key_Delete:
|
||||
try
|
||||
{
|
||||
DeleteTool();
|
||||
return; //Leave this method immediately after call!!!
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -290,9 +290,17 @@ void VToolTrueDarts::SetDartP3Id(const quint32 &value)
|
|||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolTrueDarts::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogTrueDarts>(this, event);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolTrueDarts::RemoveReferens()
|
||||
|
|
|
@ -201,9 +201,17 @@ void VToolCutArc::CurveChoosed(quint32 id)
|
|||
* @param event context menu event.
|
||||
*/
|
||||
void VToolCutArc::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogCutArc>(this, event);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
|
|
|
@ -209,9 +209,17 @@ void VToolCutSpline::CurveChoosed(quint32 id)
|
|||
* @param event context menu event.
|
||||
*/
|
||||
void VToolCutSpline::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogCutSpline>(this, event);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
|
|
|
@ -253,9 +253,17 @@ void VToolCutSplinePath::CurveChoosed(quint32 id)
|
|||
* @param event context menu event.
|
||||
*/
|
||||
void VToolCutSplinePath::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogCutSplinePath>(this, event);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
|
|
|
@ -76,9 +76,17 @@ void VToolAlongLine::SetFactor(qreal factor)
|
|||
*/
|
||||
//cppcheck-suppress unusedFunction
|
||||
void VToolAlongLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogAlongLine>(this, event);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
|
|
|
@ -230,9 +230,17 @@ void VToolBisector::SetFactor(qreal factor)
|
|||
* @param event context menu event.
|
||||
*/
|
||||
void VToolBisector::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogBisector>(this, event);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
|
|
|
@ -223,9 +223,17 @@ void VToolCurveIntersectAxis::ShowVisualization(bool show)
|
|||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolCurveIntersectAxis::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogCurveIntersectAxis>(this, event);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolCurveIntersectAxis::SaveDialog(QDomElement &domElement)
|
||||
|
|
|
@ -182,9 +182,17 @@ VToolEndLine* VToolEndLine::Create(const quint32 _id, const QString &pointName,
|
|||
* @param event context menu event.
|
||||
*/
|
||||
void VToolEndLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogEndLine>(this, event);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
|
|
|
@ -188,9 +188,17 @@ QPointF VToolHeight::FindPoint(const QLineF &line, const QPointF &point)
|
|||
* @param event context menu event.
|
||||
*/
|
||||
void VToolHeight::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogHeight>(this, event);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
|
|
|
@ -234,9 +234,17 @@ void VToolLineIntersectAxis::ShowVisualization(bool show)
|
|||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolLineIntersectAxis::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogLineIntersectAxis>(this, event);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolLineIntersectAxis::SaveDialog(QDomElement &domElement)
|
||||
|
|
|
@ -208,9 +208,17 @@ void VToolNormal::SetFactor(qreal factor)
|
|||
* @param event context menu event.
|
||||
*/
|
||||
void VToolNormal::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogNormal>(this, event);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
|
|
|
@ -234,9 +234,17 @@ void VToolShoulderPoint::SetFactor(qreal factor)
|
|||
* @param event context menu event.
|
||||
*/
|
||||
void VToolShoulderPoint::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogShoulderPoint>(this, event);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
|
|
|
@ -180,6 +180,10 @@ void VToolBasePoint::DeleteTool(bool ask)
|
|||
DeletePatternPiece *deletePP = new DeletePatternPiece(doc, nameActivDraw);
|
||||
connect(deletePP, &DeletePatternPiece::NeedFullParsing, doc, &VAbstractPattern::NeedFullParsing);
|
||||
qApp->getUndoStack()->push(deletePP);
|
||||
|
||||
// Throw exception, this will help prevent case when we forget to immediately quit function.
|
||||
VExceptionToolWasDeleted e("Tool was used after deleting.");
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -291,17 +295,22 @@ void VToolBasePoint::contextMenuEvent ( QGraphicsSceneContextMenuEvent * event )
|
|||
QApplication::restoreOverrideCursor();
|
||||
#endif
|
||||
|
||||
quint32 ref = _referens; // store referens
|
||||
_referens = 1; // make available delete pattern piece
|
||||
try
|
||||
{
|
||||
if (doc->CountPP() > 1)
|
||||
{
|
||||
ContextMenu<DialogSinglePoint>(this, event);
|
||||
ContextMenu<DialogSinglePoint>(this, event, RemoveOption::Enable, Referens::Ignore);
|
||||
}
|
||||
else
|
||||
{
|
||||
ContextMenu<DialogSinglePoint>(this, event, false);
|
||||
ContextMenu<DialogSinglePoint>(this, event, RemoveOption::Disable);
|
||||
}
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
_referens = ref; // restore referens. If not restore garbage collector delete point!!!
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -196,9 +196,17 @@ void VToolLineIntersect::SetFactor(qreal factor)
|
|||
* @param event context menu event.
|
||||
*/
|
||||
void VToolLineIntersect::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogLineIntersect>(this, event);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
|
|
|
@ -266,9 +266,17 @@ void VToolPointFromArcAndTangent::RemoveReferens()
|
|||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPointFromArcAndTangent::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogPointFromArcAndTangent>(this, event);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPointFromArcAndTangent::SaveDialog(QDomElement &domElement)
|
||||
|
|
|
@ -250,9 +250,17 @@ void VToolPointFromCircleAndTangent::RemoveReferens()
|
|||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPointFromCircleAndTangent::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogPointFromCircleAndTangent>(this, event);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPointFromCircleAndTangent::SaveDialog(QDomElement &domElement)
|
||||
|
|
|
@ -250,9 +250,17 @@ void VToolPointOfContact::SetFactor(qreal factor)
|
|||
* @param event context menu event.
|
||||
*/
|
||||
void VToolPointOfContact::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogPointOfContact>(this, event);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
|
|
|
@ -169,9 +169,17 @@ void VToolPointOfIntersection::RemoveReferens()
|
|||
* @param event context menu event.
|
||||
*/
|
||||
void VToolPointOfIntersection::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogPointOfIntersection>(this, event);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
|
|
|
@ -273,9 +273,17 @@ void VToolPointOfIntersectionArcs::RemoveReferens()
|
|||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPointOfIntersectionArcs::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogPointOfIntersectionArcs>(this, event);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPointOfIntersectionArcs::SaveDialog(QDomElement &domElement)
|
||||
|
|
|
@ -286,9 +286,17 @@ void VToolPointOfIntersectionCircles::RemoveReferens()
|
|||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPointOfIntersectionCircles::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogPointOfIntersectionCircles>(this, event);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPointOfIntersectionCircles::SaveDialog(QDomElement &domElement)
|
||||
|
|
|
@ -310,8 +310,16 @@ void VToolSinglePoint::keyReleaseEvent(QKeyEvent *event)
|
|||
switch (event->key())
|
||||
{
|
||||
case Qt::Key_Delete:
|
||||
try
|
||||
{
|
||||
DeleteTool();
|
||||
return; //Leave this method immediately after call!!!
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -225,9 +225,17 @@ void VToolTriangle::RemoveReferens()
|
|||
* @param event context menu event.
|
||||
*/
|
||||
void VToolTriangle::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogTriangle>(this, event);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
|
|
|
@ -60,7 +60,15 @@ void VAbstractPoint::ShowTool(quint32 id, bool enable)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractPoint::DeleteFromLabel()
|
||||
{
|
||||
DeleteTool(); //Leave this method immediately after call!!!
|
||||
try
|
||||
{
|
||||
DeleteTool();
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -74,6 +74,9 @@ public slots:
|
|||
virtual void Disable(bool disable, const QString &namePP)=0;
|
||||
protected:
|
||||
|
||||
enum class RemoveOption : bool {Disable = false, Enable = true};
|
||||
enum class Referens : bool {Follow = true, Ignore = false};
|
||||
|
||||
/** @brief nameActivDraw name of tool's pattern peace. */
|
||||
QString nameActivDraw;
|
||||
|
||||
|
@ -105,7 +108,9 @@ protected:
|
|||
virtual void ReadToolAttributes(const QDomElement &domElement)=0;
|
||||
|
||||
template <typename Dialog, typename Tool>
|
||||
void ContextMenu(Tool *tool, QGraphicsSceneContextMenuEvent *event, bool showRemove = true);
|
||||
void ContextMenu(Tool *tool, QGraphicsSceneContextMenuEvent *event,
|
||||
const RemoveOption &showRemove = RemoveOption::Enable,
|
||||
const Referens &ref = Referens::Follow);
|
||||
|
||||
template <typename Item>
|
||||
void ShowItem(Item *item, quint32 id, bool enable);
|
||||
|
@ -119,9 +124,11 @@ template <typename Dialog, typename Tool>
|
|||
* @brief ContextMenu show context menu for tool.
|
||||
* @param tool tool.
|
||||
* @param event context menu event.
|
||||
* @param showRemove true - tool have option delete.
|
||||
* @param showRemove true - tool enable option delete.
|
||||
* @param ref true - do not ignore referens value.
|
||||
*/
|
||||
void VDrawTool::ContextMenu(Tool *tool, QGraphicsSceneContextMenuEvent *event, bool showRemove)
|
||||
void VDrawTool::ContextMenu(Tool *tool, QGraphicsSceneContextMenuEvent *event, const RemoveOption &showRemove,
|
||||
const Referens &ref)
|
||||
{
|
||||
SCASSERT(tool != nullptr);
|
||||
SCASSERT(event != nullptr);
|
||||
|
@ -129,7 +136,9 @@ void VDrawTool::ContextMenu(Tool *tool, QGraphicsSceneContextMenuEvent *event, b
|
|||
QMenu menu;
|
||||
QAction *actionOption = menu.addAction(QIcon::fromTheme("preferences-other"), tr("Options"));
|
||||
QAction *actionRemove = menu.addAction(QIcon::fromTheme("edit-delete"), tr("Delete"));
|
||||
if (showRemove)
|
||||
if (showRemove == RemoveOption::Enable)
|
||||
{
|
||||
if (ref == Referens::Follow)
|
||||
{
|
||||
if (_referens > 1)
|
||||
{
|
||||
|
@ -141,6 +150,11 @@ void VDrawTool::ContextMenu(Tool *tool, QGraphicsSceneContextMenuEvent *event, b
|
|||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
actionRemove->setEnabled(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
actionRemove->setEnabled(false);
|
||||
}
|
||||
|
@ -161,7 +175,7 @@ void VDrawTool::ContextMenu(Tool *tool, QGraphicsSceneContextMenuEvent *event, b
|
|||
}
|
||||
if (selectedAction == actionRemove)
|
||||
{
|
||||
DeleteTool();
|
||||
DeleteTool(); // do not catch exception here
|
||||
return; //Leave this method immediately after call!!!
|
||||
}
|
||||
}
|
||||
|
|
|
@ -230,9 +230,17 @@ void VToolLine::Disable(bool disable, const QString &namePP)
|
|||
* @param event context menu event.
|
||||
*/
|
||||
void VToolLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContextMenu<DialogLine>(this, event);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
|
@ -338,8 +346,16 @@ void VToolLine::keyReleaseEvent(QKeyEvent *event)
|
|||
switch (event->key())
|
||||
{
|
||||
case Qt::Key_Delete:
|
||||
try
|
||||
{
|
||||
DeleteTool();
|
||||
return; //Leave this method immediately after call!!!
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -80,6 +80,10 @@ void VAbstractTool::DeleteTool(bool ask)
|
|||
DelTool *delTool = new DelTool(doc, id);
|
||||
connect(delTool, &DelTool::NeedFullParsing, doc, &VAbstractPattern::NeedFullParsing);
|
||||
qApp->getUndoStack()->push(delTool);
|
||||
|
||||
// Throw exception, this will help prevent case when we forget to immediately quit function.
|
||||
VExceptionToolWasDeleted e("Tool was used after deleting.");
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -237,9 +237,17 @@ void VToolDetail::Create(const quint32 &_id, const VDetail &newDetail, VMainGrap
|
|||
* @brief Remove full delete detail.
|
||||
*/
|
||||
void VToolDetail::Remove(bool ask)
|
||||
{
|
||||
try
|
||||
{
|
||||
DeleteTool(ask);
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
|
@ -367,8 +375,16 @@ void VToolDetail::keyReleaseEvent(QKeyEvent *event)
|
|||
switch (event->key())
|
||||
{
|
||||
case Qt::Key_Delete:
|
||||
try
|
||||
{
|
||||
DeleteTool();
|
||||
return; //Leave this method immediately after call!!!
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -419,8 +435,16 @@ void VToolDetail::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
|||
dialog->show();
|
||||
}
|
||||
if (selectedAction == actionRemove)
|
||||
{
|
||||
try
|
||||
{
|
||||
DeleteTool();
|
||||
}
|
||||
catch(const VExceptionToolWasDeleted &e)
|
||||
{
|
||||
Q_UNUSED(e);
|
||||
return;//Leave this method immediately!!!
|
||||
}
|
||||
return; //Leave this method immediately after call!!!
|
||||
}
|
||||
}
|
||||
|
@ -525,6 +549,10 @@ void VToolDetail::DeleteTool(bool ask)
|
|||
connect(delDet, &DeleteDetail::NeedFullParsing, doc, &VAbstractPattern::NeedFullParsing);
|
||||
}
|
||||
qApp->getUndoStack()->push(delDet);
|
||||
|
||||
// Throw exception, this will help prevent case when we forget to immediately quit function.
|
||||
VExceptionToolWasDeleted e("Tool was used after deleting.");
|
||||
throw e;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue
Block a user