Debug cause of `QObject::connect: invalid null parameter`
-
I am getting an error message on stderr
QObject::connect: invalid null parameter
I do not know where in my code this is coming from.
Is there a way to work out which connection is invalid?
For example, I'd like to configure Qt to abort or throw an exception etc when I attempt to connect with a null parameter.
-
Hi,
Then you should assert the objects you are using in your connection calls.
-
Absolutely agree.
However, there are thousands of
QObject::connect
calls throughout my codebase.I do not know where the regression is coming from, and so am looking for help from the framework.
The fact Qt will emit an error message to
stderr
means it is checking the objects itself - so is there a way to get Qt to fail hard and fail early when given an invalid object? -
QT_FATAL_WARNINGS
to the rescue ! Define this environment variable and your application will crash when a qWarning is used. You can then get the stack trace. -
Or you could install a message handler and break/crash/log/whatever when the message happens.
-
@Chris-Kawa equally awesome, thank you too!