mirror of
https://github.com/cmclark00/retro-imager.git
synced 2025-05-18 07:55:21 +01:00
If exiting program while downloading, terminate thread gracefully
Fix "terminate called without an active exception" message on Linux
This commit is contained in:
parent
43b012f964
commit
9c22346d61
2 changed files with 5 additions and 9 deletions
|
@ -54,12 +54,12 @@ DownloadExtractThread::DownloadExtractThread(const QByteArray &url, const QByteA
|
||||||
|
|
||||||
DownloadExtractThread::~DownloadExtractThread()
|
DownloadExtractThread::~DownloadExtractThread()
|
||||||
{
|
{
|
||||||
|
_cancelled = true;
|
||||||
|
_cancelExtract();
|
||||||
if (!_extractThread->wait(2000))
|
if (!_extractThread->wait(2000))
|
||||||
{
|
{
|
||||||
_extractThread->terminate();
|
_extractThread->terminate();
|
||||||
}
|
}
|
||||||
_queue.clear();
|
|
||||||
_cv.notify_one();
|
|
||||||
qFreeAligned(_abuf[0]);
|
qFreeAligned(_abuf[0]);
|
||||||
qFreeAligned(_abuf[1]);
|
qFreeAligned(_abuf[1]);
|
||||||
}
|
}
|
||||||
|
@ -105,12 +105,8 @@ void DownloadExtractThread::_cancelExtract()
|
||||||
std::unique_lock<std::mutex> lock(_queueMutex);
|
std::unique_lock<std::mutex> lock(_queueMutex);
|
||||||
_queue.clear();
|
_queue.clear();
|
||||||
_queue.push_back(QByteArray());
|
_queue.push_back(QByteArray());
|
||||||
|
lock.unlock();
|
||||||
if (_queue.size() == 1)
|
_cv.notify_one();
|
||||||
{
|
|
||||||
lock.unlock();
|
|
||||||
_cv.notify_one();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownloadExtractThread::cancelDownload()
|
void DownloadExtractThread::cancelDownload()
|
||||||
|
|
|
@ -48,7 +48,7 @@ protected:
|
||||||
|
|
||||||
QByteArray _popQueue();
|
QByteArray _popQueue();
|
||||||
void _pushQueue(const char *data, size_t len);
|
void _pushQueue(const char *data, size_t len);
|
||||||
virtual void _cancelExtract();
|
void _cancelExtract();
|
||||||
virtual size_t _writeData(const char *buf, size_t len);
|
virtual size_t _writeData(const char *buf, size_t len);
|
||||||
virtual void _onDownloadSuccess();
|
virtual void _onDownloadSuccess();
|
||||||
virtual void _onDownloadError(const QString &msg);
|
virtual void _onDownloadError(const QString &msg);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue