From d83b2a61311b0dc3bc31ee52d1b9eaac715c3cdf Mon Sep 17 00:00:00 2001 From: Vladimir Golovnev Date: Tue, 2 May 2023 09:48:49 +0300 Subject: [PATCH] Make sure ResumeSessionContext is destroyed before start processing PR #18912. --- src/base/bittorrent/sessionimpl.cpp | 38 +++++++++++++++-------------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/src/base/bittorrent/sessionimpl.cpp b/src/base/bittorrent/sessionimpl.cpp index 987391a73..40557e227 100644 --- a/src/base/bittorrent/sessionimpl.cpp +++ b/src/base/bittorrent/sessionimpl.cpp @@ -1435,27 +1435,29 @@ void SessionImpl::endStartup(ResumeSessionContext *context) } context->deleteLater(); + connect(context, &QObject::destroyed, this, [this] + { + m_nativeSession->resume(); + if (m_refreshEnqueued) + m_refreshEnqueued = false; + else + enqueueRefresh(); - m_nativeSession->resume(); - if (m_refreshEnqueued) - m_refreshEnqueued = false; - else - enqueueRefresh(); - - m_statisticsLastUpdateTimer.start(); + m_statisticsLastUpdateTimer.start(); - // Regular saving of fastresume data - connect(m_resumeDataTimer, &QTimer::timeout, this, &SessionImpl::generateResumeData); - const int saveInterval = saveResumeDataInterval(); - if (saveInterval > 0) - { - m_resumeDataTimer->setInterval(std::chrono::minutes(saveInterval)); - m_resumeDataTimer->start(); - } + // Regular saving of fastresume data + connect(m_resumeDataTimer, &QTimer::timeout, this, &SessionImpl::generateResumeData); + const int saveInterval = saveResumeDataInterval(); + if (saveInterval > 0) + { + m_resumeDataTimer->setInterval(std::chrono::minutes(saveInterval)); + m_resumeDataTimer->start(); + } - m_isRestored = true; - emit startupProgressUpdated(100); - emit restored(); + m_isRestored = true; + emit startupProgressUpdated(100); + emit restored(); + }); } void SessionImpl::initializeNativeSession()