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:
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user