diff options
author | David Schulz <david.schulz@qt.io> | 2023-08-04 14:33:54 +0200 |
---|---|---|
committer | David Schulz <david.schulz@qt.io> | 2023-08-09 04:20:55 +0000 |
commit | fbb99463315cd020aa7458c3b550df91375f81ec (patch) | |
tree | a5e12d187199e9bd88102ceeea5aaf52c3f4e4c4 | |
parent | 31f7ed44b6b64a31109f083af833fe79e4bd35cb (diff) |
Copilot: avoid crash on misconfigured agent
When setting up a wrong or unusable agent.js the client used inside the
AuthWidget get's deleted eventually. In that case we need to reset the
tracked client otherwise we use a pointer to the deleted client in the
destructor of AuthWidget.
Change-Id: Ide4067c01cdcd05a33d44bc9460acfe9a56c7815
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
Reviewed-by: Artem Sokolovskii <artem.sokolovskii@qt.io>
-rw-r--r-- | src/plugins/copilot/authwidget.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/plugins/copilot/authwidget.cpp b/src/plugins/copilot/authwidget.cpp index 559dee30cf..4052ce600a 100644 --- a/src/plugins/copilot/authwidget.cpp +++ b/src/plugins/copilot/authwidget.cpp @@ -95,14 +95,19 @@ void AuthWidget::updateClient(const Utils::FilePath &nodeJs, const Utils::FilePa m_client = nullptr; setState(Tr::tr("Sign In"), false); m_button->setEnabled(false); - if (!nodeJs.isExecutableFile() || !agent.exists()) { + if (!nodeJs.isExecutableFile() || !agent.exists()) return; - } setState(Tr::tr("Sign In"), true); m_client = new CopilotClient(nodeJs, agent); connect(m_client, &Client::initialized, this, &AuthWidget::checkStatus); + connect(m_client, &QObject::destroyed, this, [destroyedClient = m_client, this]() { + if (destroyedClient != m_client) + return; + m_client = nullptr; + m_progressIndicator->hide(); + }); } void AuthWidget::signIn() |