Skip to content
Snippets Groups Projects

fix: issue while disconnecting the app

Merged Burak Hançerli requested to merge QDS-11655/implement-drawer-menu into master
6 files
+ 80
164
Compare changes
  • Side-by-side
  • Inline
Files
6
+ 40
78
@@ -46,6 +46,12 @@ Backend::Backend(QObject *parent)
// This will allow us to open the app with the QR code
QDesktopServices::setUrlHandler("qtdesignviewer", this, "parseDesignViewerUrl");
QDesktopServices::setUrlHandler("https", this, "parseDesignViewerUrl");
connect(&m_dsConnectorThread,
&QThread::started,
this,
&Backend::initDesignStudioConnector,
Qt::DirectConnection);
m_dsConnectorThread.start();
}
void Backend::initialize()
@@ -198,91 +204,47 @@ void Backend::initializeProjectManager()
&Backend::downloadProgress);
}
bool Backend::connectDesignStudio()
void Backend::initDesignStudioConnector()
{
if (m_designStudioConnector) {
qDebug() << "Design Studio Connector is already initialized";
return true;
}
qDebug() << "Initializing Design Studio Connector";
connect(
&m_dsConnectorThread,
&QThread::started,
this,
[&] {
m_designStudioConnector.reset(new DesignStudioConnector);
connect(m_designStudioConnector.data(),
&DesignStudioConnector::networkStatusUpdated,
this,
&Backend::networkUpdated);
connect(m_designStudioConnector.data(),
&DesignStudioConnector::projectReceived,
this,
[this](const QByteArray &projectData) {
qDebug() << "Project received from Design Studio";
initializeProjectManager();
emit popupOpen();
updatePopup("Unpacking project...");
qDebug() << "Project data size: " << projectData.size();
const QString projectPath = m_projectManager->unpackProject(projectData);
if (projectPath.isEmpty()) {
qCritical()
<< "Could not unpack project. Please check the logs for more "
"information.";
emit popupClose();
return;
}
qDebug() << "Project unpacked to " << projectPath;
updatePopup("Running project...");
if (!m_projectManager->runProject(projectPath)) {
qCritical() << "Could not run project. Please check the logs for more "
"information.";
} else {
m_projectManager->showAppWindow();
}
emit popupClose();
});
if (!m_designStudioConnector->initialize()) {
qCritical()
<< "Could initialize server. Please check the logs for more information.";
m_designStudioConnector.reset();
}
},
Qt::DirectConnection);
m_designStudioConnector.reset(new DesignStudioConnector);
m_dsConnectorThread.start();
connect(m_designStudioConnector.data(),
&DesignStudioConnector::networkStatusUpdated,
this,
&Backend::networkUpdated);
qDebug() << "Design Studio Connector is initialized";
return true;
}
connect(m_designStudioConnector.data(),
&DesignStudioConnector::projectReceived,
this,
[this](const QByteArray &projectData) {
qDebug() << "Project received from Design Studio";
initializeProjectManager();
emit popupOpen();
updatePopup("Unpacking project...");
qDebug() << "Project data size: " << projectData.size();
const QString projectPath = m_projectManager->unpackProject(projectData);
if (projectPath.isEmpty()) {
qCritical() << "Could not unpack project. Please check the logs for more "
"information.";
emit popupClose();
return;
}
void Backend::disconnectDesignStudio()
{
if (!m_designStudioConnector) {
qDebug() << "Design Studio Connector is not initialized";
return;
}
qDebug() << "Project unpacked to " << projectPath;
updatePopup("Running project...");
qDebug() << "Disconnecting from Design Studio";
if (!m_projectManager->runProject(projectPath)) {
qCritical() << "Could not run project. Please check the logs for more "
"information.";
} else {
m_projectManager->showAppWindow();
}
connect(
&m_dsConnectorThread,
&QThread::finished,
this,
[&] {
qDebug() << "Design Studio Connector is disconnected";
m_designStudioConnector.reset();
},
Qt::DirectConnection);
emit popupClose();
});
m_dsConnectorThread.quit();
m_dsConnectorThread.wait();
qDebug() << "Design Studio Connector is initialized";
}
void Backend::runDemoProject(const QString &projectName)
Loading