Fix crashing after a piece remove while rendering label.

This commit is contained in:
Roman Telezhynskyi 2024-06-08 20:35:55 +03:00
parent 7f3d06c383
commit fea9e5ed07
4 changed files with 25 additions and 11 deletions

View File

@ -1346,6 +1346,16 @@ auto VToolSeamAllowance::shape() const -> QPainterPath
return ItemShapeFromPath(m_mainPath, pen()); return ItemShapeFromPath(m_mainPath, pen());
} }
//---------------------------------------------------------------------------------------------------------------------
void VToolSeamAllowance::CancelLabelRendering()
{
m_patternUpdateInfoWatcher->cancel();
m_pieceUpdateInfoWatcher->cancel();
m_patternUpdateInfoWatcher->waitForFinished();
m_pieceUpdateInfoWatcher->waitForFinished();
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolSeamAllowance::FullUpdateFromGuiApply() void VToolSeamAllowance::FullUpdateFromGuiApply()
{ {

View File

@ -121,6 +121,8 @@ public:
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override; void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
auto boundingRect() const -> QRectF override; auto boundingRect() const -> QRectF override;
auto shape() const -> QPainterPath override; auto shape() const -> QPainterPath override;
void CancelLabelRendering();
public slots: public slots:
void FullUpdateFromGuiApply() override; void FullUpdateFromGuiApply() override;
void FullUpdateFromFile() override; void FullUpdateFromFile() override;

View File

@ -75,6 +75,7 @@ void AddPiece::undo()
SCASSERT(not m_tool.isNull()); SCASSERT(not m_tool.isNull());
m_tool->DisconnectOutsideSignals(); m_tool->DisconnectOutsideSignals();
m_tool->hide(); m_tool->hide();
m_tool->CancelLabelRendering();
m_scene->removeItem(m_tool); m_scene->removeItem(m_tool);

View File

@ -34,12 +34,12 @@
#include "../ifc/ifcdef.h" #include "../ifc/ifcdef.h"
#include "../ifc/xml/vabstractpattern.h" #include "../ifc/xml/vabstractpattern.h"
#include "../ifc/xml/vdomdocument.h" #include "../ifc/xml/vdomdocument.h"
#include "../vmisc/def.h"
#include "../tools/vdatatool.h" #include "../tools/vdatatool.h"
#include "vundocommand.h" #include "../vmisc/def.h"
#include "../vpatterndb/vpiecenode.h" #include "../vpatterndb/vpiecenode.h"
#include "../vpatterndb/vpiecepath.h" #include "../vpatterndb/vpiecepath.h"
#include "../vwidgets/vmaingraphicsview.h" #include "../vwidgets/vmaingraphicsview.h"
#include "vundocommand.h"
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
DeletePiece::DeletePiece(VAbstractPattern *doc, quint32 id, const VContainer &data, VMainGraphicsScene *scene, DeletePiece::DeletePiece(VAbstractPattern *doc, quint32 id, const VContainer &data, VMainGraphicsScene *scene,
@ -117,11 +117,12 @@ void DeletePiece::redo()
{ {
m_parentNode.removeChild(domElement); m_parentNode.removeChild(domElement);
m_tool = qobject_cast<VToolSeamAllowance*>(VAbstractPattern::getTool(nodeId)); m_tool = qobject_cast<VToolSeamAllowance *>(VAbstractPattern::getTool(nodeId));
SCASSERT(not m_tool.isNull()); SCASSERT(not m_tool.isNull());
m_tool->DisconnectOutsideSignals(); m_tool->DisconnectOutsideSignals();
m_tool->EnableToolMove(true); m_tool->EnableToolMove(true);
m_tool->hide(); m_tool->hide();
m_tool->CancelLabelRendering();
m_scene->removeItem(m_tool); m_scene->removeItem(m_tool);