TDan, et al...
I have discovered the root cause of the occasional crash on Windows raster cache
rebuild. The problem stemmed from a
collision between the completion
events coming from the ongoing current chart load, and the batch
compression jobs. This lead to a logic error of trying to delete a nonexistent object. Which of course crashed.
Related to your analysis, there was also a problem with closing/deleting chart objects on program termination. This left lots of dangling pointers, as you found. It was discovered that the problem was only on GL, and related to the order in which various elements were shutdown/destroyed on exit.
I fixed these two items in github master (O4.99). The fixes could be backported to 484 for testing, but probably not needed for most user situations.
The reasonable workaround for the texture cache
rebuild crash is this:
Move the viewport to somewhere far away from any raster
charts currently in the database. Central
Asia comes to mind. Stop OCPN, then restart normally. Clear and rebuild the cache normally. The cache rebuild should not crash in this case.
Thanks
Dave