mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
Execute HTTP callbacks on main state not a thread
This commit is contained in:
parent
cd59ca1a8e
commit
30c7618fe5
|
@ -128,11 +128,7 @@ void HTTPRequest::execute(sol::this_state L)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
lua::StackGuard guard(L);
|
lua::StackGuard guard(L);
|
||||||
sol::state_view mainState(L);
|
(*self->cbSuccess)(HTTPResponse(res));
|
||||||
sol::thread thread = sol::thread::create(mainState);
|
|
||||||
sol::state_view threadstate = thread.state();
|
|
||||||
sol::protected_function cb(threadstate, *self->cbSuccess);
|
|
||||||
cb(HTTPResponse(res));
|
|
||||||
self->cbSuccess = std::nullopt;
|
self->cbSuccess = std::nullopt;
|
||||||
})
|
})
|
||||||
.onError([L, hack](const NetworkResult &res) {
|
.onError([L, hack](const NetworkResult &res) {
|
||||||
|
@ -146,11 +142,7 @@ void HTTPRequest::execute(sol::this_state L)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
lua::StackGuard guard(L);
|
lua::StackGuard guard(L);
|
||||||
sol::state_view mainState(L);
|
(*self->cbError)(HTTPResponse(res));
|
||||||
sol::thread thread = sol::thread::create(mainState);
|
|
||||||
sol::state_view threadstate = thread.state();
|
|
||||||
sol::protected_function cb(threadstate, *self->cbError);
|
|
||||||
cb(HTTPResponse(res));
|
|
||||||
self->cbError = std::nullopt;
|
self->cbError = std::nullopt;
|
||||||
})
|
})
|
||||||
.finally([L, hack]() {
|
.finally([L, hack]() {
|
||||||
|
@ -177,11 +169,7 @@ void HTTPRequest::execute(sol::this_state L)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
lua::StackGuard guard(L);
|
lua::StackGuard guard(L);
|
||||||
sol::state_view mainState(L);
|
(*self->cbFinally)();
|
||||||
sol::thread thread = sol::thread::create(mainState);
|
|
||||||
sol::state_view threadstate = thread.state();
|
|
||||||
sol::protected_function cb(threadstate, *self->cbFinally);
|
|
||||||
cb();
|
|
||||||
self->cbFinally = std::nullopt;
|
self->cbFinally = std::nullopt;
|
||||||
})
|
})
|
||||||
.timeout(this->timeout_)
|
.timeout(this->timeout_)
|
||||||
|
|
Loading…
Reference in a new issue