forked from qt-creator/qt-creator
iOS: Fixes a random crash in Qt creator while closing
The Qt creator crashed randomly while closing. Fixed the iostool process termination Task-number: QTCREATORBUG-14862 Change-Id: Ib356020095fe23f277389ebe30d8dedf4380ec28 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -123,7 +123,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
explicit IosToolHandlerPrivate(const IosDeviceType &devType, IosToolHandler *q);
|
explicit IosToolHandlerPrivate(const IosDeviceType &devType, IosToolHandler *q);
|
||||||
virtual ~IosToolHandlerPrivate() {}
|
virtual ~IosToolHandlerPrivate();
|
||||||
virtual void requestTransferApp(const QString &bundlePath, const QString &deviceId,
|
virtual void requestTransferApp(const QString &bundlePath, const QString &deviceId,
|
||||||
int timeout = 1000) = 0;
|
int timeout = 1000) = 0;
|
||||||
virtual void requestRunApp(const QString &bundlePath, const QStringList &extraArgs,
|
virtual void requestRunApp(const QString &bundlePath, const QStringList &extraArgs,
|
||||||
@@ -158,7 +158,7 @@ protected:
|
|||||||
void processXml();
|
void processXml();
|
||||||
|
|
||||||
IosToolHandler *q;
|
IosToolHandler *q;
|
||||||
QProcess process;
|
QProcess *process;
|
||||||
QTimer killTimer;
|
QTimer killTimer;
|
||||||
QXmlStreamReader outputParser;
|
QXmlStreamReader outputParser;
|
||||||
QString deviceId;
|
QString deviceId;
|
||||||
@@ -202,7 +202,12 @@ private:
|
|||||||
|
|
||||||
IosToolHandlerPrivate::IosToolHandlerPrivate(const IosDeviceType &devType,
|
IosToolHandlerPrivate::IosToolHandlerPrivate(const IosDeviceType &devType,
|
||||||
Ios::IosToolHandler *q) :
|
Ios::IosToolHandler *q) :
|
||||||
q(q), state(NonStarted), devType(devType), iBegin(0), iEnd(0),
|
q(q),
|
||||||
|
process(new QProcess),
|
||||||
|
state(NonStarted),
|
||||||
|
devType(devType),
|
||||||
|
iBegin(0),
|
||||||
|
iEnd(0),
|
||||||
gdbSocket(-1)
|
gdbSocket(-1)
|
||||||
{
|
{
|
||||||
killTimer.setSingleShot(true);
|
killTimer.setSingleShot(true);
|
||||||
@@ -225,22 +230,32 @@ IosToolHandlerPrivate::IosToolHandlerPrivate(const IosDeviceType &devType,
|
|||||||
<< QLatin1String("/System/Library/PrivateFrameworks");
|
<< QLatin1String("/System/Library/PrivateFrameworks");
|
||||||
env.insert(QLatin1String("DYLD_FALLBACK_FRAMEWORK_PATH"), frameworkPaths.join(QLatin1Char(':')));
|
env.insert(QLatin1String("DYLD_FALLBACK_FRAMEWORK_PATH"), frameworkPaths.join(QLatin1Char(':')));
|
||||||
qCDebug(toolHandlerLog) << "IosToolHandler runEnv:" << env.toStringList();
|
qCDebug(toolHandlerLog) << "IosToolHandler runEnv:" << env.toStringList();
|
||||||
process.setProcessEnvironment(env);
|
process->setProcessEnvironment(env);
|
||||||
QObject::connect(&process, &QProcess::readyReadStandardOutput,
|
QObject::connect(process, &QProcess::readyReadStandardOutput,
|
||||||
q, &IosToolHandler::subprocessHasData);
|
q, &IosToolHandler::subprocessHasData);
|
||||||
QObject::connect(&process,
|
QObject::connect(process,
|
||||||
static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished),
|
static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished),
|
||||||
q, &IosToolHandler::subprocessFinished);
|
q, &IosToolHandler::subprocessFinished);
|
||||||
QObject::connect(&process,
|
QObject::connect(process,
|
||||||
static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error),
|
static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error),
|
||||||
q, &IosToolHandler::subprocessError);
|
q, &IosToolHandler::subprocessError);
|
||||||
QObject::connect(&killTimer, &QTimer::timeout,
|
QObject::connect(&killTimer, &QTimer::timeout,
|
||||||
q, &IosToolHandler::killProcess);
|
q, &IosToolHandler::killProcess);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IosToolHandlerPrivate::~IosToolHandlerPrivate()
|
||||||
|
{
|
||||||
|
if (isRunning()) {
|
||||||
|
process->terminate();
|
||||||
|
if (!process->waitForFinished(1000))
|
||||||
|
process->kill();
|
||||||
|
}
|
||||||
|
delete process;
|
||||||
|
}
|
||||||
|
|
||||||
bool IosToolHandlerPrivate::isRunning()
|
bool IosToolHandlerPrivate::isRunning()
|
||||||
{
|
{
|
||||||
return process.state() != QProcess::NotRunning;
|
return process && (process->state() != QProcess::NotRunning);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IosToolHandlerPrivate::start(const QString &exe, const QStringList &args)
|
void IosToolHandlerPrivate::start(const QString &exe, const QStringList &args)
|
||||||
@@ -248,7 +263,7 @@ void IosToolHandlerPrivate::start(const QString &exe, const QStringList &args)
|
|||||||
QTC_CHECK(state == NonStarted);
|
QTC_CHECK(state == NonStarted);
|
||||||
state = Starting;
|
state = Starting;
|
||||||
qCDebug(toolHandlerLog) << "running " << exe << args;
|
qCDebug(toolHandlerLog) << "running " << exe << args;
|
||||||
process.start(exe, args);
|
process->start(exe, args);
|
||||||
state = StartedInferior;
|
state = StartedInferior;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -283,9 +298,9 @@ void IosToolHandlerPrivate::stop(int errorCode)
|
|||||||
case Stopped:
|
case Stopped:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (process.state() != QProcess::NotRunning) {
|
if (isRunning()) {
|
||||||
process.write("k\n\r");
|
process->write("k\n\r");
|
||||||
process.closeWriteChannel();
|
process->closeWriteChannel();
|
||||||
killTimer.start(1500);
|
killTimer.start(1500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -556,8 +571,8 @@ void IosToolHandlerPrivate::subprocessHasData()
|
|||||||
// read some data
|
// read some data
|
||||||
{
|
{
|
||||||
char buf[200];
|
char buf[200];
|
||||||
while (true) {
|
while (isRunning()) {
|
||||||
qint64 rRead = process.read(buf, sizeof(buf));
|
qint64 rRead = process->read(buf, sizeof(buf));
|
||||||
if (rRead == -1) {
|
if (rRead == -1) {
|
||||||
stop(-1);
|
stop(-1);
|
||||||
return;
|
return;
|
||||||
@@ -706,8 +721,8 @@ void IosSimulatorToolHandlerPrivate::addDeviceArguments(QStringList &args) const
|
|||||||
|
|
||||||
void IosToolHandlerPrivate::killProcess()
|
void IosToolHandlerPrivate::killProcess()
|
||||||
{
|
{
|
||||||
if (process.state() != QProcess::NotRunning)
|
if (isRunning())
|
||||||
process.kill();
|
process->kill();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
Reference in New Issue
Block a user