From 83e48fa8dc1eeeb68ab43472a1d67378e2c3def5 Mon Sep 17 00:00:00 2001 From: altalk23 <45172705+altalk23@users.noreply.github.com> Date: Fri, 8 Sep 2023 18:02:59 +0300 Subject: [PATCH] Fix AsyncWebRequest backwards compat --- loader/include/Geode/utils/web.hpp | 6 +++--- loader/src/utils/web.cpp | 16 ++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/loader/include/Geode/utils/web.hpp b/loader/include/Geode/utils/web.hpp index 17896041..a496c76f 100644 --- a/loader/include/Geode/utils/web.hpp +++ b/loader/include/Geode/utils/web.hpp @@ -106,12 +106,12 @@ namespace geode::utils::web { // Hack until 2.0.0 to store extra members in AsyncWebRequest struct AsyncWebRequestData { - std::variant m_target; std::string m_userAgent; std::string m_customRequest; bool m_isPostRequest = false; std::string m_postFields; bool m_isJsonRequest = false; + bool m_sent = false; }; /** @@ -130,8 +130,8 @@ namespace geode::utils::web { AsyncExpectCode m_expect = nullptr; AsyncProgress m_progress = nullptr; AsyncCancelled m_cancelled = nullptr; - bool m_sent = false; - mutable std::variant m_extra; + AsyncWebRequestData* m_extra = nullptr; + std::variant m_target; std::vector m_httpHeaders; AsyncWebRequestData& extra(); diff --git a/loader/src/utils/web.cpp b/loader/src/utils/web.cpp index aab89b60..d6e2a168 100644 --- a/loader/src/utils/web.cpp +++ b/loader/src/utils/web.cpp @@ -427,17 +427,17 @@ void SentAsyncWebRequest::error(std::string const& error, int code) { } AsyncWebRequestData& AsyncWebRequest::extra() { - if (!std::holds_alternative(m_extra)) { - m_extra = AsyncWebRequestData(); + if (!m_extra) { + m_extra = new AsyncWebRequestData(); } - return std::get(m_extra); + return *m_extra; } AsyncWebRequestData const& AsyncWebRequest::extra() const { - if (!std::holds_alternative(m_extra)) { - m_extra = AsyncWebRequestData(); + if (!m_extra) { + m_extra = new AsyncWebRequestData(); } - return std::get(m_extra); + return *m_extra; } AsyncWebRequest& AsyncWebRequest::join(std::string const& requestID) { @@ -503,8 +503,8 @@ AsyncWebRequest& AsyncWebRequest::cancelled(AsyncCancelled cancelledFunc) { } SentAsyncWebRequestHandle AsyncWebRequest::send() { - if (m_sent) return nullptr; - m_sent = true; + if (this->extra().m_sent) return nullptr; + this->extra().m_sent = true; std::lock_guard __(RUNNING_REQUESTS_MUTEX);