Details
-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
4.7.0
-
None
-
d9119535a2e3fcb977998ab1f7006f8a15b5a140
Description
This will crash (sorry, no backtracke this time - got problems with debug symbols)
QObject *obj = 0;
QSignalSpy spy(obj, SIGNAL(...));
Of course in this example you could say it's easy to avoid the invalid object, But in tests, where you would setup your signal spys in the beginning (otherwise, you might miss signals already), it can easily happen that one of the participating objects is 0. And since I then have to avoid QSignalSpy construction alltogether, it means that my code would have to check for a valid QSignalSpy pointer first. And then heap allocation of QSignalSpy could lead to memory leaks etc ...
In short: it would simply be more convenient if the ctor could deal with 0, and QSignalSpy::isValid could be used to check for both, valid signal and valid object (the former implies the latter, actually).