QPointer<T> does not segfault.
Because QPointer in Qt 5 is implemented in terms of QWeakPointer, this problem manifests itself in several more places. Some of the consequences of this can be seen using git grep QPointer. A non-exhaustive list:
- Putting the result of myPluginLoader::instance() into a QSharedPointer aborts (this is true since Qt 4.7.0)
- Can't put a model into a QSharedPointer after putting it into a QItemSelectionModel
- Can't put any QObject into a QSharedPointer after using it as an event filter with installEventFilter.
From there the effect snowballs.
Because of holding a QPointer:
- Can't put a QNetworkAccessManager into a QSharedPointer after creating a QNetworkReply.
- Can't create an asyncronous DBus call with callback and then put the receiver into a QSharedPointer.
Because of the event filter issue:
- Can't put a running QStateMachine which contains a QEventTransition into a QSharedPointer.
- Can't put a QFontDialog into a QSharedPointer (also not much reason to, but...)
These are just the obvious effects of this change in Qt 5.
There will certainly be more subtle side-effects and breakages resulting from implementing QPointer using QWeakPointer.
The attached tests pass in Qt 4.8 and all fail with Qt 5.
|For Gerrit Dashboard: QTBUG-22622|
|11750,3||Make it possible to put QObject tracked with QWeakPointer inside QSharedPointer||master||qt/qtbase||Status: MERGED||+2||0|