forked from qt-creator/qt-creator
Android: Don't crash when dis- and reconnecting phone via USB
When ADB signals a change about the list of connected devices, the whole build/run steps tree gets deleted and recreated. The AndroidBuildApkStep is a part of that tree and starts one or more "keytool" processes on creation/init. They were started with their own event loop. Those synthetic event loops caused a change in order of deletion which led to crashes with obscure backtraces. This change removes the event loop creation from "keytool" calls. The crash is avoided. The calls take ~0.5 seconds. The short UI freeze should be an acceptable hotfix trade-off for a crash in QtC13. If 0.5 seconds freeze seem too much, a better fix could be done in QtC 14. Fixes: QTCREATORBUG-30645 Fixes: QTCREATORBUG-30770 Change-Id: I8842dc87023142ae75572bf255c7f1ec808d9bab Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -1002,7 +1002,7 @@ QAbstractItemModel *AndroidBuildApkStep::keystoreCertificates()
|
|||||||
Process keytoolProc;
|
Process keytoolProc;
|
||||||
keytoolProc.setCommand({androidConfig().keytoolPath(), params});
|
keytoolProc.setCommand({androidConfig().keytoolPath(), params});
|
||||||
using namespace std::chrono_literals;
|
using namespace std::chrono_literals;
|
||||||
keytoolProc.runBlocking(30s, EventLoopMode::On);
|
keytoolProc.runBlocking(30s);
|
||||||
if (keytoolProc.result() > ProcessResult::FinishedWithError)
|
if (keytoolProc.result() > ProcessResult::FinishedWithError)
|
||||||
QMessageBox::critical(nullptr, Tr::tr("Error"), Tr::tr("Failed to run keytool."));
|
QMessageBox::critical(nullptr, Tr::tr("Error"), Tr::tr("Failed to run keytool."));
|
||||||
else
|
else
|
||||||
|
@@ -275,7 +275,7 @@ void AndroidCreateKeystoreCertificate::buttonBoxAccepted()
|
|||||||
Process genKeyCertProc;
|
Process genKeyCertProc;
|
||||||
genKeyCertProc.setCommand(command);
|
genKeyCertProc.setCommand(command);
|
||||||
using namespace std::chrono_literals;
|
using namespace std::chrono_literals;
|
||||||
genKeyCertProc.runBlocking(15s, EventLoopMode::On);
|
genKeyCertProc.runBlocking(15s);
|
||||||
|
|
||||||
if (genKeyCertProc.result() != ProcessResult::FinishedWithSuccess) {
|
if (genKeyCertProc.result() != ProcessResult::FinishedWithSuccess) {
|
||||||
QMessageBox::critical(this, Tr::tr("Error"),
|
QMessageBox::critical(this, Tr::tr("Error"),
|
||||||
|
@@ -614,7 +614,7 @@ bool checkKeystorePassword(const FilePath &keystorePath, const QString &keystore
|
|||||||
"--storepass", keystorePasswd});
|
"--storepass", keystorePasswd});
|
||||||
Process proc;
|
Process proc;
|
||||||
proc.setCommand(cmd);
|
proc.setCommand(cmd);
|
||||||
proc.runBlocking(10s, EventLoopMode::On);
|
proc.runBlocking(10s);
|
||||||
return proc.result() == ProcessResult::FinishedWithSuccess;
|
return proc.result() == ProcessResult::FinishedWithSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -631,7 +631,7 @@ bool checkCertificatePassword(const FilePath &keystorePath, const QString &keyst
|
|||||||
|
|
||||||
Process proc;
|
Process proc;
|
||||||
proc.setCommand({androidConfig().keytoolPath(), arguments});
|
proc.setCommand({androidConfig().keytoolPath(), arguments});
|
||||||
proc.runBlocking(10s, EventLoopMode::On);
|
proc.runBlocking(10s);
|
||||||
return proc.result() == ProcessResult::FinishedWithSuccess;
|
return proc.result() == ProcessResult::FinishedWithSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -644,7 +644,7 @@ bool checkCertificateExists(const FilePath &keystorePath, const QString &keystor
|
|||||||
|
|
||||||
Process proc;
|
Process proc;
|
||||||
proc.setCommand({androidConfig().keytoolPath(), arguments});
|
proc.setCommand({androidConfig().keytoolPath(), arguments});
|
||||||
proc.runBlocking(10s, EventLoopMode::On);
|
proc.runBlocking(10s);
|
||||||
return proc.result() == ProcessResult::FinishedWithSuccess;
|
return proc.result() == ProcessResult::FinishedWithSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user