Skip to content

Reset PSL internals at end of building each completion procedure#5732

Merged
PaulWessel merged 1 commit intomasterfrom
completion-PS-fix
Sep 6, 2021
Merged

Reset PSL internals at end of building each completion procedure#5732
PaulWessel merged 1 commit intomasterfrom
completion-PS-fix

Conversation

@PaulWessel
Copy link
Member

The way subplot tags and movie labels and progress indicators work is that the PostScript commands needed to place these items are stored as a "completion" PostScript procedure and then the procedure is called at the end of the subplot or the whole plot. One tricky thing is that if you for instance change a color in a completion procedure, the next PSL function requesting the same color in the main module will think it was already set, but the procedure has not yet run, hence we fail to set the color. I had a partial solution to this by resetting key internal parameters, but it was incomplete and failed in movie when several -L labels with the same color or pen outline were selected (the first label was correct, the next missed the same fill/pen). This PR gathers all the resetting statements in a new internal function (gmtplot_reset_PSL) that is now called at the end of building a completion procedure. Tests still pass and my problem case also works.

The way subplot tags and movie labels and progress indicators work is that the PostScript needed to place these items are written as a "completion" PostSCript function and then the function is called at the end of the subplot or plot. One tricky thing is that if you for instance change a color in a completion function, the next PSL function requesting the same color will think it was already set, but the function has not yet run, hence we fail to select the color.  I had a partial sollution to this by resetting key internal parameters, but it was incomplete and failed in movie when several -L labels with the same color or pen outline were selected.  This PR gathers all the resetting statements in a new function (gmtplot_reset_PSL) that is now called at the end of building a completion funciton.  Tests still pass and my problem case also works.
@PaulWessel PaulWessel added the bug Something isn't working label Sep 6, 2021
@PaulWessel PaulWessel self-assigned this Sep 6, 2021
@PaulWessel PaulWessel merged commit ccc3193 into master Sep 6, 2021
@PaulWessel PaulWessel deleted the completion-PS-fix branch September 6, 2021 22:29
@Esteban82
Copy link
Member

Is this WIP? Because I am getting this message when I run gmt movie. However I don't see anything wrong in the mp4 or master frame.

free(): invalid pointer
movie_frame.sh: línea 16: 59025 Abortado                (`core' generado) gmt grdview above.nc -Rabove.nc -Ciceland.cpt -Qc${MOVIE_DPU} -Iintens.nc -JM19c -JZ0.4c -p-210/35+v4.5c/1.7c -X7.6c -Y5c
movie_frame.sh: línea 16: 59028 Abortado                (`core' generado) gmt grdview above.nc -Rabove.nc -Ciceland.cpt -Qc${MOVIE_DPU} -Iintens.nc -JM19c -JZ0.4c -p-210/35+v4.5c/1.7c -X7.6c -Y5c
free(): invalid pointer
movie_frame.sh: línea 16: 59043 Abortado                (`core' generado) gmt grdview above.nc -Rabove.nc -Ciceland.cpt -Qc${MOVIE_DPU} -Iintens.nc -JM19c -JZ0.4c -p-210/35+v4.5c/1.7c -X7.6c -Y5c

@PaulWessel
Copy link
Member Author

No, it was not WIP and I ran all the tests. However, I did not run all the animations (takes too long) except my new versions of 5 and an addition one with no problems. I will have to test your animation I think.

@PaulWessel
Copy link
Member Author

As usual, no complains on macOS for your script. Do you get the error with no -F, i.e., just making a single PNG? RUn that with -Vd to see if you can learn when it tries to free, and ideally try to figure out which line that causes it. Could try to add fprintf (stderr, "Got this far\n"); in a few places in grdview.c to see when it happens.

@Esteban82
Copy link
Member

Ok. Thanks. I will keep it in mind. The messages doesn't appear now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants