Copy the scale vector as well and attach it to the data vector.

Remove it again when the graph is destroyed.
This commit is contained in:
Holger Vogt 2020-02-23 14:18:29 +01:00
parent 5eb217fecd
commit 00ebe289dd
2 changed files with 7 additions and 19 deletions

View File

@ -319,7 +319,7 @@ void gr_point(struct dvec *dv,
switch (currentgraph->plottype) {
double *tics;
case PLOT_LIN:
case PLOT_MONOLIN:
case PLOT_RETLIN:
/* If it's a linear plot, ignore first point since we don't
want to connect with oldx and oldy. */
if (np)
@ -421,32 +421,18 @@ static void gr_start_internal(struct dvec *dv, bool copyvec)
currentgraph->plotdata = link;
/* FIXME: this piece of code causes bug no. #472 */
/* Add the scale vector to the list of vectors associated with the plot
/* Copy the scale vector, add it to the vector as v_scale
* and use the copy instead of the original scale vector if requested */
{
struct dvec * const custom_scale = dv->v_scale;
if (custom_scale != (struct dvec *) NULL) {
link = TMALLOC(struct dveclist, 1);
link->next = currentgraph->plotdata;
if (custom_scale != (struct dvec*) NULL) {
if (copyvec) {
link->vector = vec_copy(dv->v_scale);
link->vector->v_flags |= VF_PERMANENT;
link->next->vector->v_scale = link->vector;
link->f_own_vector = TRUE;
currentgraph->plotdata->vector->v_scale = vec_copy(dv->v_scale);
currentgraph->plotdata->vector->v_scale->v_flags |= VF_PERMANENT;
}
else {
link->vector = dv->v_scale;
link->f_own_vector = FALSE;
}
/* Make the new vector the start of the list of vectors */
currentgraph->plotdata = link;
}
}
/* Put the legend entry on the screen. */
if (!cp_getvar("nolegend", CP_BOOL, NULL, 0))
drawlegend(currentgraph, cur.plotno++, dv);

View File

@ -259,6 +259,8 @@ int DestroyGraph(int id)
nextd = d->next;
if (d->f_own_vector) {
/* list responsible for freeing this vector */
if (d->vector->v_scale)
dvec_free(d->vector->v_scale);
dvec_free(d->vector);
}
txfree(d);