fix(plugins): lookup by main lua state in http request (#6375)

* fix(plugins): lookup by main lua state in http request

* changelog

---------

Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
nerix
2025-08-09 12:18:35 +02:00
committed by GitHub
parent f7042dc542
commit 52d0c9631e
2 changed files with 6 additions and 7 deletions
+1
View File
@@ -56,6 +56,7 @@
- Bugfix: Emotes that failed to load their images now show as text. (#6355)
- Bugfix: Fixed a crash that occurs when searching for emotes in channel-less contexts. (#6357)
- Bugfix: Fixed command triggers showing as '/...' when the value is longer than the column width. (#6369)
- Bugfix: Fixed a crash that could occur when making HTTP requests from a timeout handler. (#6375)
- Dev: Mini refactor of Split. (#6148)
- Dev: Conan will no longer generate a `CMakeUserPresets.json` file. (#6117)
- Dev: Pass `--force-openssl` when installing from CMake in Qt 6.8+. (#6129)
+5 -7
View File
@@ -115,9 +115,10 @@ void HTTPRequest::execute(sol::this_state L)
auto hack = this->weak_from_this();
auto *pl = getApp()->getPlugins()->getPluginByStatePtr(L);
pl->httpRequests.push_back(this->shared_from_this());
auto *mainState = pl->state().lua_state();
std::move(this->req_)
.onSuccess([L, hack](const NetworkResult &res) {
.onSuccess([hack](const NetworkResult &res) {
auto self = hack.lock();
if (!self)
{
@@ -127,11 +128,10 @@ void HTTPRequest::execute(sol::this_state L)
{
return;
}
lua::StackGuard guard(L);
(*self->cbSuccess)(HTTPResponse(res));
self->cbSuccess = std::nullopt;
})
.onError([L, hack](const NetworkResult &res) {
.onError([hack](const NetworkResult &res) {
auto self = hack.lock();
if (!self)
{
@@ -141,18 +141,17 @@ void HTTPRequest::execute(sol::this_state L)
{
return;
}
lua::StackGuard guard(L);
(*self->cbError)(HTTPResponse(res));
self->cbError = std::nullopt;
})
.finally([L, hack]() {
.finally([mainState, hack]() {
auto self = hack.lock();
if (!self)
{
// this could happen if the plugin was deleted
return;
}
auto *pl = getApp()->getPlugins()->getPluginByStatePtr(L);
auto *pl = getApp()->getPlugins()->getPluginByStatePtr(mainState);
for (auto it = pl->httpRequests.begin();
it < pl->httpRequests.end(); it++)
{
@@ -167,7 +166,6 @@ void HTTPRequest::execute(sol::this_state L)
{
return;
}
lua::StackGuard guard(L);
(*self->cbFinally)();
self->cbFinally = std::nullopt;
})