Skip to content
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(server): Respect Qt's desired initialization order #6691

Merged
merged 1 commit into from
Jan 11, 2025

Conversation

Krzmbrzl
Copy link
Member

In a Qt application, the QApplication object should be the first QObject that is created. However, the Meta class used to have a static member called mp, which means that this member gets initialized before main() runs and therefore before the QApplication is created.

This has caused an "Invalid nullptr in QObject::connect" warning somewhere in Qt's internals (since the move to Qt 6). The impact of this warning is unclear at this point.

This commit makes the mp parameter a std::unique_ptr that gets explicitly initialized in the main function (more or less right after the QApplication object is created). This guarantees that the MetaParams object does not get created before the QApplication object, fixing the observed warning.

It is worth noting that we do have a couple of other static QObject variables in the main translation unit, but these seem to be inconsequential (at least they don't seem to trigger a similar warning).

Fixes #6669

Checks

In a Qt application, the QApplication object should be the first QObject
that is created. However, the `Meta` class used to have a static member
called `mp`, which means that this member gets initialized _before_
main() runs and therefore before the QApplication is created.

This has caused an "Invalid nullptr in QObject::connect" warning
somewhere in Qt's internals (since the move to Qt 6). The impact of this
warning is unclear at this point.

This commit makes the mp parameter a std::unique_ptr that gets
explicitly initialized in the main function (more or less right after
the QApplication object is created). This guarantees that the MetaParams
object does not get created before the QApplication object, fixing the
observed warning.

It is worth noting that we do have a couple of other static QObject
variables in the main translation unit, but these seem to be
inconsequential (at least they don't seem to trigger a similar warning).

Fixes mumble-voip#6669
@Krzmbrzl Krzmbrzl added server bug A bug (error) in the software labels Jan 11, 2025
@Krzmbrzl
Copy link
Member Author

@Hartmnt I would tend to not backport this to 1.5 as it is not clear whether the fixed issue even has any real consequences for Mumble. At the same time, this change might have some subtle, unintended side-effects. Do you see this in a similar way?

@Hartmnt
Copy link
Member

Hartmnt commented Jan 11, 2025

@Hartmnt I would tend to not backport this to 1.5 as it is not clear whether the fixed issue even has any real consequences for Mumble. At the same time, this change might have some subtle, unintended side-effects. Do you see this in a similar way?

Totally, this does not seem to negatively impact 1.5 and I would leave it as is to not cause any unintended side-effects

@Krzmbrzl Krzmbrzl merged commit 5fd534a into mumble-voip:master Jan 11, 2025
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug (error) in the software server
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Invalid nullptr in QObject::connect
2 participants