Fix potential crash with too big shift for a label.

This commit is contained in:
Roman Telezhynskyi 2020-11-07 15:14:46 +02:00
parent 99985d43e0
commit e5a9092e25
5 changed files with 7 additions and 13 deletions

View File

@ -94,8 +94,6 @@ DestinationItem VAbstractFlipping::CreateItem(quint32 idTool, const SourceItem &
} }
DestinationItem item; DestinationItem item;
item.mx = INT_MAX;
item.my = INT_MAX;
item.id = data->AddGObject(new Item(rotated)); item.id = data->AddGObject(new Item(rotated));
return item; return item;
} }

View File

@ -252,8 +252,8 @@ QVector<DestinationItem> VAbstractOperation::ExtractDestinationData(const QDomEl
{ {
DestinationItem d; DestinationItem d;
d.id = VDomDocument::GetParametrUInt(element, AttrIdObject, NULL_ID_STR); d.id = VDomDocument::GetParametrUInt(element, AttrIdObject, NULL_ID_STR);
d.mx = qApp->toPixel(VDomDocument::GetParametrDouble(element, AttrMx, QString::number(INT_MAX))); d.mx = qApp->toPixel(VDomDocument::GetParametrDouble(element, AttrMx, QChar('1')));
d.my = qApp->toPixel(VDomDocument::GetParametrDouble(element, AttrMy, QString::number(INT_MAX))); d.my = qApp->toPixel(VDomDocument::GetParametrDouble(element, AttrMy, QChar('1')));
d.showLabel = VDomDocument::GetParametrBool(element, AttrShowLabel, trueStr); d.showLabel = VDomDocument::GetParametrBool(element, AttrShowLabel, trueStr);
destination.append(d); destination.append(d);
} }
@ -754,7 +754,7 @@ void VAbstractOperation::SaveSourceDestination(QDomElement &tag)
QDomElement item = doc->createElement(TagItem); QDomElement item = doc->createElement(TagItem);
doc->SetAttribute(item, AttrIdObject, dItem.id); doc->SetAttribute(item, AttrIdObject, dItem.id);
VAbstractSimple *obj = operatedObjects.value(dItem.id); VAbstractSimple *obj = operatedObjects.value(dItem.id, nullptr);
doc->SetAttributeOrRemoveIf(item, AttrMx, qApp->fromPixel(dItem.mx), doc->SetAttributeOrRemoveIf(item, AttrMx, qApp->fromPixel(dItem.mx),
obj && obj->GetType() != GOType::Point); obj && obj->GetType() != GOType::Point);

View File

@ -45,10 +45,10 @@
struct DestinationItem struct DestinationItem
{ {
quint32 id; quint32 id{NULL_ID};
qreal mx; qreal mx{1};
qreal my; qreal my{1};
bool showLabel; bool showLabel{true};
}; };
struct VAbstractOperationInitData : VDrawToolInitData struct VAbstractOperationInitData : VDrawToolInitData

View File

@ -629,8 +629,6 @@ DestinationItem VToolMove::CreateItem(quint32 idTool, const SourceItem &sItem, q
} }
DestinationItem item; DestinationItem item;
item.mx = INT_MAX;
item.my = INT_MAX;
item.id = data->AddGObject(new Item(moved)); item.id = data->AddGObject(new Item(moved));
return item; return item;
} }

View File

@ -440,8 +440,6 @@ DestinationItem VToolRotation::CreateItem(quint32 idTool, const SourceItem &sIte
} }
DestinationItem item; DestinationItem item;
item.mx = INT_MAX;
item.my = INT_MAX;
item.id = data->AddGObject(new Item(rotated)); item.id = data->AddGObject(new Item(rotated));
return item; return item;
} }