mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-17 06:01:33 -06:00
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 #23422.
This commit is contained in:
@@ -492,14 +492,14 @@ void TorrentContentWidget::openItem(const QModelIndex &index) const
|
|||||||
Utils::Gui::openPath(getFullPath(index));
|
Utils::Gui::openPath(getFullPath(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TorrentContentWidget::openParentFolder(const QModelIndex &index) const
|
void TorrentContentWidget::openParentFolder(const QModelIndex &index)
|
||||||
{
|
{
|
||||||
const Path path = getFullPath(index);
|
const Path path = getFullPath(index);
|
||||||
m_model->contentHandler()->flushCache(); // Flush data
|
m_model->contentHandler()->flushCache(); // Flush data
|
||||||
#ifdef Q_OS_MACOS
|
#ifdef Q_OS_MACOS
|
||||||
MacUtils::openFiles({path});
|
MacUtils::openFiles({path});
|
||||||
#else
|
#else
|
||||||
Utils::Gui::openFolderSelect(path);
|
Utils::Gui::openFolderSelect(path, this);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ private:
|
|||||||
void displayColumnHeaderMenu();
|
void displayColumnHeaderMenu();
|
||||||
void displayContextMenu();
|
void displayContextMenu();
|
||||||
void openItem(const QModelIndex &index) const;
|
void openItem(const QModelIndex &index) const;
|
||||||
void openParentFolder(const QModelIndex &index) const;
|
void openParentFolder(const QModelIndex &index);
|
||||||
void openSelectedFile();
|
void openSelectedFile();
|
||||||
void renameSelectedFile();
|
void renameSelectedFile();
|
||||||
void applyPriorities(BitTorrent::DownloadPriority priority);
|
void applyPriorities(BitTorrent::DownloadPriority priority);
|
||||||
|
|||||||
@@ -104,20 +104,6 @@ namespace
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void openDestinationFolder(const BitTorrent::Torrent *const torrent)
|
|
||||||
{
|
|
||||||
const Path contentPath = torrent->contentPath();
|
|
||||||
const Path openedPath = (!contentPath.isEmpty() ? contentPath : torrent->savePath());
|
|
||||||
#ifdef Q_OS_MACOS
|
|
||||||
MacUtils::openFiles({openedPath});
|
|
||||||
#else
|
|
||||||
if (torrent->filesCount() == 1)
|
|
||||||
Utils::Gui::openFolderSelect(openedPath);
|
|
||||||
else
|
|
||||||
Utils::Gui::openPath(openedPath);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void removeTorrents(const QList<BitTorrent::Torrent *> &torrents, const bool isDeleteFileSelected)
|
void removeTorrents(const QList<BitTorrent::Torrent *> &torrents, const bool isDeleteFileSelected)
|
||||||
{
|
{
|
||||||
auto *session = BitTorrent::Session::instance();
|
auto *session = BitTorrent::Session::instance();
|
||||||
@@ -592,7 +578,7 @@ void TransferListWidget::hideQueuePosColumn(bool hide)
|
|||||||
resizeColumnToContents(TransferListModel::TR_QUEUE_POSITION);
|
resizeColumnToContents(TransferListModel::TR_QUEUE_POSITION);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransferListWidget::openSelectedTorrentsFolder() const
|
void TransferListWidget::openSelectedTorrentsFolder()
|
||||||
{
|
{
|
||||||
QSet<Path> paths;
|
QSet<Path> paths;
|
||||||
#ifdef Q_OS_MACOS
|
#ifdef Q_OS_MACOS
|
||||||
@@ -612,7 +598,7 @@ void TransferListWidget::openSelectedTorrentsFolder() const
|
|||||||
if (!paths.contains(openedPath))
|
if (!paths.contains(openedPath))
|
||||||
{
|
{
|
||||||
if (torrent->filesCount() == 1)
|
if (torrent->filesCount() == 1)
|
||||||
Utils::Gui::openFolderSelect(openedPath);
|
Utils::Gui::openFolderSelect(openedPath, this);
|
||||||
else
|
else
|
||||||
Utils::Gui::openPath(openedPath);
|
Utils::Gui::openPath(openedPath);
|
||||||
}
|
}
|
||||||
@@ -621,6 +607,20 @@ void TransferListWidget::openSelectedTorrentsFolder() const
|
|||||||
#endif // Q_OS_MACOS
|
#endif // Q_OS_MACOS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TransferListWidget::openDestinationFolder(const BitTorrent::Torrent *const torrent)
|
||||||
|
{
|
||||||
|
const Path contentPath = torrent->contentPath();
|
||||||
|
const Path openedPath = (!contentPath.isEmpty() ? contentPath : torrent->savePath());
|
||||||
|
#ifdef Q_OS_MACOS
|
||||||
|
MacUtils::openFiles({openedPath});
|
||||||
|
#else
|
||||||
|
if (torrent->filesCount() == 1)
|
||||||
|
Utils::Gui::openFolderSelect(openedPath, this);
|
||||||
|
else
|
||||||
|
Utils::Gui::openPath(openedPath);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void TransferListWidget::previewSelectedTorrents()
|
void TransferListWidget::previewSelectedTorrents()
|
||||||
{
|
{
|
||||||
for (const BitTorrent::Torrent *torrent : asConst(getSelectedTorrents()))
|
for (const BitTorrent::Torrent *torrent : asConst(getSelectedTorrents()))
|
||||||
|
|||||||
@@ -89,7 +89,8 @@ public slots:
|
|||||||
void copySelectedInfohashes(CopyInfohashPolicy policy) const;
|
void copySelectedInfohashes(CopyInfohashPolicy policy) const;
|
||||||
void copySelectedIDs() const;
|
void copySelectedIDs() const;
|
||||||
void copySelectedComments() const;
|
void copySelectedComments() const;
|
||||||
void openSelectedTorrentsFolder() const;
|
void openSelectedTorrentsFolder();
|
||||||
|
void openDestinationFolder(const BitTorrent::Torrent *torrent);
|
||||||
void recheckSelectedTorrents();
|
void recheckSelectedTorrents();
|
||||||
void reannounceSelectedTorrents();
|
void reannounceSelectedTorrents();
|
||||||
void setTorrentOptions();
|
void setTorrentOptions();
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ void Utils::Gui::openPath(const Path &path)
|
|||||||
|
|
||||||
// Open the parent directory of the given path with a file manager and select
|
// Open the parent directory of the given path with a file manager and select
|
||||||
// (if possible) the item at the given path
|
// (if possible) the item at the given path
|
||||||
void Utils::Gui::openFolderSelect(const Path &path)
|
void Utils::Gui::openFolderSelect(const Path &path, [[maybe_unused]] QObject *parent)
|
||||||
{
|
{
|
||||||
// If the item to select doesn't exist, try to open its parent
|
// If the item to select doesn't exist, try to open its parent
|
||||||
if (!path.exists())
|
if (!path.exists())
|
||||||
@@ -175,11 +175,11 @@ void Utils::Gui::openFolderSelect(const Path &path)
|
|||||||
#elif defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
|
#elif defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
|
||||||
const int lineMaxLength = 64;
|
const int lineMaxLength = 64;
|
||||||
|
|
||||||
auto lookupProc = new QProcess();
|
auto lookupProc = new QProcess(parent);
|
||||||
lookupProc->setProcessChannelMode(QProcess::ForwardedErrorChannel);
|
lookupProc->setProcessChannelMode(QProcess::ForwardedErrorChannel);
|
||||||
lookupProc->setUnixProcessParameters(QProcess::UnixProcessFlag::CloseFileDescriptors);
|
lookupProc->setUnixProcessParameters(QProcess::UnixProcessFlag::CloseFileDescriptors);
|
||||||
QObject::connect(lookupProc, &QProcess::finished, lookupProc
|
QObject::connect(lookupProc, &QProcess::finished, lookupProc
|
||||||
, [path, lookupProc]([[maybe_unused]] const int exitCode, [[maybe_unused]] const QProcess::ExitStatus exitStatus)
|
, [parent, path, lookupProc]([[maybe_unused]] const int exitCode, [[maybe_unused]] const QProcess::ExitStatus exitStatus)
|
||||||
{
|
{
|
||||||
lookupProc->deleteLater();
|
lookupProc->deleteLater();
|
||||||
|
|
||||||
@@ -191,7 +191,7 @@ void Utils::Gui::openFolderSelect(const Path &path)
|
|||||||
else if ((output == u"nautilus.desktop") || (output == u"org.gnome.Nautilus.desktop")
|
else if ((output == u"nautilus.desktop") || (output == u"org.gnome.Nautilus.desktop")
|
||||||
|| (output == u"nautilus-folder-handler.desktop"))
|
|| (output == u"nautilus-folder-handler.desktop"))
|
||||||
{
|
{
|
||||||
auto deProcess = new QProcess();
|
auto deProcess = new QProcess(parent);
|
||||||
deProcess->setProcessChannelMode(QProcess::ForwardedErrorChannel);
|
deProcess->setProcessChannelMode(QProcess::ForwardedErrorChannel);
|
||||||
deProcess->setUnixProcessParameters(QProcess::UnixProcessFlag::CloseFileDescriptors);
|
deProcess->setUnixProcessParameters(QProcess::UnixProcessFlag::CloseFileDescriptors);
|
||||||
QObject::connect(deProcess, &QProcess::finished, deProcess
|
QObject::connect(deProcess, &QProcess::finished, deProcess
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
|
|
||||||
#include "base/pathfwd.h"
|
#include "base/pathfwd.h"
|
||||||
|
|
||||||
|
class QObject;
|
||||||
class QPixmap;
|
class QPixmap;
|
||||||
class QPoint;
|
class QPoint;
|
||||||
class QSize;
|
class QSize;
|
||||||
@@ -52,7 +53,7 @@ namespace Utils::Gui
|
|||||||
QPoint screenCenter(const QWidget *w);
|
QPoint screenCenter(const QWidget *w);
|
||||||
|
|
||||||
void openPath(const Path &path);
|
void openPath(const Path &path);
|
||||||
void openFolderSelect(const Path &path);
|
void openFolderSelect(const Path &path, QObject *parent);
|
||||||
|
|
||||||
QString tagToWidgetText(const Tag &tag);
|
QString tagToWidgetText(const Tag &tag);
|
||||||
Tag widgetTextToTag(const QString &text);
|
Tag widgetTextToTag(const QString &text);
|
||||||
|
|||||||
Reference in New Issue
Block a user