Skip to content

Commit ee62dd3

Browse files
authored
Do not allow orphan processes
If a process is an orphan (without a parent) then the process won't exit when qbt exits and the process will be still running. This is unwanted behavior. PR qbittorrent#23422.
1 parent bc22e89 commit ee62dd3

File tree

6 files changed

+27
-25
lines changed

6 files changed

+27
-25
lines changed

src/gui/torrentcontentwidget.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,14 +492,14 @@ void TorrentContentWidget::openItem(const QModelIndex &index) const
492492
Utils::Gui::openPath(getFullPath(index));
493493
}
494494

495-
void TorrentContentWidget::openParentFolder(const QModelIndex &index) const
495+
void TorrentContentWidget::openParentFolder(const QModelIndex &index)
496496
{
497497
const Path path = getFullPath(index);
498498
m_model->contentHandler()->flushCache(); // Flush data
499499
#ifdef Q_OS_MACOS
500500
MacUtils::openFiles({path});
501501
#else
502-
Utils::Gui::openFolderSelect(path);
502+
Utils::Gui::openFolderSelect(path, this);
503503
#endif
504504
}
505505

src/gui/torrentcontentwidget.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class TorrentContentWidget final : public QTreeView
113113
void displayColumnHeaderMenu();
114114
void displayContextMenu();
115115
void openItem(const QModelIndex &index) const;
116-
void openParentFolder(const QModelIndex &index) const;
116+
void openParentFolder(const QModelIndex &index);
117117
void openSelectedFile();
118118
void renameSelectedFile();
119119
void applyPriorities(BitTorrent::DownloadPriority priority);

src/gui/transferlistwidget.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -104,20 +104,6 @@ namespace
104104
return false;
105105
}
106106

107-
void openDestinationFolder(const BitTorrent::Torrent *const torrent)
108-
{
109-
const Path contentPath = torrent->contentPath();
110-
const Path openedPath = (!contentPath.isEmpty() ? contentPath : torrent->savePath());
111-
#ifdef Q_OS_MACOS
112-
MacUtils::openFiles({openedPath});
113-
#else
114-
if (torrent->filesCount() == 1)
115-
Utils::Gui::openFolderSelect(openedPath);
116-
else
117-
Utils::Gui::openPath(openedPath);
118-
#endif
119-
}
120-
121107
void removeTorrents(const QList<BitTorrent::Torrent *> &torrents, const bool isDeleteFileSelected)
122108
{
123109
auto *session = BitTorrent::Session::instance();
@@ -592,7 +578,7 @@ void TransferListWidget::hideQueuePosColumn(bool hide)
592578
resizeColumnToContents(TransferListModel::TR_QUEUE_POSITION);
593579
}
594580

595-
void TransferListWidget::openSelectedTorrentsFolder() const
581+
void TransferListWidget::openSelectedTorrentsFolder()
596582
{
597583
QSet<Path> paths;
598584
#ifdef Q_OS_MACOS
@@ -612,7 +598,7 @@ void TransferListWidget::openSelectedTorrentsFolder() const
612598
if (!paths.contains(openedPath))
613599
{
614600
if (torrent->filesCount() == 1)
615-
Utils::Gui::openFolderSelect(openedPath);
601+
Utils::Gui::openFolderSelect(openedPath, this);
616602
else
617603
Utils::Gui::openPath(openedPath);
618604
}
@@ -621,6 +607,20 @@ void TransferListWidget::openSelectedTorrentsFolder() const
621607
#endif // Q_OS_MACOS
622608
}
623609

610+
void TransferListWidget::openDestinationFolder(const BitTorrent::Torrent *const torrent)
611+
{
612+
const Path contentPath = torrent->contentPath();
613+
const Path openedPath = (!contentPath.isEmpty() ? contentPath : torrent->savePath());
614+
#ifdef Q_OS_MACOS
615+
MacUtils::openFiles({openedPath});
616+
#else
617+
if (torrent->filesCount() == 1)
618+
Utils::Gui::openFolderSelect(openedPath, this);
619+
else
620+
Utils::Gui::openPath(openedPath);
621+
#endif
622+
}
623+
624624
void TransferListWidget::previewSelectedTorrents()
625625
{
626626
for (const BitTorrent::Torrent *torrent : asConst(getSelectedTorrents()))

src/gui/transferlistwidget.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ public slots:
8989
void copySelectedInfohashes(CopyInfohashPolicy policy) const;
9090
void copySelectedIDs() const;
9191
void copySelectedComments() const;
92-
void openSelectedTorrentsFolder() const;
92+
void openSelectedTorrentsFolder();
93+
void openDestinationFolder(const BitTorrent::Torrent *torrent);
9394
void recheckSelectedTorrents();
9495
void reannounceSelectedTorrents();
9596
void setTorrentOptions();

src/gui/utils.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ void Utils::Gui::openPath(const Path &path)
144144

145145
// Open the parent directory of the given path with a file manager and select
146146
// (if possible) the item at the given path
147-
void Utils::Gui::openFolderSelect(const Path &path)
147+
void Utils::Gui::openFolderSelect(const Path &path, [[maybe_unused]] QObject *parent)
148148
{
149149
// If the item to select doesn't exist, try to open its parent
150150
if (!path.exists())
@@ -175,11 +175,11 @@ void Utils::Gui::openFolderSelect(const Path &path)
175175
#elif defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
176176
const int lineMaxLength = 64;
177177

178-
auto lookupProc = new QProcess();
178+
auto lookupProc = new QProcess(parent);
179179
lookupProc->setProcessChannelMode(QProcess::ForwardedErrorChannel);
180180
lookupProc->setUnixProcessParameters(QProcess::UnixProcessFlag::CloseFileDescriptors);
181181
QObject::connect(lookupProc, &QProcess::finished, lookupProc
182-
, [path, lookupProc]([[maybe_unused]] const int exitCode, [[maybe_unused]] const QProcess::ExitStatus exitStatus)
182+
, [parent, path, lookupProc]([[maybe_unused]] const int exitCode, [[maybe_unused]] const QProcess::ExitStatus exitStatus)
183183
{
184184
lookupProc->deleteLater();
185185

@@ -191,7 +191,7 @@ void Utils::Gui::openFolderSelect(const Path &path)
191191
else if ((output == u"nautilus.desktop") || (output == u"org.gnome.Nautilus.desktop")
192192
|| (output == u"nautilus-folder-handler.desktop"))
193193
{
194-
auto deProcess = new QProcess();
194+
auto deProcess = new QProcess(parent);
195195
deProcess->setProcessChannelMode(QProcess::ForwardedErrorChannel);
196196
deProcess->setUnixProcessParameters(QProcess::UnixProcessFlag::CloseFileDescriptors);
197197
QObject::connect(deProcess, &QProcess::finished, deProcess

src/gui/utils.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
#include "base/pathfwd.h"
3333

34+
class QObject;
3435
class QPixmap;
3536
class QPoint;
3637
class QSize;
@@ -52,7 +53,7 @@ namespace Utils::Gui
5253
QPoint screenCenter(const QWidget *w);
5354

5455
void openPath(const Path &path);
55-
void openFolderSelect(const Path &path);
56+
void openFolderSelect(const Path &path, QObject *parent);
5657

5758
QString tagToWidgetText(const Tag &tag);
5859
Tag widgetTextToTag(const QString &text);

0 commit comments

Comments
 (0)