Mmm. I cannot agree with you unfortunately :/
The images are all stored in the table hikashop_file. In this table, the file_ref_id stores the id of the entity to which the image is attached (a product id, a variant id, a category id) and the file_type column stores the type of the image: product for product and variant images. That's the only link between an image and a variant. Changing the code of a variant does not have any impact on the images of the variant/product.
Here is what I think happened: You clicked on the delete icon of the images WITHOUT saving the product/variant. If you do that, the modification isn't taken into account. Then, you checked on another tab your front end and indeed the image was still there. Then, you changed the code and saved and at that time the deletion of the image was taken into account.