Commit 1e7a77c1e33718a8449395bc5ebbe03333585be9

  • Tree SHA1: d1fb005
  • Parent SHA1: d1329df (add support for manual stop and start of the application from the scripts; currently crashes if you try it, but works fine with previous usage)
  • raw diff | raw patch
Only allow the most recent spawn to be closed
  
119119
120120void Interpreter::connectRemoteApplication(RemoteApplicationPrototype* object)
121121{
122 m_applicationUuid = object->uuid();
123 qDebug() << Q_FUNC_INFO << "Launching" << object->uuid();
122124 if(object->useDefaults())
123125 {
124126 emit startApplicationAndAttach();
139139
140140void Interpreter::closeApplication()
141141{
142 qDebug() << Q_FUNC_INFO;
142 RemoteApplicationPrototype* object = qobject_cast<RemoteApplicationPrototype*>(sender());
143 if(object)
144 {
145 if(object->uuid() != m_applicationUuid)
146 {
147 qDebug() << Q_FUNC_INFO << "Ignoring request. Current UUID:" << m_applicationUuid << "Requested UUID:" << object->uuid();
148 return;
149 }
150 }
143151 if(device())
144152 {
153 qDebug() << Q_FUNC_INFO << "Closing UUID" << m_applicationUuid;
145154 writeEndElement(); // hooq
146155 writeEndDocument();
147156
159159 waitForAck();
160160 m_attachState = NotAttached;
161161 setDevice(0);
162 m_applicationUuid = QString();
162163 }
163164}
164165
536536
537537void Interpreter::run()
538538{
539 m_applicationUuid = QString();
539540 qDebug() << Q_FUNC_INFO;
540541 m_attachState = NotAttached;
541542 m_engine->evaluate(m_script, m_scriptPath);
543 m_engine->collectGarbage();
542544 closeApplication();
543545 emit finished();
544546}
  
9595 AttachState m_attachState;
9696 void waitForAttach();
9797 void ensureAttached();
98 QString m_applicationUuid;
9899
99100 bool m_haveRequiredQtScriptExtensions;
100101 QScriptEngine* m_engine;
  
1818*/
1919#include "RemoteApplicationPrototype.h"
2020
21#include <QUuid>
22
2123RemoteApplicationPrototype::RemoteApplicationPrototype(QObject* parent)
2224: QObject(parent)
2325, m_closed(false)
26, m_uuid(QUuid::createUuid())
2427{
2528}
2629
30QString RemoteApplicationPrototype::uuid() const
31{
32 return m_uuid;
33}
34
2735RemoteApplicationPrototype::RemoteApplicationPrototype(const QString& path, const QStringList& arguments, QObject* parent)
2836: QObject(parent)
2937, m_closed(false)
38, m_uuid(QUuid::createUuid())
3039, m_path(path)
3140, m_arguments(arguments)
3241{
  
3232 bool useDefaults() const;
3333 QString path() const;
3434 QStringList arguments() const;
35
36 QString uuid() const;
3537 public slots:
3638 void close();
3739 signals:
3840 void closeRequested();
3941 private:
4042 bool m_closed;
43 QString m_uuid;
4144 QString m_path;
4245 QStringList m_arguments;
4346};