Skip to content

Fix \W4 warnings and texture deletion order

Magne.Stromsnes requested to merge fix_W4_warnings into master

Enables and corrects \W4 warnings. Mostly narrowing conversions from size_t and Qt deprecated function use.

Narrowing conversions from size_t is not a big issue, as casting size_t to int for the size of a container is only an issue when that container holds more than MAX_INT elements. Only VolumeData could really do that in this application.

Qt deprecated functions should be avoided though. The main culprits were more convenient axis-functions for QtCharts and matrix-vector multiplication. Matrix-vector multiplication is split into two functions, .map and .mapVector, depending on if the multiplication is intended for a point or a vector. All of our multiplications were transformations of points, and so .map is used in all cases.

Textures are owned by the texture-store, which lived until application destruction. At that point the windows were closed and the OpenGLContexts were all destroyed. Textures need to be destroyed in the presence of a OpenGLContext.

Ownership is therefore moved back to MainWindow, and made unique to MainWindow. MainWindow is destroyed before the child widgets, and so the OpenGLContext(s) are alive. Previous use of shared_ptr in this way meant the texture-store was destroyed after the last renderer (which owned a shared_ptr to texturestore) was destroyed.

Merge request reports