destructors are not called in the right order

Pages: 12
May 11, 2025 at 8:01am
In other words, each component ended up storing its own copy of the device object, each containing a pointer to the underlying vulkan device. This lead to the underlying vulkan device being destroyed multiple times, once for each component that was destroyed. To avoid mistakes like this, consider the rule of three/five and disable copy operations for polymorphic classes and other classes that are not meant to be copied.

Rule of three/five
https://en.wikipedia.org/wiki/Rule_of_three_(C%2B%2B_programming)

Use =delete when you want to disable default behavior (such as the ability to copy)
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#c81-use-delete-when-you-want-to-disable-default-behavior-without-wanting-an-alternative

A polymorphic class should suppress public copy/move
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rc-copy-virtual
Last edited on May 11, 2025 at 8:06am
Registered users can post here. Sign in or register to post.
Pages: 12