Commit a30d696c authored by con's avatar con
Browse files

Don't block, and be able to terminate remote application.

parent 124f2e9f
......@@ -411,7 +411,7 @@ RunControl* S60DeviceRunConfigurationRunner::run(QSharedPointer<RunConfiguration
// ======== S60DeviceRunControl
S60DeviceRunControl::S60DeviceRunControl(QSharedPointer<RunConfiguration> runConfiguration)
: RunControl(runConfiguration)
: RunControl(runConfiguration), m_adapter(0)
{
m_makesis = new QProcess(this);
connect(m_makesis, SIGNAL(readyReadStandardError()),
......@@ -471,7 +471,7 @@ void S60DeviceRunControl::stop()
{
m_makesis->kill();
m_signsis->kill();
//m_adapter->terminate();
m_adapter->terminate();
}
bool S60DeviceRunControl::isRunning() const
......@@ -533,7 +533,6 @@ void S60DeviceRunControl::signsisProcessFinished()
emit finished();
return;
}
//TODO
m_adapter = new trk::Adapter;
connect(m_adapter, SIGNAL(finished()), this, SLOT(runFinished()));
//TODO com selection, sisx destination and file path user definable
......@@ -549,6 +548,8 @@ void S60DeviceRunControl::signsisProcessFinished()
void S60DeviceRunControl::runFinished()
{
m_adapter->deleteLater();
m_adapter = 0;
emit addToOutputWindow(this, tr("Finished."));
emit finished();
}
......
......@@ -40,10 +40,14 @@ BOOL WINAPI TryReadFile(HANDLE hFile,
LPOVERLAPPED lpOverlapped)
{
COMSTAT comStat;
if(!ClearCommError(hFile, NULL, &comStat)){
if (!ClearCommError(hFile, NULL, &comStat)){
qDebug() << "ClearCommError() failed";
return FALSE;
}
if (comStat.cbInQue == 0) {
*lpNumberOfBytesRead = 0;
return FALSE;
}
return ReadFile(hFile,
lpBuffer,
qMin(comStat.cbInQue, nNumberOfBytesToRead),
......@@ -66,7 +70,6 @@ Adapter::Adapter()
#endif
m_trkWriteToken = 0;
m_trkWriteBusy = false;
startTimer(100);
}
Adapter::~Adapter()
......@@ -88,6 +91,7 @@ bool Adapter::startServer()
qDebug("Unable to connect to TRK server");
return false;
}
m_timerId = startTimer(100);
qDebug("Connecting");
sendTrkInitialPing();
sendTrkMessage(TrkConnect); // Connect
......@@ -197,6 +201,14 @@ void Adapter::waitForTrkFinished(const TrkResult &result)
sendTrkMessage(TrkPing, CB(handleWaitForFinished));
}
void Adapter::terminate()
{
QByteArray ba;
appendShort(&ba, 0x0000, TargetByteOrder);
appendInt(&ba, m_session.pid, TargetByteOrder);
sendTrkMessage(TrkDeleteItem, CB(waitForTrkFinished), ba);
}
void Adapter::sendTrkAck(byte token)
{
logMessage(QString("SENDING ACKNOWLEDGEMENT FOR TOKEN %1").arg(int(token)));
......@@ -262,6 +274,9 @@ void Adapter::tryTrkRead()
if (isValidTrkResult(m_trkReadQueue))
break;
}
if (charsRead == 0 && m_trkReadQueue.isEmpty()) {
return;
}
#else // USE_NATIVE
if (m_trkDevice->bytesAvailable() == 0 && m_trkReadQueue.isEmpty()) {
return;
......@@ -475,6 +490,7 @@ void Adapter::handleCreateProcess(const TrkResult &result)
void Adapter::handleWaitForFinished(const TrkResult &result)
{
logMessage(" FINISHED: " + stringFromArray(result.data));
killTimer(m_timerId);
emit finished();
}
......
......@@ -64,6 +64,9 @@ public:
signals:
void finished();
public slots:
void terminate();
private:
//
// TRK
......@@ -137,6 +140,7 @@ private:
// Debuggee state
Session m_session; // global-ish data (process id, target information)
int m_timerId;
QString m_fileName;
QString m_copySrcFileName;
QString m_copyDstFileName;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment