diff --git a/src/gui/addnewtorrentdialog.cpp b/src/gui/addnewtorrentdialog.cpp index c327caad8..321e1528b 100644 --- a/src/gui/addnewtorrentdialog.cpp +++ b/src/gui/addnewtorrentdialog.cpp @@ -1,6 +1,6 @@ /* * Bittorrent Client using Qt and libtorrent. - * Copyright (C) 2022-2024 Vladimir Golovnev + * Copyright (C) 2022-2025 Vladimir Golovnev * Copyright (C) 2012 Christophe Dumez * * This program is free software; you can redistribute it and/or @@ -386,7 +386,6 @@ AddNewTorrentDialog::AddNewTorrentDialog(const BitTorrent::TorrentDescriptor &to AddNewTorrentDialog::~AddNewTorrentDialog() { - saveState(); delete m_ui; } @@ -400,7 +399,7 @@ void AddNewTorrentDialog::loadState() if (const QSize dialogSize = m_storeDialogSize; dialogSize.isValid()) resize(dialogSize); - m_ui->splitter->restoreState(m_storeSplitterState);; + m_ui->splitter->restoreState(m_storeSplitterState); } void AddNewTorrentDialog::saveState() @@ -836,6 +835,12 @@ void AddNewTorrentDialog::reject() QDialog::reject(); } +void AddNewTorrentDialog::done(const int result) +{ + saveState(); + QDialog::done(result); +} + void AddNewTorrentDialog::updateMetadata(const BitTorrent::TorrentInfo &metadata) { Q_ASSERT(m_currentContext); diff --git a/src/gui/addnewtorrentdialog.h b/src/gui/addnewtorrentdialog.h index bc530953b..84d57b4cc 100644 --- a/src/gui/addnewtorrentdialog.h +++ b/src/gui/addnewtorrentdialog.h @@ -1,6 +1,6 @@ /* * Bittorrent Client using Qt and libtorrent. - * Copyright (C) 2022-2024 Vladimir Golovnev + * Copyright (C) 2022-2025 Vladimir Golovnev * Copyright (C) 2012 Christophe Dumez * * This program is free software; you can redistribute it and/or @@ -68,6 +68,11 @@ signals: void torrentAccepted(const BitTorrent::TorrentDescriptor &torrentDescriptor, const BitTorrent::AddTorrentParams &addTorrentParams); void torrentRejected(const BitTorrent::TorrentDescriptor &torrentDescriptor); +public slots: + void accept() override; + void reject() override; + void done(int result) override; + private slots: void updateDiskSpaceLabel(); void onSavePathChanged(const Path &newPath); @@ -77,9 +82,6 @@ private slots: void categoryChanged(int index); void contentLayoutChanged(); - void accept() override; - void reject() override; - private: class TorrentContentAdaptor; struct Context; diff --git a/src/gui/guiaddtorrentmanager.cpp b/src/gui/guiaddtorrentmanager.cpp index 5ed945383..6e6b709d7 100644 --- a/src/gui/guiaddtorrentmanager.cpp +++ b/src/gui/guiaddtorrentmanager.cpp @@ -81,6 +81,15 @@ GUIAddTorrentManager::GUIAddTorrentManager(IGUIApplication *app, BitTorrent::Ses connect(btSession(), &BitTorrent::Session::metadataDownloaded, this, &GUIAddTorrentManager::onMetadataDownloaded); } +GUIAddTorrentManager::~GUIAddTorrentManager() +{ + for (AddNewTorrentDialog *dialog : asConst(m_dialogs)) + { + dialog->disconnect(this); + dialog->reject(); + } +} + bool GUIAddTorrentManager::addTorrent(const QString &source, const BitTorrent::AddTorrentParams ¶ms, const AddTorrentOption option) { // `source`: .torrent file path, magnet URI or URL diff --git a/src/gui/guiaddtorrentmanager.h b/src/gui/guiaddtorrentmanager.h index fa48dda30..2c756e313 100644 --- a/src/gui/guiaddtorrentmanager.h +++ b/src/gui/guiaddtorrentmanager.h @@ -61,6 +61,7 @@ class GUIAddTorrentManager : public GUIApplicationComponent public: GUIAddTorrentManager(IGUIApplication *app, BitTorrent::Session *session, QObject *parent = nullptr); + ~GUIAddTorrentManager() override; bool addTorrent(const QString &source, const BitTorrent::AddTorrentParams ¶ms = {}, AddTorrentOption option = AddTorrentOption::Default);