Skip to content

Commit

Permalink
Fix crash if we open an empy image
Browse files Browse the repository at this point in the history
On top of an empty image.

This is the second version of this fix, in the first commit I made a
mistake and hashed the matrix (mat) instead of the material (material).

The issue is that we need to make sure that the hash changes when we
open a new image, even if the image is exactly the same, because the
material pointer of the cached render_layers still point to the old
image.

I think a proper solution would be to avoid using pointer for
layer->material but instead an index.  The same could be done for
image->layer, image->camera, etc.
  • Loading branch information
guillaumechereau committed Sep 11, 2024
1 parent 292588c commit e875881
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/layer.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,11 @@ uint32_t layer_get_key(const layer_t *layer)
key = XXH32(&layer->shape, sizeof(layer->shape), key);
key = XXH32(&layer->color, sizeof(layer->color), key);
key = XXH32(&mat_key, sizeof(mat_key), key);
key = XXH32(&layer->mat, sizeof(layer->mat), key);
key = XXH32(&layer->mode, sizeof(layer->mode), key);

// Also hash the material pointer, to avoid some possible crashes with
// goxel.render_layers cache.
key = XXH32(&layer->material, sizeof(layer->material), key);
return key;
}

Expand Down

0 comments on commit e875881

Please sign in to comment.