Hi Hartmut,
I'm sorry for the delay, but I've been very busy. I've just applied your patch to the dashedsegment function, and it works just fine. Thank you very much. By the way, the code I sent to you was only a simplification, my real code was: GrSetClipBox(6, 0, 506, 333); GrCustomCircleArc(393,235,137,241,900,GR_ARC_STYLE_OPEN,&linestyle);
Josu Onandia
-----Mensaje original----- De: Hartmut Schirmer [SMTP:hartmut.schirmer@arcormail.de] Enviado el: jueves 6 de abril de 2000 22:19 Para: Josu Onandia CC: grx@gnu.de Asunto: Re: GrCustomCircleArc
On Wed, 05 Apr 2000, Josu Onandia wrote:
Hi,
With the following code I get an Access Violation:
unsigned char pattern[2] = { 2, 2}; GrLineOption linestyle = { 15, 1, 2, pattern };
GrCustomLine(-2, 0, 1, 0, &linestyle);
I've followed the execution until the call to 'dashedsegment', but then I get a bit lost. What is clear is that when this function calls (*doseg), the variables 'start' and 'end' haven´t been initialized.
Hi Josu,
looks like you found a bug in one of the most compicated parts of GRX.
Some years ago I rewrote the intersection function several time until it worked without overflow / underflow / division by zero / ... in the usual cases.
Your example doesn´t look like a usual case but of course should give an access violation.
The problem is the while loop doesn´t set start & end but reports actual state as ´on´
This patch should prevent the access violation. I don´t know if it´s the right soloution for this problem but it doesn´t break the linetest demo:
Hope it helps, Hartmut
*** drwcpoly.c.org Thu Apr 6 21:03:38 2000 --- drwcpoly.c Thu Apr 6 22:18:11 2000
*** 231,237 **** int x,y,dx,dy; int error,erradd,errsub,count; int xinc1,xinc2,yinc1,yinc2; ! int start[2],end[2];
/* find the current starting segment for the pattern */ pos = (p->ppos %= p->plength); --- 231,237 ---- int x,y,dx,dy; int error,erradd,errsub,count; int xinc1,xinc2,yinc1,yinc2; ! int start[2],end[2], se_init;
/* find the current starting segment for the pattern */ pos = (p->ppos %= p->plength);
*** 267,275 **** --- 267,277 ---- yinc1 = yinc2; xinc1 = 0; }
- se_init = 0; if(on) { start[0] = x; start[1] = y;
} else { prev = NULL;se_init = 1;
*** 279,284 **** --- 281,287 ---- if(on) { end[0] = x; end[1] = y;
} if((error -= errsub) < 0) { error += erradd;se_init |= 2;
*** 300,314 **** if ( !old_state && on && count > 0) { start[0] = x; start[1] = y; } else if ( old_state && !on) { (*doseg)(start,end,prev,NULL,p); prev = NULL; } /* else: zero length element(s), continue current segment */ } } ! if(on) (*doseg)(start,end,prev,next,p); p->on = on; }
--- 303,321 ---- if ( !old_state && on && count > 0) { start[0] = x; start[1] = y;
} else if ( old_state && !on) { (*doseg)(start,end,prev,NULL,p); prev = NULL;se_init = 1;
} /* else: zero length element(s), continue current segment */ } }se_init = 0;
! if(on && se_init==3) { ! (*doseg)(start,end,prev,next,p); ! } p->on = on; }