Details
-
Bug
-
Resolution: Done
-
P1: Critical
-
5.7.1, 5.8.0 RC
-
None
-
macOS, windows
Description
Hi,
I am the author of a library called QuickFlux (www.github.com/benlau/quickflux ) . One of the function is a central message dispatcher for component-to-component communication that avoid to propagate a signal across uncertain amount of components .
I just got a bug report that it will crash on Qt 5.7.1/5.8RC in Mac/Windows (but works with Qt 5.7.0) . After traced out the code, I found that it happen when emitting a signal from C++ to QML with a QJSValue (isUndefined() == true) as argument.
For example, if we have such C++ class:
class Messenger : public QQuickItem { Q_OBJECT public: explicit Messenger(QQuickItem *parent = 0); signals: void received(QJSValue message); public slots: void send (QJSValue message = QJSValue()); };
The send() function is actually a proxy to forward the message
void Messenger::send(QJSValue message) { emit received(message); }
Then call send() in QML, the program will crash immediately
Messenger { id: messenger onReceived: { console.log("hello"); } } Component.onCompleted: { messenger.send(); // crash here }
Part of backtrace:
QML debugging is enabled. Only use this in a safe environment.
Error: signal 11:
0 qtbug 0x000000010add87a2 _Z15handleBacktracei + 34
1 libsystem_platform.dylib 0x00007fffe45c2bba _sigtramp + 26
2 ??? 0x000000011684e7ad 0x0 + 4672776109
3 QtQml 0x000000010b33f39d _ZN15QQmlBoundSignal10setEnabledEb + 477
4 QtQml 0x000000010b38106d _ZN12QQmlNotifier10emitNotifyEP20QQmlNotifierEndpointPPv + 781
5 QtCore 0x000000010b850fc9 _ZN11QMetaObject8activateEP7QObjectiiPPv + 121
6 qtbug 0x000000010addac4f _ZN9Messenger8receivedE8QJSValue + 63
The program and backtrace has been attached .
Thanks
Attachments
For Gerrit Dashboard: QTBUG-58133 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
182265,2 | Fix crash when C++ QJSValue parameterized signal interacts with JS | 5.8 | qt/qtdeclarative | Status: MERGED | +2 | 0 |
182287,2 | Fix crash when C++ QJSValue parameterized signal interacts with JS | 5.6 | qt/qtdeclarative | Status: MERGED | +2 | 0 |
182506,3 | Fix support for QJSValue as C++ signal parameter type, part 2 | 5.8 | qt/qtdeclarative | Status: MERGED | +2 | 0 |
182673,2 | Fix support for QJSValue as C++ signal parameter type, part 2 | 5.6 | qt/qtdeclarative | Status: MERGED | +2 | 0 |