Skip to content

Commit

Permalink
symbol was compared with GMT_SYMBOL_CUBE twice instead of GMT_SYMBOL_…
Browse files Browse the repository at this point in the history
…COLUMN (#8591)

* Move a GMT_DEBUG from the inner side of a for loop.

* Check that fp is !NULL before closing it (got this in a crash case)

* symbol was compared with GMT_SYMBOL_CUBE twice instead of GMT_SYMBOL_COLUMN
  • Loading branch information
joa-quim authored Oct 2, 2024
1 parent 426abad commit 5e68adc
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
21 changes: 11 additions & 10 deletions src/grdview.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ struct GRDVIEW_POINT {
struct GRDVIEW_POINT *next_point;
};

GMT_LOCAL struct GRDVIEW_CONT * grdview_get_cont_struct (struct GMT_CTRL *GMT, uint64_t bin, struct GRDVIEW_BIN *binij, double value) {
GMT_LOCAL struct GRDVIEW_CONT *grdview_get_cont_struct(struct GMT_CTRL *GMT, uint64_t bin, struct GRDVIEW_BIN *binij, double value) {
struct GRDVIEW_CONT *cont, *new_cont;

if (!binij[bin].first_cont) binij[bin].first_cont = gmt_M_memory (GMT, NULL, 1, struct GRDVIEW_CONT);
Expand All @@ -157,7 +157,7 @@ GMT_LOCAL struct GRDVIEW_CONT * grdview_get_cont_struct (struct GMT_CTRL *GMT, u
return (new_cont);
}

GMT_LOCAL struct GRDVIEW_POINT * grdview_get_point (struct GMT_CTRL *GMT, double x, double y) {
GMT_LOCAL struct GRDVIEW_POINT *grdview_get_point(struct GMT_CTRL *GMT, double x, double y) {
struct GRDVIEW_POINT *point = gmt_M_memory (GMT, NULL, 1, struct GRDVIEW_POINT);
point->x = x;
point->y = y;
Expand Down Expand Up @@ -809,7 +809,7 @@ static int parse (struct GMT_CTRL *GMT, struct GRDVIEW_CTRL *Ctrl, struct GMT_OP
#define bailout(code) {gmt_M_free_options (mode); return (code);}
#define Return(code) {Free_Ctrl (GMT, Ctrl); gmt_end_module (GMT, GMT_cpy); bailout (code);}

EXTERN_MSC int GMT_grdview (void *V_API, int mode, void *args) {
EXTERN_MSC int GMT_grdview(void *V_API, int mode, void *args) {
bool get_contours, bad, pen_set, begin, saddle, drape_resample = false;
bool nothing_inside = false, use_intensity_grid, do_G_reading = true, read_z = false;

Expand Down Expand Up @@ -1431,12 +1431,10 @@ EXTERN_MSC int GMT_grdview (void *V_API, int mode, void *args) {

/* Plot from back to front */

gmt_M_memset (rgb, 4, double);
GMT_Report (API, GMT_MSG_INFORMATION, "Start rasterization\n");
gmt_M_memset(rgb, 4, double);
GMT_Report(API, GMT_MSG_INFORMATION, "Start rasterization\n");
GMT_Report(API, GMT_MSG_DEBUG, "Scan line conversion at j-line %.6ld\n", start[0]);
for (j = start[0]; j != stop[0]; j += inc[0]) {

GMT_Report (API, GMT_MSG_DEBUG, "Scan line conversion at j-line %.6ld\n", j);

for (i = start[1]; i != stop[1]; i += inc[1]) {
if (id[0] == GMT_Y) {
bin = gmt_M_ij0 (Z->header, j, i);
Expand Down Expand Up @@ -1521,6 +1519,7 @@ EXTERN_MSC int GMT_grdview (void *V_API, int mode, void *args) {
}
}
}
GMT_Report(API, GMT_MSG_DEBUG, "Scan line conversion at j-line %.6ld\n", j-1);

if (!Ctrl->Q.mask) { /* Must implement the clip path for the perspective image */
/* We now have the top and bottom j-pixel per i-pixel and will build a closed clip path.
Expand Down Expand Up @@ -2151,8 +2150,10 @@ EXTERN_MSC int GMT_grdview (void *V_API, int mode, void *args) {
gmt_M_free (GMT, y);
gmt_M_free (GMT, z);
gmt_M_free (GMT, v);
if (Ctrl->G.active) for (k = 0; k < Ctrl->G.n; k++) {
gmt_change_grdreg (GMT, Drape[k]->header, d_reg[k]); /* Reset registration, if required */
if (Ctrl->G.active) {
for (k = 0; k < Ctrl->G.n; k++) {
gmt_change_grdreg (GMT, Drape[k]->header, d_reg[k]); /* Reset registration, if required */
}
}
if (get_contours && GMT_Destroy_Data (API, &Z) != GMT_NOERROR) {
GMT_Report (API, GMT_MSG_ERROR, "Failed to free Z\n");
Expand Down
4 changes: 3 additions & 1 deletion src/psconvert.c
Original file line number Diff line number Diff line change
Expand Up @@ -2190,7 +2190,9 @@ EXTERN_MSC int GMT_psconvert (void *V_API, int mode, void *args) {
GMT_Report (API, GMT_MSG_ERROR,
"The file %s has no BoundingBox in the first 20 lines or last 256 bytes. Use -A option.\n", ps_file);
if (!Ctrl->T.eps && gmt_remove_file (GMT, tmp_file)) { /* Remove the temporary EPS file */
fclose (fp); fclose (fp2); fclose (fpo);
if (fp != NULL) fclose (fp);
if (fp2 != NULL) fclose (fp2);
if (fpo != NULL) fclose (fpo);
Return (GMT_RUNTIME_ERROR);
}
continue;
Expand Down
3 changes: 1 addition & 2 deletions src/psxyz.c
Original file line number Diff line number Diff line change
Expand Up @@ -1420,7 +1420,6 @@ EXTERN_MSC int GMT_psxyz (void *V_API, int mode, void *args) {
dist[1] is higher when objects are further above a place viewed from above or below a plane viewed from below */
data[n].dist[0] = GMT->current.proj.z_project.sin_az * data[n].x + GMT->current.proj.z_project.cos_az * data[n].y;
data[n].dist[1] = GMT->current.proj.z_project.sin_el * data[n].z;
GMT_Report (API, GMT_MSG_DEBUG, "dist[0] = %g dist[1] = %g\n", data[n].dist[0], data[n].dist[1]);

switch (S.symbol) {
case GMT_SYMBOL_BARX:
Expand Down Expand Up @@ -1722,7 +1721,7 @@ EXTERN_MSC int GMT_psxyz (void *V_API, int mode, void *args) {

for (i = 0; i < n; i++) {

if (n_z == 1 || (data[i].symbol == GMT_SYMBOL_CUBE || data[i].symbol == GMT_SYMBOL_CUBE)) {
if (n_z == 1 || (data[i].symbol == GMT_SYMBOL_CUBE || data[i].symbol == GMT_SYMBOL_COLUMN)) {
for (j = 0; j < 3; j++) {
gmt_M_rgb_copy (rgb[j], data[i].f.rgb);
if (S.shade3D) gmt_illuminate (GMT, lux[j], rgb[j]);
Expand Down

0 comments on commit 5e68adc

Please sign in to comment.