Improve use of parented_ptr#13411
Conversation
…er has always a parent.
Wdyt about adding some compile time checks to template<typename... Args>
concept AnyQObject = (... || std::is_base_of_v<QObject, Args>);
template<typename T, typename... Args>
parented_ptr<T> make_parented(Args...) requires (AnyQObject<Args...>) |
|
whoops. sorry its template<typename... Args>
constexpr bool AnyQObject = (... || std::is_base_of_v<QObject, std::remove_pointer_t<Args>>); |
Swiftb0y
left a comment
There was a problem hiding this comment.
if you prefer I can also fix it locally and issue a PR to your branch once I got it working.
2131409 to
5bb0daf
Compare
|
ah nice, the static check actually caught something |
… allow the weak situation where an object is not memory managed. This reverts df77064 partially.
2a5eb7f to
11d2f59
Compare
11d2f59 to
30e9db2
Compare
|
All green finally. Thank you for your perfect idea with the compile time check. |
This PR fixed some cases where a patented_ptr is constructed without a parent. This creates a pointer that is temporary without any owner.
I have moved the assertion to the constructor to avoid this situation in future.
The risk is that we with debug assertion enabled, Mixxx will crash in case I have missed a case. So a double check during review is required.
This is part of the pending discussion about the future of parented_ptr in: #13395