Skip to content
Snippets Groups Projects
Verified Commit 293d15c3 authored by Burak Hançerli's avatar Burak Hançerli :headphones:
Browse files

fix: skip stopping notification from the previous session

parent e37dfbf7
No related branches found
No related tags found
1 merge request!65QDS-14287 Support interruptable operations
Pipeline #78276 failed
......@@ -138,12 +138,21 @@ void Backend::initProjectManager()
{
m_projectManager.reset(new ProjectManager(this));
connect(m_projectManager.get(), &ProjectManager::closingProject, this, [this] {
QMetaObject::invokeMethod(m_dsManager.get(),
"sendProjectStopped",
Qt::QueuedConnection,
Q_ARG(QString, m_lastProjectSenderId));
});
connect(m_projectManager.get(),
&ProjectManager::closingProject,
this,
[this](const QString &sessionId) {
// most likely the project was running from the leftover session
// (DS connected, project started, DS disconnected without stopping the project)
// so we'll stop the project and do not send any signals to the DS
if (sessionId != m_lastSessionId)
return;
QMetaObject::invokeMethod(m_dsManager.get(),
"sendProjectStopped",
Qt::QueuedConnection,
Q_ARG(QString, m_lastProjectSenderId));
});
}
void Backend::initDsManager()
......@@ -178,11 +187,13 @@ void Backend::initDsManager()
[this](const QString &id, const int projectSize) {
qDebug() << "Project incoming with size" << projectSize;
emit updatePopupText("Receiving project...");
// we'll use this to notify the correct DS when the project started/stopped
m_lastProjectSenderId = id;
m_lastSessionId = QUuid::createUuid().toString(QUuid::WithoutBraces);
QMetaObject::invokeMethod(m_projectManager.get(),
"stopProject",
Qt::QueuedConnection);
// we'll use this to notify the correct DS when the project started/stopped
m_lastProjectSenderId = id;
});
connect(m_dsManager.get(),
......@@ -228,7 +239,8 @@ void Backend::runProject(const QString &id, const QByteArray &projectData)
"runProject",
Q_RETURN_ARG(bool, retVal),
Q_ARG(QByteArray, projectData),
Q_ARG(bool, autoScaleProject()));
Q_ARG(bool, autoScaleProject()),
Q_ARG(QString, m_lastSessionId));
if (!retVal)
QMetaObject::invokeMethod(m_dsManager.get(), "sendProjectStopped", Q_ARG(QString, id));
......
......@@ -51,6 +51,7 @@ private:
QScopedPointer<QrScanner> m_qrScanner;
QString m_lastProjectSenderId;
QString m_lastSessionId;
// Settings
Settings m_settings;
......
......@@ -198,6 +198,8 @@ void DesignStudio::processTextMessage(const QString &message)
} else if (dataType == PackageFromDesignStudio::stopRunningProject) {
qDebug() << "Stop running project requested";
m_projectData.clear();
m_speedCalculator.stop();
m_projectStallTimer.stop();
emit projectStopRequested(m_designStudioID);
} else {
qDebug() << "Unkown JSON message type:" << dataType;
......
......@@ -198,9 +198,12 @@ bool ProjectManager::isQt6Project(const QString &qmlProjectFileContent)
return qt6ProjectMatch.hasMatch();
}
bool ProjectManager::runProject(const QByteArray &project, const bool autoScaleProject)
bool ProjectManager::runProject(const QByteArray &project,
const bool autoScaleProject,
const QString &sessionId)
{
m_autoScaleProject = autoScaleProject;
m_sessionId = sessionId;
const QString projectPath = unpackProject(project);
qDebug() << "Project location: " << projectPath;
......@@ -361,7 +364,7 @@ void ProjectManager::showAppWindow()
disconnect(screen, &QScreen::orientationChanged, this, &ProjectManager::orientateWindow);
// this signal is connected to the lambda in the backend
// which will reset the project manager
emit closingProject();
emit closingProject(m_sessionId);
});
m_quickWindow->setFlags(Qt::Window | Qt::WindowStaysOnTopHint);
......@@ -373,6 +376,7 @@ void ProjectManager::stopProject()
if (!m_quickWindow || !m_quickWindow->isVisible())
return;
m_sessionId.clear();
qDebug("Stopping the QML app window");
m_quickWindow->close();
}
......
......@@ -37,13 +37,16 @@ public:
bool isRunning();
public slots:
bool runProject(const QByteArray &project, const bool autoScaleProject);
bool runProject(const QByteArray &project,
const bool autoScaleProject,
const QString &sessionId);
void stopProject();
private:
// Member variables
QByteArray m_projectData;
QString m_projectPath;
QString m_sessionId;
bool m_autoScaleProject;
// Qml related members
......@@ -70,5 +73,5 @@ private:
void showAppWindow();
signals:
void closingProject();
void closingProject(const QString &sessionId);
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment