From e7f38ec6ceea3eb40dd73fb386b19754893a9d0f Mon Sep 17 00:00:00 2001 From: Vladimir Golovnev Date: Tue, 31 Oct 2023 10:20:23 +0300 Subject: [PATCH] Don't forget to delete TorrentContentAdaptor instance PR #19825. Closes #19816. --- src/gui/addnewtorrentdialog.cpp | 6 +++--- src/gui/addnewtorrentdialog.h | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/gui/addnewtorrentdialog.cpp b/src/gui/addnewtorrentdialog.cpp index e3ceb2880..75140827e 100644 --- a/src/gui/addnewtorrentdialog.cpp +++ b/src/gui/addnewtorrentdialog.cpp @@ -549,7 +549,7 @@ void AddNewTorrentDialog::contentLayoutChanged() const auto contentLayout = static_cast(m_ui->contentLayoutComboBox->currentIndex()); m_contentAdaptor->applyContentLayout(contentLayout); - m_ui->contentTreeView->setContentHandler(m_contentAdaptor); // to cause reloading + m_ui->contentTreeView->setContentHandler(m_contentAdaptor.get()); // to cause reloading } void AddNewTorrentDialog::saveTorrentFile() @@ -775,7 +775,7 @@ void AddNewTorrentDialog::setupTreeview() if (m_torrentParams.filePaths.isEmpty()) m_torrentParams.filePaths = torrentInfo.filePaths(); - m_contentAdaptor = new TorrentContentAdaptor(torrentInfo, m_torrentParams.filePaths, m_torrentParams.filePriorities); + m_contentAdaptor = std::make_unique(torrentInfo, m_torrentParams.filePaths, m_torrentParams.filePriorities); const auto contentLayout = static_cast(m_ui->contentLayoutComboBox->currentIndex()); m_contentAdaptor->applyContentLayout(contentLayout); @@ -796,7 +796,7 @@ void AddNewTorrentDialog::setupTreeview() m_contentAdaptor->prioritizeFiles(priorities); } - m_ui->contentTreeView->setContentHandler(m_contentAdaptor); + m_ui->contentTreeView->setContentHandler(m_contentAdaptor.get()); m_filterLine->blockSignals(false); diff --git a/src/gui/addnewtorrentdialog.h b/src/gui/addnewtorrentdialog.h index 211e542ab..16c68eacc 100644 --- a/src/gui/addnewtorrentdialog.h +++ b/src/gui/addnewtorrentdialog.h @@ -29,6 +29,8 @@ #pragma once +#include + #include #include "base/bittorrent/addtorrentparams.h" @@ -85,7 +87,7 @@ private: void showEvent(QShowEvent *event) override; Ui::AddNewTorrentDialog *m_ui = nullptr; - TorrentContentAdaptor *m_contentAdaptor = nullptr; + std::unique_ptr m_contentAdaptor; BitTorrent::TorrentDescriptor m_torrentDescr; BitTorrent::AddTorrentParams m_torrentParams; int m_savePathIndex = -1;