diff --git a/CHANGELOG.md b/CHANGELOG.md index a9b8ae37007..f38527c575d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unversioned +- Bugfix: Fixed a crash relating to Lua HTTP. (#5800) + ## 2.5.2 - Bugfix: Fixed a crash in the 7TV EventApi when closing Chatterino. (#5768) diff --git a/src/controllers/plugins/api/HTTPRequest.cpp b/src/controllers/plugins/api/HTTPRequest.cpp index a1a97f616c8..a270e815147 100644 --- a/src/controllers/plugins/api/HTTPRequest.cpp +++ b/src/controllers/plugins/api/HTTPRequest.cpp @@ -49,12 +49,12 @@ void HTTPRequest::createUserType(sol::table &c2) ); } -void HTTPRequest::on_success(sol::protected_function func) +void HTTPRequest::on_success(sol::main_protected_function func) { this->cbSuccess = std::make_optional(func); } -void HTTPRequest::on_error(sol::protected_function func) +void HTTPRequest::on_error(sol::main_protected_function func) { this->cbError = std::make_optional(func); } @@ -64,7 +64,7 @@ void HTTPRequest::set_timeout(int timeout) this->timeout_ = timeout; } -void HTTPRequest::finally(sol::protected_function func) +void HTTPRequest::finally(sol::main_protected_function func) { this->cbFinally = std::make_optional(func); } diff --git a/src/controllers/plugins/api/HTTPRequest.hpp b/src/controllers/plugins/api/HTTPRequest.hpp index ebf82967f74..825894109a0 100644 --- a/src/controllers/plugins/api/HTTPRequest.hpp +++ b/src/controllers/plugins/api/HTTPRequest.hpp @@ -48,9 +48,9 @@ class HTTPRequest : public std::enable_shared_from_this int timeout_ = 10'000; bool done = false; - std::optional cbSuccess; - std::optional cbError; - std::optional cbFinally; + std::optional cbSuccess; + std::optional cbError; + std::optional cbFinally; public: // These functions are wrapped so data can be accessed more easily. When a call from Lua comes in: @@ -64,7 +64,7 @@ class HTTPRequest : public std::enable_shared_from_this * @lua@param callback c2.HTTPCallback Function to call when the HTTP request succeeds * @exposed c2.HTTPRequest:on_success */ - void on_success(sol::protected_function func); + void on_success(sol::main_protected_function func); /** * Sets the failure callback @@ -72,7 +72,7 @@ class HTTPRequest : public std::enable_shared_from_this * @lua@param callback c2.HTTPCallback Function to call when the HTTP request fails or returns a non-ok status * @exposed c2.HTTPRequest:on_error */ - void on_error(sol::protected_function func); + void on_error(sol::main_protected_function func); /** * Sets the finally callback @@ -80,7 +80,7 @@ class HTTPRequest : public std::enable_shared_from_this * @lua@param callback fun(): nil Function to call when the HTTP request finishes * @exposed c2.HTTPRequest:finally */ - void finally(sol::protected_function func); + void finally(sol::main_protected_function func); /** * Sets the timeout