Skip to content

Commit

Permalink
Don't forget to delete TorrentContentAdaptor instance
Browse files Browse the repository at this point in the history
PR #19825.
Closes #19816.
  • Loading branch information
glassez authored Oct 31, 2023
1 parent a689ccf commit e7f38ec
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/gui/addnewtorrentdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ void AddNewTorrentDialog::contentLayoutChanged()

const auto contentLayout = static_cast<BitTorrent::TorrentContentLayout>(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()
Expand Down Expand Up @@ -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<TorrentContentAdaptor>(torrentInfo, m_torrentParams.filePaths, m_torrentParams.filePriorities);

const auto contentLayout = static_cast<BitTorrent::TorrentContentLayout>(m_ui->contentLayoutComboBox->currentIndex());
m_contentAdaptor->applyContentLayout(contentLayout);
Expand All @@ -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);

Expand Down
4 changes: 3 additions & 1 deletion src/gui/addnewtorrentdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@

#pragma once

#include <memory>

#include <QDialog>

#include "base/bittorrent/addtorrentparams.h"
Expand Down Expand Up @@ -85,7 +87,7 @@ private slots:
void showEvent(QShowEvent *event) override;

Ui::AddNewTorrentDialog *m_ui = nullptr;
TorrentContentAdaptor *m_contentAdaptor = nullptr;
std::unique_ptr<TorrentContentAdaptor> m_contentAdaptor;
BitTorrent::TorrentDescriptor m_torrentDescr;
BitTorrent::AddTorrentParams m_torrentParams;
int m_savePathIndex = -1;
Expand Down

0 comments on commit e7f38ec

Please sign in to comment.