mirror of
https://github.com/Palm1r/QodeAssist.git
synced 2026-05-30 02:49:12 -04:00
fix: Prevent crash on cancelling quick refactor via progress widget
This commit is contained in:
@@ -385,26 +385,26 @@ void QuickRefactorHandler::handleLLMResponse(
|
|||||||
|
|
||||||
void QuickRefactorHandler::cancelRequest()
|
void QuickRefactorHandler::cancelRequest()
|
||||||
{
|
{
|
||||||
if (m_isRefactoringInProgress) {
|
if (!m_isRefactoringInProgress)
|
||||||
auto id = m_lastRequestId;
|
return;
|
||||||
|
|
||||||
for (auto it = m_activeRequests.begin(); it != m_activeRequests.end(); ++it) {
|
|
||||||
if (it.key() == id) {
|
|
||||||
const RequestContext &ctx = it.value();
|
|
||||||
ctx.provider->cancelRequest(id);
|
|
||||||
m_activeRequests.erase(it);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
const auto id = m_lastRequestId;
|
||||||
m_isRefactoringInProgress = false;
|
m_isRefactoringInProgress = false;
|
||||||
|
m_lastRequestId = {};
|
||||||
|
|
||||||
|
auto it = m_activeRequests.find(id);
|
||||||
|
if (it != m_activeRequests.end()) {
|
||||||
|
auto provider = it.value().provider;
|
||||||
|
m_activeRequests.erase(it);
|
||||||
|
if (provider)
|
||||||
|
provider->cancelRequest(id);
|
||||||
|
}
|
||||||
|
|
||||||
RefactorResult result;
|
RefactorResult result;
|
||||||
result.success = false;
|
result.success = false;
|
||||||
result.errorMessage = "Refactoring request was cancelled";
|
result.errorMessage = "Refactoring request was cancelled";
|
||||||
emit refactoringCompleted(result);
|
emit refactoringCompleted(result);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void QuickRefactorHandler::handleFullResponse(const QString &requestId, const QString &fullText)
|
void QuickRefactorHandler::handleFullResponse(const QString &requestId, const QString &fullText)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -142,10 +142,12 @@ void ProgressWidget::leaveEvent(QEvent *event)
|
|||||||
void ProgressWidget::mousePressEvent(QMouseEvent *event)
|
void ProgressWidget::mousePressEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (event->button() == Qt::LeftButton && m_isHovered) {
|
if (event->button() == Qt::LeftButton && m_isHovered) {
|
||||||
|
event->accept();
|
||||||
|
auto callback = m_cancelCallback;
|
||||||
emit cancelRequested();
|
emit cancelRequested();
|
||||||
if (m_cancelCallback) {
|
if (callback)
|
||||||
m_cancelCallback();
|
callback();
|
||||||
}
|
return;
|
||||||
}
|
}
|
||||||
QWidget::mousePressEvent(event);
|
QWidget::mousePressEvent(event);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user