Ios: Fix crash when connecting user-mode device

The modal dialog was opened directly from the tool output processing,
and when returning the tool handler was already deleted.

Change-Id: Iacba584b59bf8720788ac03fd2e839c5e4485ab3
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@digia.com>
This commit is contained in:
Eike Ziller
2013-10-08 15:27:45 +02:00
parent c65c650cc2
commit 171fd691c3
4 changed files with 21 additions and 8 deletions

View File

@@ -269,7 +269,7 @@ void IosDeviceManager::updateInfo(const QString &devId)
{
IosToolHandler *requester = new IosToolHandler(IosToolHandler::IosDeviceType, this);
connect(requester, SIGNAL(deviceInfo(Ios::IosToolHandler*,QString,Ios::IosToolHandler::Dict)),
SLOT(deviceInfo(Ios::IosToolHandler *,QString,Ios::IosToolHandler::Dict)));
SLOT(deviceInfo(Ios::IosToolHandler *,QString,Ios::IosToolHandler::Dict)), Qt::QueuedConnection);
connect(requester, SIGNAL(finished(Ios::IosToolHandler*)),
SLOT(infoGathererFinished(Ios::IosToolHandler*)));
requester->requestDeviceInfo(devId);

View File

@@ -38,6 +38,7 @@
#include "iosmanager.h"
#include "iosrunfactories.h"
#include "iossettingspage.h"
#include "iostoolhandler.h"
#include "iosqtversionfactory.h"
#include "iosbuildstep.h"
#include "iosdeploystepfactory.h"
@@ -52,7 +53,9 @@
namespace Ios {
IosPlugin::IosPlugin()
{ }
{
qRegisterMetaType<Ios::IosToolHandler::Dict>("Ios::IosToolHandler::Dict");
}
bool IosPlugin::initialize(const QStringList &arguments, QString *errorMessage)
{

View File

@@ -61,7 +61,7 @@ class MyProcess: public QProcess
Q_OBJECT
public:
explicit MyProcess(QObject *parent = 0);
int processOutput();
int processOutputSocket();
QSocketNotifier *notifier();
protected:
virtual void setupChildProcess();
@@ -136,6 +136,7 @@ public:
};
explicit IosToolHandlerPrivate(IosToolHandler::DeviceType devType, IosToolHandler *q);
virtual ~IosToolHandlerPrivate() {}
virtual void requestTransferApp(const QString &bundlePath, const QString &deviceId,
int timeout = 1000) = 0;
virtual void requestRunApp(const QString &bundlePath, const QStringList &extraArgs,
@@ -221,7 +222,7 @@ MyProcess::MyProcess(QObject *parent) : QProcess(parent)
m_notifier = new QSocketNotifier(m_sockets[0], QSocketNotifier::Read, this);
}
int MyProcess::processOutput()
int MyProcess::processOutputSocket()
{
return m_sockets[0];
}
@@ -251,8 +252,8 @@ IosToolHandlerPrivate::IosToolHandlerPrivate(IosToolHandler::DeviceType devType,
q, SLOT(subprocessFinished(int,QProcess::ExitStatus)));
QObject::connect(&process, SIGNAL(error(QProcess::ProcessError)),
q, SLOT(subprocessError(QProcess::ProcessError)));
int accessFlags = fcntl(process.processOutput(), F_GETFL);
if (fcntl(process.processOutput(), F_SETFL, accessFlags | O_NONBLOCK) == -1)
int accessFlags = fcntl(process.processOutputSocket(), F_GETFL);
if (fcntl(process.processOutputSocket(), F_SETFL, accessFlags | O_NONBLOCK) == -1)
qDebug() << "IosToolHandler fcntl F_SETFL failed to set non blocking mode"
<< qt_error_string(errno);
}
@@ -277,9 +278,11 @@ void IosToolHandlerPrivate::stop()
if (debugToolHandler)
qDebug() << "IosToolHandlerPrivate::stop";
if (process.state() != QProcess::NotRunning) {
close(process.processOutput());
close(process.processOutputSocket());
process.close();
process.kill();
if (debugToolHandler)
qDebug() << "killing";
}
if (state != Stopped) {
state = Stopped;
@@ -374,7 +377,7 @@ void IosToolHandlerPrivate::subprocessError(QProcess::ProcessError error)
void IosToolHandlerPrivate::subprocessFinished(int exitCode, QProcess::ExitStatus exitStatus)
{
// process potentially pending data
subprocessHasData(process.processOutput());
subprocessHasData(process.processOutputSocket());
switch (state) {
case NonStarted:
qDebug() << "subprocessFinished() when state was NonStarted";
@@ -944,6 +947,11 @@ IosToolHandler::IosToolHandler(DeviceType devType, QObject *parent) :
d = new Internal::IosSimulatorToolHandlerPrivate(devType, this);
}
IosToolHandler::~IosToolHandler()
{
delete d;
}
void IosToolHandler::stop()
{
d->stop();

View File

@@ -67,7 +67,9 @@ public:
static QString iosDeviceToolPath();
static QString iosSimulatorToolPath();
explicit IosToolHandler(DeviceType = IosDeviceType, QObject *parent = 0);
~IosToolHandler();
void requestTransferApp(const QString &bundlePath, const QString &deviceId, int timeout = 1000);
void requestRunApp(const QString &bundlePath, const QStringList &extraArgs, RunKind runType,
const QString &deviceId, int timeout = 1000);