Skip to content
Snippets Groups Projects

fix: issue while disconnecting the app

Merged Burak Hançerli requested to merge QDS-11468/direct-ds-connection into master
6 files
+ 80
164
Compare changes
  • Side-by-side
  • Inline
Files
6
+ 40
78
@@ -46,6 +46,12 @@ Backend::Backend(QObject *parent)
@@ -46,6 +46,12 @@ Backend::Backend(QObject *parent)
// This will allow us to open the app with the QR code
// This will allow us to open the app with the QR code
QDesktopServices::setUrlHandler("qtdesignviewer", this, "parseDesignViewerUrl");
QDesktopServices::setUrlHandler("qtdesignviewer", this, "parseDesignViewerUrl");
QDesktopServices::setUrlHandler("https", this, "parseDesignViewerUrl");
QDesktopServices::setUrlHandler("https", this, "parseDesignViewerUrl");
 
connect(&m_dsConnectorThread,
 
&QThread::started,
 
this,
 
&Backend::initDesignStudioConnector,
 
Qt::DirectConnection);
 
m_dsConnectorThread.start();
}
}
void Backend::initialize()
void Backend::initialize()
@@ -198,91 +204,47 @@ void Backend::initializeProjectManager()
@@ -198,91 +204,47 @@ void Backend::initializeProjectManager()
&Backend::downloadProgress);
&Backend::downloadProgress);
}
}
bool Backend::connectDesignStudio()
void Backend::initDesignStudioConnector()
{
{
if (m_designStudioConnector) {
m_designStudioConnector.reset(new 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_dsConnectorThread.start();
connect(m_designStudioConnector.data(),
 
&DesignStudioConnector::networkStatusUpdated,
 
this,
 
&Backend::networkUpdated);
qDebug() << "Design Studio Connector is initialized";
connect(m_designStudioConnector.data(),
return true;
&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()
qDebug() << "Project unpacked to " << projectPath;
{
updatePopup("Running project...");
if (!m_designStudioConnector) {
qDebug() << "Design Studio Connector is not initialized";
return;
}
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(
emit popupClose();
&m_dsConnectorThread,
});
&QThread::finished,
this,
[&] {
qDebug() << "Design Studio Connector is disconnected";
m_designStudioConnector.reset();
},
Qt::DirectConnection);
m_dsConnectorThread.quit();
qDebug() << "Design Studio Connector is initialized";
m_dsConnectorThread.wait();
}
}
void Backend::runDemoProject(const QString &projectName)
void Backend::runDemoProject(const QString &projectName)
Loading