Skip to content

Commit fd809df

Browse files
committed
encode: fix downconvert_DIMSTYLE
when the eed already had one member, AcadAnnotative. e.g. ../to/2013/from_github_santicastro/Triskele_centered_with_connectors_extract.dwg
1 parent 0227b57 commit fd809df

File tree

1 file changed

+26
-15
lines changed

1 file changed

+26
-15
lines changed

src/encode.c

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7471,9 +7471,9 @@ downconvert_MLEADERSTYLE (Dwg_Object *restrict obj)
74717471
idx = oo->num_eed;
74727472
if (dwg_has_eed_appid (oo, eedhdl))
74737473
return;
7474-
oo->num_eed += 2;
7474+
oo->num_eed += 1;
74757475
if (idx)
7476-
oo->eed = (Dwg_Eed *)realloc (oo->eed, oo->num_eed * sizeof (Dwg_Eed));
7476+
oo->eed = (Dwg_Eed *)realloc (oo->eed, (oo->num_eed + 1) * sizeof (Dwg_Eed));
74777477
else
74787478
oo->eed = (Dwg_Eed *)calloc (2, sizeof (Dwg_Eed));
74797479
dwg_add_handle (&oo->eed[idx].handle, 5, eedhdl, NULL);
@@ -7483,7 +7483,10 @@ downconvert_MLEADERSTYLE (Dwg_Object *restrict obj)
74837483
_obj = oo->tio.MLEADERSTYLE;
74847484
oo->eed[idx].data->u.eed_70.rs
74857485
= _obj->class_version ? _obj->class_version : 2;
7486-
oo->eed[idx + 1].size = 0;
7486+
idx++;
7487+
oo->eed[idx].size = 0;
7488+
oo->eed[idx].raw = NULL;
7489+
oo->eed[idx].data = NULL;
74877490
}
74887491

74897492
static void
@@ -7559,10 +7562,11 @@ downconvert_DIMSTYLE (Bit_Chain *restrict dat, Dwg_Object *restrict obj)
75597562
idx = oo->num_eed;
75607563
if (!dwg_has_eed_appid (oo, eedhdl1))
75617564
{
7562-
LOG_TRACE ("Add EED for AcadAnnotative\n");
7563-
oo->num_eed += 6;
7565+
LOG_TRACE ("Add EED for AcadAnnotative to " FORMAT_RLLx "\n",
7566+
obj->handle.value);
7567+
oo->num_eed += 5;
75647568
if (idx)
7565-
oo->eed = (Dwg_Eed *)realloc (oo->eed, oo->num_eed * sizeof (Dwg_Eed));
7569+
oo->eed = (Dwg_Eed *)realloc (oo->eed, (oo->num_eed + 1) * sizeof (Dwg_Eed));
75667570
else
75677571
oo->eed = (Dwg_Eed *)calloc (6, sizeof (Dwg_Eed));
75687572
// AnnotativeData
@@ -7599,15 +7603,17 @@ downconvert_DIMSTYLE (Bit_Chain *restrict dat, Dwg_Object *restrict obj)
75997603
oo->eed[idx].data->u.eed_2.close = 1;
76007604
idx++;
76017605
oo->eed[idx].size = 0;
7606+
oo->eed[idx].data = NULL;
76027607
oo->eed[idx].raw = NULL;
76037608
}
76047609

76057610
if (!dwg_has_eed_appid (oo, eedhdl2))
76067611
{
7607-
LOG_TRACE ("Add EED for ACAD_DSTYLE_DIMJAG\n");
7608-
oo->num_eed += 3;
7612+
LOG_TRACE ("Add EED for ACAD_DSTYLE_DIMJAG to " FORMAT_RLLx "\n",
7613+
obj->handle.value);
7614+
oo->num_eed += 2;
76097615
if (idx)
7610-
oo->eed = (Dwg_Eed *)realloc (oo->eed, oo->num_eed * sizeof (Dwg_Eed));
7616+
oo->eed = (Dwg_Eed *)realloc (oo->eed, (oo->num_eed + 1) * sizeof (Dwg_Eed));
76117617
else
76127618
oo->eed = (Dwg_Eed *)calloc (3, sizeof (Dwg_Eed));
76137619
// DIMJAG
@@ -7626,14 +7632,16 @@ downconvert_DIMSTYLE (Bit_Chain *restrict dat, Dwg_Object *restrict obj)
76267632
oo->eed[idx].data->u.eed_40.real = 1.5; // FIXME Which value?
76277633
idx++;
76287634
oo->eed[idx].size = 0;
7635+
oo->eed[idx].data = NULL;
76297636
oo->eed[idx].raw = NULL;
76307637
}
76317638
if (!dwg_has_eed_appid (oo, eedhdl3))
76327639
{
7633-
LOG_TRACE ("Add EED for ACAD_DSTYLE_DIMTALN\n");
7634-
oo->num_eed += 3;
7640+
LOG_TRACE ("Add EED for ACAD_DSTYLE_DIMTALN to " FORMAT_RLLx "\n",
7641+
obj->handle.value);
7642+
oo->num_eed += 2;
76357643
if (idx)
7636-
oo->eed = (Dwg_Eed *)realloc (oo->eed, oo->num_eed * sizeof (Dwg_Eed));
7644+
oo->eed = (Dwg_Eed *)realloc (oo->eed, (oo->num_eed + 1) * sizeof (Dwg_Eed));
76377645
else
76387646
oo->eed = (Dwg_Eed *)calloc (3, sizeof (Dwg_Eed));
76397647
// DIMTALN
@@ -7652,15 +7660,18 @@ downconvert_DIMSTYLE (Bit_Chain *restrict dat, Dwg_Object *restrict obj)
76527660
oo->eed[idx].data->u.eed_70.rs = 0; // FIXME Which value?
76537661
idx++;
76547662
oo->eed[idx].size = 0;
7663+
oo->eed[idx].data = NULL;
76557664
oo->eed[idx].raw = NULL;
76567665
}
76577666
if (idx != oo->num_eed)
76587667
{
7659-
LOG_WARN ("Already DIMSTYLE (" FORMAT_RLLx
7668+
// eg. when the EED already had AcadAnnotative
7669+
LOG_WARN ("Already DIMSTYLE(" FORMAT_RLLx
76607670
") eed idx %u vs num_eed %u\n",
76617671
obj->handle.value, idx, oo->num_eed);
7662-
// oo->num_eed = idx;
7663-
// oo->eed = (Dwg_Eed *)realloc (oo->eed, oo->num_eed * sizeof (Dwg_Eed));
7672+
oo->eed[idx].data = NULL;
7673+
oo->num_eed = idx;
7674+
oo->eed = (Dwg_Eed *)realloc (oo->eed, oo->num_eed * sizeof (Dwg_Eed));
76647675
}
76657676
}
76667677

0 commit comments

Comments
 (0)