mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-25 14:04:23 +00:00
Launch external programs async and don't block. Closes #1252.
This commit is contained in:
parent
bf291dbfb1
commit
77329a2609
@ -2072,11 +2072,7 @@ void QBtSession::recursiveTorrentDownload(const QTorrentHandle &h) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QBtSession::cleanUpAutoRunProcess(int) {
|
void QBtSession::autoRunExternalProgram(const QTorrentHandle &h) {
|
||||||
sender()->deleteLater();
|
|
||||||
}
|
|
||||||
|
|
||||||
void QBtSession::autoRunExternalProgram(const QTorrentHandle &h, bool async) {
|
|
||||||
if (!h.is_valid()) return;
|
if (!h.is_valid()) return;
|
||||||
QString program = Preferences().getAutoRunProgram().trimmed();
|
QString program = Preferences().getAutoRunProgram().trimmed();
|
||||||
if (program.isEmpty()) return;
|
if (program.isEmpty()) return;
|
||||||
@ -2089,14 +2085,7 @@ void QBtSession::autoRunExternalProgram(const QTorrentHandle &h, bool async) {
|
|||||||
program.replace("%f", torrent_path);
|
program.replace("%f", torrent_path);
|
||||||
// Replace %n by torrent name
|
// Replace %n by torrent name
|
||||||
program.replace("%n", h.name());
|
program.replace("%n", h.name());
|
||||||
QProcess *process = new QProcess;
|
QProcess::startDetached(program);
|
||||||
if (async) {
|
|
||||||
connect(process, SIGNAL(finished(int)), this, SLOT(cleanUpAutoRunProcess(int)));
|
|
||||||
process->start(program);
|
|
||||||
} else {
|
|
||||||
process->execute(program);
|
|
||||||
delete process;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QBtSession::sendNotificationEmail(const QTorrentHandle &h) {
|
void QBtSession::sendNotificationEmail(const QTorrentHandle &h) {
|
||||||
@ -2183,7 +2172,7 @@ void QBtSession::readAlerts() {
|
|||||||
#endif
|
#endif
|
||||||
// AutoRun program
|
// AutoRun program
|
||||||
if (pref.isAutoRunEnabled())
|
if (pref.isAutoRunEnabled())
|
||||||
autoRunExternalProgram(h, will_shutdown);
|
autoRunExternalProgram(h);
|
||||||
// Move .torrent file to another folder
|
// Move .torrent file to another folder
|
||||||
if (pref.isFinishedTorrentExportEnabled())
|
if (pref.isFinishedTorrentExportEnabled())
|
||||||
exportTorrentFile(h, FinishedTorrentExportFolder);
|
exportTorrentFile(h, FinishedTorrentExportFolder);
|
||||||
|
@ -197,8 +197,7 @@ private slots:
|
|||||||
void exportTorrentFiles(QString path);
|
void exportTorrentFiles(QString path);
|
||||||
void saveTempFastResumeData();
|
void saveTempFastResumeData();
|
||||||
void sendNotificationEmail(const QTorrentHandle &h);
|
void sendNotificationEmail(const QTorrentHandle &h);
|
||||||
void autoRunExternalProgram(const QTorrentHandle &h, bool async=true);
|
void autoRunExternalProgram(const QTorrentHandle &h);
|
||||||
void cleanUpAutoRunProcess(int);
|
|
||||||
void mergeTorrents(QTorrentHandle& h_ex, boost::intrusive_ptr<libtorrent::torrent_info> t);
|
void mergeTorrents(QTorrentHandle& h_ex, boost::intrusive_ptr<libtorrent::torrent_info> t);
|
||||||
void mergeTorrents(QTorrentHandle& h_ex, const QString& magnet_uri);
|
void mergeTorrents(QTorrentHandle& h_ex, const QString& magnet_uri);
|
||||||
void exportTorrentFile(const QTorrentHandle &h, TorrentExportFolder folder = RegularTorrentExportFolder);
|
void exportTorrentFile(const QTorrentHandle &h, TorrentExportFolder folder = RegularTorrentExportFolder);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user