# HG changeset patch # User Paper # Date 1762522764 18000 # Node ID 811697ad826a493e4f9847f952a9349c1e8ed719 # Parent 8ed3b5e8f205237ef3aa640b8552df28feed5c2b http: do proper global init/cleanup of libcurl this is done automagically using RAII diff -r 8ed3b5e8f205 -r 811697ad826a include/core/http.h --- a/include/core/http.h Fri Nov 07 07:56:03 2025 -0500 +++ b/include/core/http.h Fri Nov 07 08:39:24 2025 -0500 @@ -11,6 +11,17 @@ namespace HTTP { +/* Global state init/quit */ +void Init(); +void Quit(); + +/* helper class that automatically init/deinit as constructors + * and destructors */ +struct Initializer { + Initializer() { Init(); } + ~Initializer() { Quit(); } +}; + /* calls libcurl to encode/decode */ std::string UrlEncode(const std::string &data); std::string UrlDecode(const std::string &data); diff -r 8ed3b5e8f205 -r 811697ad826a src/core/http.cc --- a/src/core/http.cc Fri Nov 07 07:56:03 2025 -0500 +++ b/src/core/http.cc Fri Nov 07 08:39:24 2025 -0500 @@ -211,4 +211,14 @@ cancelled_ = true; } +void Init() +{ + curl_global_init(CURL_GLOBAL_ALL); +} + +void Quit() +{ + curl_global_cleanup(); +} + } // namespace HTTP diff -r 8ed3b5e8f205 -r 811697ad826a src/main.cc --- a/src/main.cc Fri Nov 07 07:56:03 2025 -0500 +++ b/src/main.cc Fri Nov 07 08:39:24 2025 -0500 @@ -2,6 +2,7 @@ #include "core/anime_db.h" #include "core/date.h" #include "core/session.h" +#include "core/http.h" #include "core/strings.h" #include "gui/window.h" #include "services/anilist.h" @@ -15,6 +16,8 @@ int main(int argc, char **argv) { + HTTP::Initializer http; + QApplication app(argc, argv); app.setApplicationName("minori"); app.setApplicationDisplayName("Minori");