refactor: make shared_qobject_ptr ctor explicit
This turns issues like creating two shared ptrs from a single raw ptr from popping up at runtime, instead making them a compile error. Signed-off-by: flow <flowlnlnln@gmail.com>
This commit is contained in:
@@ -49,14 +49,9 @@
|
||||
|
||||
namespace Net {
|
||||
|
||||
Download::Download() : NetAction()
|
||||
{
|
||||
m_state = State::Inactive;
|
||||
}
|
||||
|
||||
auto Download::makeCached(QUrl url, MetaEntryPtr entry, Options options) -> Download::Ptr
|
||||
{
|
||||
auto* dl = new Download();
|
||||
auto dl = makeShared<Download>();
|
||||
dl->m_url = url;
|
||||
dl->m_options = options;
|
||||
auto md5Node = new ChecksumValidator(QCryptographicHash::Md5);
|
||||
@@ -67,7 +62,7 @@ auto Download::makeCached(QUrl url, MetaEntryPtr entry, Options options) -> Down
|
||||
|
||||
auto Download::makeByteArray(QUrl url, QByteArray* output, Options options) -> Download::Ptr
|
||||
{
|
||||
auto* dl = new Download();
|
||||
auto dl = makeShared<Download>();
|
||||
dl->m_url = url;
|
||||
dl->m_options = options;
|
||||
dl->m_sink.reset(new ByteArraySink(output));
|
||||
@@ -76,7 +71,7 @@ auto Download::makeByteArray(QUrl url, QByteArray* output, Options options) -> D
|
||||
|
||||
auto Download::makeFile(QUrl url, QString path, Options options) -> Download::Ptr
|
||||
{
|
||||
auto* dl = new Download();
|
||||
auto dl = makeShared<Download>();
|
||||
dl->m_url = url;
|
||||
dl->m_options = options;
|
||||
dl->m_sink.reset(new FileSink(path));
|
||||
|
@@ -52,9 +52,6 @@ class Download : public NetAction {
|
||||
enum class Option { NoOptions = 0, AcceptLocalFiles = 1, MakeEternal = 2 };
|
||||
Q_DECLARE_FLAGS(Options, Option)
|
||||
|
||||
protected:
|
||||
explicit Download();
|
||||
|
||||
public:
|
||||
~Download() override = default;
|
||||
|
||||
|
@@ -233,7 +233,7 @@ namespace Net {
|
||||
}
|
||||
|
||||
Upload::Ptr Upload::makeByteArray(QUrl url, QByteArray *output, QByteArray m_post_data) {
|
||||
auto* up = new Upload();
|
||||
auto up = makeShared<Upload>();
|
||||
up->m_url = std::move(url);
|
||||
up->m_sink.reset(new ByteArraySink(output));
|
||||
up->m_post_data = std::move(m_post_data);
|
||||
|
@@ -45,6 +45,8 @@ namespace Net {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
using Ptr = shared_qobject_ptr<Upload>;
|
||||
|
||||
static Upload::Ptr makeByteArray(QUrl url, QByteArray *output, QByteArray m_post_data);
|
||||
auto abort() -> bool override;
|
||||
auto canAbort() const -> bool override { return true; };
|
||||
|
Reference in New Issue
Block a user