From 836393d2ef43945c8394aee0f659bd1df04cb3c8 Mon Sep 17 00:00:00 2001 From: Marcus Tillmanns Date: Tue, 23 Apr 2024 08:49:37 +0200 Subject: [PATCH] Lua: Use global NetworkManager to fetch Fixes crash on exit on windows after "tell a joke" as well. Change-Id: Ie1ca0c40d9b80af7fe1b0f44ec7b8cdaa190a2cd Reviewed-by: Reviewed-by: Christian Stenger --- src/plugins/lua/bindings/fetch.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/plugins/lua/bindings/fetch.cpp b/src/plugins/lua/bindings/fetch.cpp index f8ea05d2d4a..046b220bc1c 100644 --- a/src/plugins/lua/bindings/fetch.cpp +++ b/src/plugins/lua/bindings/fetch.cpp @@ -4,6 +4,8 @@ #include "../luaengine.h" #include "../luaqttypes.h" +#include + #include #include #include @@ -51,8 +53,6 @@ void addFetchModule() .arg(r->error()); }); - static QNetworkAccessManager networkAccessManager; - fetch["fetch_cb"] = [](const sol::table &options, const sol::function &callback, const sol::this_state &thisState) { auto url = options.get("url"); @@ -70,9 +70,9 @@ void addFetchModule() QNetworkReply *reply = nullptr; if (method == "get") - reply = networkAccessManager.get(request); + reply = Utils::NetworkAccessManager::instance()->get(request); else if (method == "post") - reply = networkAccessManager.post(request, data.toUtf8()); + reply = Utils::NetworkAccessManager::instance()->post(request, data.toUtf8()); else throw std::runtime_error("Unknown method: " + method.toStdString());