SUMMARY SyntaxHighlighter(QObject* parent = nullptr) calls QSyntaxHighlighter(parent). If parent == nullptr, this crashes because QSyntaxHighlighter(QObject *parent) dereferences parent without checking for nullptr. This could be considered a bug in QSyntaxHighlighter. However, QSyntaxHighlighter does not have a default argument nullptr but SyntaxHighlighter does. I do not see a way to fix SyntaxHighlighter so that SyntaxHighlighter() can be called without crashing. Ideally, one would do this: SyntaxHighlighter::SyntaxHighlighter(QObject* parent) : QSyntaxHighlighter(parent ?QSyntaxHighlighter(parent) :QSyntaxHighlighter((QTextDocument*)0)), AbstractHighlighter(new SyntaxHighlighterPrivate) { qRegisterMetaType<QTextBlock>(); } but that does not compile. Is there a way to choose what superclass constructor to call at runtime?
No there is not. This should be fixed upstream. Relevant code upstream: https://code.woboq.org/qt5/qtbase/src/gui/text/qsyntaxhighlighter.cpp.html#300
Sounds like the default to nullptr is wrong in our code then? Should be ok to remove as that only affects SC of code that will crash immediately anyway.
Proposed upstream patch for Qt 5.12: https://codereview.qt-project.org/#/c/254448/
Upstream patch and removing the '= nullptr' is enough to close this bug imo.
Removing the = nullptr is not required. nullptr will be ok with the next Qt 5.12.x upgrade. Closing as fixed, see: https://codereview.qt-project.org/#/c/254448/