forked from qt-creator/qt-creator
Git: Fix crash on Grep
If the process is already finished, and cancel is triggered Creator crashes. For example, search for "q" in qt-creator, wait for >200K popup, then wait a few seconds for the process to finish and press Cancel. The reason for the crash is that reportFinished() is called twice - one from GitGrepRunner::finish() and another one from Utils::runAsyncImpl(). Change-Id: I61d379f5e3a5ae86c9a48a3751dbb2e00203516d Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
5646480f27
commit
6a3e687d14
@@ -122,13 +122,6 @@ public:
|
|||||||
m_fi.reportResult(resultList);
|
m_fi.reportResult(resultList);
|
||||||
}
|
}
|
||||||
|
|
||||||
void finish()
|
|
||||||
{
|
|
||||||
read();
|
|
||||||
m_fi.setProgressValue(1);
|
|
||||||
m_fi.reportFinished();
|
|
||||||
}
|
|
||||||
|
|
||||||
void exec()
|
void exec()
|
||||||
{
|
{
|
||||||
m_fi.setProgressRange(0, 1);
|
m_fi.setProgressRange(0, 1);
|
||||||
@@ -158,16 +151,17 @@ public:
|
|||||||
&m_process, &QtcProcess::kill);
|
&m_process, &QtcProcess::kill);
|
||||||
connect(&m_process, &QProcess::readyRead,
|
connect(&m_process, &QProcess::readyRead,
|
||||||
this, &GitGrepRunner::read);
|
this, &GitGrepRunner::read);
|
||||||
connect(&m_process, static_cast<void(QProcess::*)(int)>(&QProcess::finished),
|
|
||||||
this, &GitGrepRunner::finish);
|
|
||||||
QEventLoop eventLoop;
|
|
||||||
connect(&watcher, &QFutureWatcher<FileSearchResultList>::finished,
|
|
||||||
&eventLoop, &QEventLoop::quit);
|
|
||||||
m_process.start();
|
m_process.start();
|
||||||
if (!m_process.waitForStarted())
|
if (!m_process.waitForStarted())
|
||||||
return;
|
return;
|
||||||
m_fi.reportStarted();
|
QEventLoop eventLoop;
|
||||||
|
connect(&m_process, static_cast<void(QProcess::*)(int)>(&QProcess::finished),
|
||||||
|
this, [this, &eventLoop]() {
|
||||||
|
read();
|
||||||
|
eventLoop.quit();
|
||||||
|
});
|
||||||
eventLoop.exec();
|
eventLoop.exec();
|
||||||
|
m_fi.setProgressValue(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void run(QFutureInterface<FileSearchResultList> &fi,
|
static void run(QFutureInterface<FileSearchResultList> &fi,
|
||||||
|
|||||||
Reference in New Issue
Block a user