Skip to content
Snippets Groups Projects

QDS-11411 Material Bundle crashes

Merged Burak Hançerli requested to merge QDS-11411/clear-projectmanager into master
5 files
+ 50
20
Compare changes
  • Side-by-side
  • Inline
Files
5
+ 41
17
@@ -74,11 +74,10 @@ void Backend::initialize()
updateUserProjectList();
}
connect(&m_serviceConnector, &ServiceConnector::downloadProgress, this, &Backend::downloadProgress);
connect(&m_projectManager,
&ProjectManager::projectStateChanged,
connect(&m_serviceConnector,
&ServiceConnector::downloadProgress,
this,
&Backend::popupTextChanged);
&Backend::downloadProgress);
qDebug("Initialization complete");
}
@@ -90,6 +89,26 @@ void Backend::updatePopup(const QString &text, bool indeterminate)
QEventLoop().processEvents(QEventLoop::AllEvents, 100);
}
void Backend::initializeProjectManager()
{
if (m_projectManager)
return;
qDebug() << "Initializing Project Manager";
m_projectManager.reset(new ProjectManager);
connect(m_projectManager.data(),
&ProjectManager::projectStateChanged,
this,
&Backend::popupTextChanged);
connect(m_projectManager.data(), &ProjectManager::closingProject, this, [&] {
emit popupClose();
qDebug() << "Project Manager is closing";
m_projectManager.reset();
});
qDebug() << "Project Manager is initialized";
}
bool Backend::connectDesignStudio()
{
if (m_designStudioConnector) {
@@ -112,13 +131,14 @@ bool Backend::connectDesignStudio()
connect(m_designStudioConnector.data(),
&DesignStudioConnector::projectReceived,
&m_projectManager,
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);
const QString projectPath = m_projectManager->unpackProject(projectData);
if (projectPath.isEmpty()) {
qCritical()
@@ -131,11 +151,11 @@ bool Backend::connectDesignStudio()
qDebug() << "Project unpacked to " << projectPath;
updatePopup("Running project...");
if (!m_projectManager.runProject(projectPath)) {
if (!m_projectManager->runProject(projectPath)) {
qCritical() << "Could not run project. Please check the logs for more "
"information.";
} else {
m_projectManager.showAppWindow();
m_projectManager->showAppWindow();
}
emit popupClose();
});
@@ -178,10 +198,11 @@ void Backend::disconnectDesignStudio()
void Backend::runDemoProject(const QString &projectName)
{
initializeProjectManager();
qDebug() << "Checking if demo project is cached for " << projectName;
emit popupOpen();
const bool cached = m_projectManager.isDemoProjectCached(projectName);
const bool cached = m_projectManager->isDemoProjectCached(projectName);
if (!cached) {
updatePopup("Downloading demo project...", false);
@@ -191,7 +212,7 @@ void Backend::runDemoProject(const QString &projectName)
qDebug() << "Demo project is not cached. Trying to download from " << url << " ...";
updatePopup("Caching demo project...");
if (!m_projectManager.cacheDemoProject(project, projectName)) {
if (!m_projectManager->cacheDemoProject(project, projectName)) {
qCritical()
<< "Could not cache demo project. Please check the logs for more information.";
emit popupClose();
@@ -202,10 +223,10 @@ void Backend::runDemoProject(const QString &projectName)
}
updatePopup("Running demo project...");
if (!m_projectManager.runDemoProject(projectName))
if (!m_projectManager->runDemoProject(projectName))
qCritical() << "Could not run demo project. Please check the logs for more information.";
else
m_projectManager.showAppWindow();
m_projectManager->showAppWindow();
emit popupClose();
}
@@ -214,12 +235,15 @@ void Backend::clearDemoCaches()
{
emit popupOpen();
updatePopup("Clearing demo caches...");
m_projectManager.clearDemoCaches();
m_projectManager.reset(new ProjectManager);
m_projectManager->clearDemoCaches();
m_projectManager.reset();
emit popupClose();
}
void Backend::runUserProject(const QString &url)
{
initializeProjectManager();
updatePopup("Running user project");
emit popupOpen();
@@ -236,7 +260,7 @@ void Backend::runUserProject(const QString &url)
}
}
const bool projectCached = m_projectManager.isProjectCached(projectInfo);
const bool projectCached = m_projectManager->isProjectCached(projectInfo);
if (!projectCached) {
qDebug("Project is not cached. Downloading...");
@@ -244,7 +268,7 @@ void Backend::runUserProject(const QString &url)
QByteArray projectData = m_serviceConnector.fetchProject(url);
updatePopup("Caching user project...");
if (!m_projectManager.cacheProject(projectData, projectInfo)) {
if (!m_projectManager->cacheProject(projectData, projectInfo)) {
qCritical() << "Could not cache project. Please check the logs for more information.";
emit popupClose();
return;
@@ -254,10 +278,10 @@ void Backend::runUserProject(const QString &url)
}
updatePopup("Running cached project...");
if (!m_projectManager.runCachedProject(projectInfo))
if (!m_projectManager->runCachedProject(projectInfo))
qCritical() << "Could not run project. Please check the logs for more information.";
else
m_projectManager.showAppWindow();
m_projectManager->showAppWindow();
emit popupClose();
}
Loading