Skip to content

Commit

Permalink
Fix crash on application exit (Qt 6.5)
Browse files Browse the repository at this point in the history
PR #19169.
  • Loading branch information
glassez authored Jul 27, 2023
1 parent 006ad23 commit 11efd26
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/app/signalhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#endif

#include <QCoreApplication>
#include <QMetaObject>

#include "base/version.h"

Expand Down Expand Up @@ -89,7 +90,7 @@ namespace
const char *msgs[] = {"Catching signal: ", sysSigName[signum], "\nExiting cleanly\n"};
std::for_each(std::begin(msgs), std::end(msgs), safePrint);
signal(signum, SIG_DFL);
QCoreApplication::exit(); // unsafe, but exit anyway
QMetaObject::invokeMethod(qApp, [] { QCoreApplication::exit(); }, Qt::QueuedConnection); // unsafe, but exit anyway
}

#ifdef STACKTRACE
Expand Down
4 changes: 2 additions & 2 deletions src/base/torrentfileswatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ TorrentFilesWatcher *TorrentFilesWatcher::instance()
}

TorrentFilesWatcher::TorrentFilesWatcher(QObject *parent)
: QObject {parent}
: QObject(parent)
, m_ioThread {new QThread}
{
const auto *btSession = BitTorrent::Session::instance();
Expand All @@ -159,7 +159,7 @@ void TorrentFilesWatcher::initWorker()
connect(m_asyncWorker, &TorrentFilesWatcher::Worker::torrentFound, this, &TorrentFilesWatcher::onTorrentFound);

m_asyncWorker->moveToThread(m_ioThread.get());
connect(m_ioThread.get(), &QThread::finished, m_asyncWorker, &QObject::deleteLater);
connect(m_ioThread.get(), &QThread::finished, this, [this] { delete m_asyncWorker; });
m_ioThread->start();

for (auto it = m_watchedFolders.cbegin(); it != m_watchedFolders.cend(); ++it)
Expand Down

0 comments on commit 11efd26

Please sign in to comment.