-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: add explicit virtual destructor in order to fix linker issues #13756
fix: add explicit virtual destructor in order to fix linker issues #13756
Conversation
For my understanding, without explicit declaration, the implicit default destructor is not virtual. This is an issue when a class is deleted by its base class. Can we add a CI check for this? |
I have no explanation for the issue though, the AutoFileReloader is used as a member variable where this issue is not relevant. And the ~QObject is virtual so this is even more not an issue here. |
Since 707a08f fixes the issue, can we close this? |
I don't think so. I would expect the compiler to catch this by itself already.
Yeah I agree. The implicit destructor was a red herring. Nevertheless, its probably better practice to have it declared and defined in the
That commit is part of this PR. So closing PR doesn't make sense. |
Oh yes, I see. autofilereloader.cpp is not used in mixxx-lib and can be removed here: Line 1150 in 707a08f
Why? For my understanding it is better to remove the destructor again and allow the Compiler to inline it and finally optimize it away. |
@@ -2792,6 +2792,8 @@ if(QML) | |||
# The following sources need to be in this target to get QML_ELEMENT properly interpreted | |||
src/control/controlmodel.cpp | |||
src/control/controlsortfiltermodel.cpp | |||
# needed for qml/qmlautoreload.cpp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We normally don't have such comments, remove?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would be confused on where this comes from (since the remaining files in the module all live in the qml directory), so I figured it would be better to make clear why this is necessary. I can remove if you disagree with the exception.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI I'm using autoreloader in #13082
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the headsup. well then it needs to be linked in both anyways. That discussion is therefore resolved.
It can't inline the dtor though because its I would fully agree with your conclusion if this was TriviallyDestructible, but with QObjects, the very opposite is the case (they always have a virtual destructor). So the compiler will likely declare the function as inline in the header and let the linker deduplicate it. So in the binary, its effectively as if it was always in the translation unit. So the hope that the compiler can optimize much here doesn't apply. I will try to reproduce in compiler explorer, but I don't have time right now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for explaining. LGTM
Our library layout is still not optimal, but let's merge this now make main build again.
May fix #13755