fix(plugins): check websocket callbacks before calling (#6314)

This commit is contained in:
nerix
2025-07-05 12:27:08 +02:00
committed by GitHub
parent 70bdeb79c3
commit c10172fee8
3 changed files with 30 additions and 4 deletions
+6 -3
View File
@@ -144,7 +144,10 @@ void WebSocketListenerProxy::onClose(std::unique_ptr<WebSocketListener> self)
auto cb = std::move(strong->onClose);
strong->onText.reset();
strong->onBinary.reset();
loggedVoidCall(cb, u"WebSocket.on_close", strong->plugin);
if (cb)
{
loggedVoidCall(cb, u"WebSocket.on_close", strong->plugin);
}
}
});
}
@@ -154,7 +157,7 @@ void WebSocketListenerProxy::onTextMessage(QByteArray data)
auto target = this->target;
runInGuiThread([target, data{std::move(data)}] {
auto strong = target.lock();
if (strong)
if (strong && strong->onText)
{
loggedVoidCall(strong->onText, u"WebSocket.on_text", strong->plugin,
data);
@@ -167,7 +170,7 @@ void WebSocketListenerProxy::onBinaryMessage(QByteArray data)
auto target = this->target;
runInGuiThread([target, data{std::move(data)}] {
auto strong = target.lock();
if (strong)
if (strong && strong->onBinary)
{
loggedVoidCall(strong->onBinary, u"WebSocket.on_binary",
strong->plugin, data);