From 202b696677c13079dd503d0f814aecdc64bfa00b Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Thu, 2 Feb 2023 23:32:26 +0100 Subject: DiffEditor: Fix a crash when "No difference" It may happen that async task associated with diffing one pair of files may not report any value. This happens when both file contents are the same. In this case taking a result from async task on a successful done will lead to crash. Add AsyncTask::isResultAvailable() method. Use it in client code just in case, where needed. Fix DiffFilesController, so that no result is allowed for all running tasks (i.e. make the main group optional). Collect list of optional results instead of direct results. The empty optional on the list means the result wasn't delivered by async task and it's skipped. Fixes: QTCREATORBUG-28750 Change-Id: I4ca678a187fad619bae470da3e806e8c8da61127 Reviewed-by: Orgad Shaneh Reviewed-by: Qt CI Bot --- src/plugins/diffeditor/unifieddiffeditorwidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins/diffeditor/unifieddiffeditorwidget.cpp') diff --git a/src/plugins/diffeditor/unifieddiffeditorwidget.cpp b/src/plugins/diffeditor/unifieddiffeditorwidget.cpp index 8c8bee05c2..b937b919f7 100644 --- a/src/plugins/diffeditor/unifieddiffeditorwidget.cpp +++ b/src/plugins/diffeditor/unifieddiffeditorwidget.cpp @@ -458,7 +458,7 @@ void UnifiedDiffEditorWidget::showDiff() m_asyncTask->setFutureSynchronizer(DiffEditorPlugin::futureSynchronizer()); m_controller.setBusyShowing(true); connect(m_asyncTask.get(), &AsyncTaskBase::done, this, [this] { - if (m_asyncTask->isCanceled()) { + if (m_asyncTask->isCanceled() || !m_asyncTask->isResultAvailable()) { setPlainText(Tr::tr("Retrieving data failed.")); } else { const ShowResult result = m_asyncTask->result(); -- cgit v1.2.1