Fix crash when loading bad fill data (#2519)
* Ignore bad intersection data * Fix crash removing unwanted intersect data
This commit is contained in:
parent
b5dd396b49
commit
f2ace2130c
1 changed files with 12 additions and 9 deletions
|
@ -457,8 +457,9 @@ static void cleanNextIntersection(const VIList<Intersection> &interList,
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
void TVectorImage::Imp::eraseEdgeFromStroke(IntersectedStroke *is) {
|
void TVectorImage::Imp::eraseEdgeFromStroke(IntersectedStroke *is) {
|
||||||
if (is->m_edge.m_index >=
|
if (is->m_edge.m_index >= 0 &&
|
||||||
0) // elimino il puntatore all'edge nella lista della VIStroke
|
is->m_edge.m_index < m_strokes.size()) // elimino il puntatore all'edge
|
||||||
|
// nella lista della VIStroke
|
||||||
{
|
{
|
||||||
VIStroke *s;
|
VIStroke *s;
|
||||||
s = m_strokes[is->m_edge.m_index];
|
s = m_strokes[is->m_edge.m_index];
|
||||||
|
@ -602,7 +603,10 @@ void TVectorImage::Imp::doEraseIntersection(int index,
|
||||||
p1 = p1->next();
|
p1 = p1->next();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (deleteIt) delete deleteIt;
|
if (deleteIt) {
|
||||||
|
m_intersectionData->m_autocloseMap.erase(index);
|
||||||
|
delete deleteIt;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -771,8 +775,7 @@ for (UINT ii=0; ii<branchCount; ii++)
|
||||||
if (v[i].m_currInter >=
|
if (v[i].m_currInter >=
|
||||||
size) // pezza per immagine corrotte...evito crash
|
size) // pezza per immagine corrotte...evito crash
|
||||||
{
|
{
|
||||||
intList.clear();
|
break;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
branchesBefore[v[i].m_currInter] = i;
|
branchesBefore[v[i].m_currInter] = i;
|
||||||
|
@ -787,7 +790,7 @@ for (UINT ii=0; ii<branchCount; ii++)
|
||||||
currBranch->m_edge.m_styleId = b.m_style;
|
currBranch->m_edge.m_styleId = b.m_style;
|
||||||
// assert(b.m_style<100);
|
// assert(b.m_style<100);
|
||||||
currBranch->m_edge.m_index = b.m_strokeIndex;
|
currBranch->m_edge.m_index = b.m_strokeIndex;
|
||||||
if (b.m_strokeIndex >= 0)
|
if (b.m_strokeIndex >= 0 && b.m_strokeIndex < m_strokes.size())
|
||||||
currBranch->m_edge.m_s = m_strokes[b.m_strokeIndex]->m_s;
|
currBranch->m_edge.m_s = m_strokes[b.m_strokeIndex]->m_s;
|
||||||
else
|
else
|
||||||
currBranch->m_edge.m_s = 0;
|
currBranch->m_edge.m_s = 0;
|
||||||
|
@ -840,7 +843,7 @@ assert(v[b.m_nextBranch].m_nextBranch==i);
|
||||||
while (v[j].m_strokeIndex < 0 &&
|
while (v[j].m_strokeIndex < 0 &&
|
||||||
((j > 0 && v[j].m_currInter == v[j - 1].m_currInter) || j == 0))
|
((j > 0 && v[j].m_currInter == v[j - 1].m_currInter) || j == 0))
|
||||||
j--;
|
j--;
|
||||||
if (v[j].m_strokeIndex >= 0)
|
if (v[j].m_strokeIndex >= 0 && v[j].m_strokeIndex < m_strokes.size())
|
||||||
currInt->m_intersection =
|
currInt->m_intersection =
|
||||||
m_strokes[v[j].m_strokeIndex]->m_s->getPoint(v[j].m_w);
|
m_strokes[v[j].m_strokeIndex]->m_s->getPoint(v[j].m_w);
|
||||||
}
|
}
|
||||||
|
@ -873,7 +876,7 @@ assert(v[b.m_nextBranch].m_nextBranch==i);
|
||||||
if (!p2->m_edge.m_s && p2->m_edge.m_index < 0) {
|
if (!p2->m_edge.m_s && p2->m_edge.m_index < 0) {
|
||||||
VIStroke *vs = m_intersectionData->m_autocloseMap[p2->m_edge.m_index];
|
VIStroke *vs = m_intersectionData->m_autocloseMap[p2->m_edge.m_index];
|
||||||
if (vs) {
|
if (vs) {
|
||||||
p2->m_edge.m_s =
|
p2->m_edge.m_s =
|
||||||
m_intersectionData->m_autocloseMap[p2->m_edge.m_index]->m_s;
|
m_intersectionData->m_autocloseMap[p2->m_edge.m_index]->m_s;
|
||||||
|
|
||||||
// TEdge& e = it2->m_edge;
|
// TEdge& e = it2->m_edge;
|
||||||
|
@ -3309,7 +3312,7 @@ struct TDeleteMapFunctor {
|
||||||
};
|
};
|
||||||
|
|
||||||
IntersectionData::~IntersectionData() {
|
IntersectionData::~IntersectionData() {
|
||||||
std::for_each(m_autocloseMap.begin(), m_autocloseMap.end(),
|
std::for_each(m_autocloseMap.begin(), m_autocloseMap.end(),
|
||||||
TDeleteMapFunctor());
|
TDeleteMapFunctor());
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in a new issue