diff --git a/rpcs3/rpcs3qt/curl_handle.cpp b/rpcs3/rpcs3qt/curl_handle.cpp index 053de6e4d1..ff40004dec 100644 --- a/rpcs3/rpcs3qt/curl_handle.cpp +++ b/rpcs3/rpcs3qt/curl_handle.cpp @@ -1,3 +1,4 @@ +#include "stdafx.h" #include "curl_handle.h" #include "Emu/system_utils.hpp" #include "util/logs.hpp" @@ -11,7 +12,7 @@ LOG_CHANNEL(network_log, "NET"); namespace rpcs3::curl { -curl_handle::curl_handle(QObject* parent) : QObject(parent) +curl_handle::curl_handle() { reset_error_buffer(); @@ -48,7 +49,7 @@ void curl_handle::reset_error_buffer() m_error_buffer[0] = 0; } -std::string curl_handle::get_verbose_error(CURLcode code) +std::string curl_handle::get_verbose_error(CURLcode code) const { if (m_uses_error_buffer) { diff --git a/rpcs3/rpcs3qt/curl_handle.h b/rpcs3/rpcs3qt/curl_handle.h index 223d2eeb6c..e0d4db22d3 100644 --- a/rpcs3/rpcs3qt/curl_handle.h +++ b/rpcs3/rpcs3qt/curl_handle.h @@ -1,7 +1,6 @@ #pragma once #include -#include #ifndef CURL_STATICLIB #define CURL_STATICLIB @@ -12,10 +11,10 @@ namespace rpcs3::curl { inline bool g_curl_verbose = false; -class curl_handle : public QObject +class curl_handle { public: - explicit curl_handle(QObject* parent = nullptr); + explicit curl_handle(); ~curl_handle(); CURL* get_curl() const; @@ -26,7 +25,7 @@ public: } void reset_error_buffer(); - std::string get_verbose_error(CURLcode code); + std::string get_verbose_error(CURLcode code) const; private: CURL* m_curl = nullptr; diff --git a/rpcs3/rpcs3qt/downloader.cpp b/rpcs3/rpcs3qt/downloader.cpp index e9f4af0996..5180a532e2 100644 --- a/rpcs3/rpcs3qt/downloader.cpp +++ b/rpcs3/rpcs3qt/downloader.cpp @@ -18,7 +18,7 @@ usz curl_write_cb_compat(char* ptr, usz /*size*/, usz nmemb, void* userdata) downloader::downloader(QWidget* parent) : QObject(parent) , m_parent(parent) - , m_curl(new rpcs3::curl::curl_handle(this)) + , m_curl(new rpcs3::curl::curl_handle()) { } @@ -85,10 +85,9 @@ void downloader::start(const std::string& url, bool follow_location, bool show_p return; } - if (m_progress_dialog && (!m_keep_progress_dialog_open || !m_curl_success)) + if (!m_keep_progress_dialog_open || !m_curl_success) { - m_progress_dialog->close(); - m_progress_dialog = nullptr; + close_progress_dialog(); } if (m_curl_success) @@ -126,7 +125,7 @@ void downloader::start(const std::string& url, bool follow_location, bool show_p close_progress_dialog(); Q_EMIT signal_download_canceled(); }); - connect(m_progress_dialog, &QProgressDialog::finished, m_progress_dialog, &QProgressDialog::deleteLater); + connect(m_progress_dialog, &QProgressDialog::finished, this, &downloader::close_progress_dialog); } } diff --git a/rpcs3/rpcs3qt/downloader.h b/rpcs3/rpcs3qt/downloader.h index 8d0b34e68c..2975c6a76e 100644 --- a/rpcs3/rpcs3qt/downloader.h +++ b/rpcs3/rpcs3qt/downloader.h @@ -25,10 +25,12 @@ public: usz update_buffer(char* data, usz size); void update_progress_dialog(const QString& title) const; - void close_progress_dialog(); progress_dialog* get_progress_dialog() const; +public Q_SLOTS: + void close_progress_dialog(); + private Q_SLOTS: void handle_buffer_update(int size, int max) const; @@ -41,7 +43,7 @@ Q_SIGNALS: private: QWidget* m_parent = nullptr; - rpcs3::curl::curl_handle* m_curl = nullptr; + std::unique_ptr m_curl; QByteArray m_curl_buf; atomic_t m_curl_abort = false; atomic_t m_curl_success = false;