Enforce mode setting from GMT_Create_Session in API-driven programs #4525
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of proposed changes
See #4518 for background, as reported by @sarzeaud.
The key problem was that when modules are not driven by gmt.c (i.e., command-line calls), the single GMT_Create_Session call must set the type of the session. Pass GMT_SESSION_NORMAL and you create a classic session, and pass GMT_SESSION_RUNMODE to select modern mode. Apart from the wrappers (MATLAB, Julia, Python), stand-alone C/C++ programs must follow that rule. Now, sessions started as classic cannot later call modern-mode only modules such as begin, figure, subplot, inset, and end.
I have added a new testapi_map.c program derived from the example in #4518. By default it creates a PostScript plot and the test for this passes, but if testapi_map is run manually on the command line with a valid graphics extension (e.g., testapi_map jpg) then it will now produce the cropped JPG missing from the original posting.
I suggest @joa-quim and @seisman test this branch in GMT.jl and PyGMT before approving.