Don't passing a callback is a valid model.
But the library should not crash in that case.
This fix the uissue.
Bug-AGL: SPEC-2520
Change-Id: I6e6f3e6b617cfcf251ac910db5fa27832c2713a1
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
*/
void QAfbWebsocketClient::call(const QString& api, const QString& verb, const QJsonValue& arg, closure_t closure)
{
- QString callId = QString::number(m_nextCallId);
- m_closures[callId] = closure;
+ QString callId = QString::number(m_nextCallId++);
+ if (closure)
+ m_closures[callId] = closure;
QJsonArray msg;
msg.append(2); // Call
msg.append(api + "/" + verb);
msg.append(arg);
- m_nextCallId++;
-
QJsonDocument value;
value.setArray(msg);