From b15ea4478149b38b079920c35f66b2406a7dde61 Mon Sep 17 00:00:00 2001 From: Sergey Fedorov Date: Mon, 14 Jul 2025 07:42:18 +0800 Subject: [PATCH] Downloader.cpp: provisional fix for crash on quit --- src/modules/Extensions/Downloader.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/modules/Extensions/Downloader.cpp b/src/modules/Extensions/Downloader.cpp index 0160b026..12e48b1b 100644 --- a/src/modules/Extensions/Downloader.cpp +++ b/src/modules/Extensions/Downloader.cpp @@ -210,7 +210,8 @@ DownloadItemW::DownloadItemW(DownloaderThread *downloaderThr, QString name, cons } DownloadItemW::~DownloadItemW() { - deleteConvertProcess(); +// deleteConvertProcess() here causes the app to crash on quit, disable for now: +// deleteConvertProcess(); if (!dontDeleteDownloadThr) { finish(false); @@ -223,6 +224,7 @@ void DownloadItemW::setName(const QString &name) if (!finished) titleL->setText(name); } + void DownloadItemW::setSizeAndFilePath(qint64 size, const QString &filePath) { if (!finished) @@ -232,16 +234,19 @@ void DownloadItemW::setSizeAndFilePath(qint64 size, const QString &filePath) this->filePath = filePath; } } + void DownloadItemW::setPos(int pos) { if (!finished) speedProgressW->progressB->setValue(pos); } + void DownloadItemW::setSpeed(int Bps) { if (!finished) speedProgressW->speedL->setText(Functions::sizeString(Bps) + "/s"); } + void DownloadItemW::finish(bool f) { if (!finished) @@ -272,6 +277,7 @@ void DownloadItemW::finish(bool f) downloadStop(f); } } + void DownloadItemW::error() { if (!finished) @@ -363,7 +369,6 @@ void DownloadItemW::startConversion() m_convertProcess = new QProcess(this); - // Use old-style connect for Qt4 compatibility connect(m_convertProcess, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(handleConversionFinished(int, QProcess::ExitStatus))); connect(m_convertProcess, SIGNAL(error(QProcess::ProcessError)), @@ -424,7 +429,6 @@ void DownloadItemW::startConversion() convertCommand.replace(idx1, idx2 - idx1 + 9, "\"" + m_convertedFilePath + "\""); maybeAddAbsolutePath(convertCommand); - // Store program name and arguments for Qt4 compatibility m_processProgram = convertCommand.section(' ', 0, 0); // Extract the program name m_processArguments = convertCommand.split(' ').mid(1); // Extract the arguments (everything after the program name) @@ -438,8 +442,10 @@ void DownloadItemW::deleteConvertProcess() { if (m_convertProcess) { - disconnect(m_convertProcess, SIGNAL(finished(int)), this, SLOT(yourSlotForFinished(int))); - disconnect(m_convertProcess, SIGNAL(errorOccurred(QProcess::ProcessError)), this, SLOT(yourSlotForError(QProcess::ProcessError))); + disconnect(m_convertProcess, SIGNAL(finished(int, QProcess::ExitStatus)), + this, SLOT(handleConversionFinished(int, QProcess::ExitStatus))); + disconnect(m_convertProcess, SIGNAL(error(QProcess::ProcessError)), + this, SLOT(handleConversionError(QProcess::ProcessError))); m_convertProcess->close(); delete m_convertProcess; m_convertProcess = nullptr; @@ -567,10 +573,12 @@ void DownloaderThread::listSlot(int param, qint64 val, const QString &filePath) break; } } + void DownloaderThread::stop() { ioCtrl.abort(); } + void DownloaderThread::finished() { if (downloadItemW)