Remove temporary changes and remove key before building
Signed-off-by: AMZN-Phil <pconroy@amazon.com>
This commit is contained in:
@@ -9,14 +9,16 @@
|
||||
#include <ProjectBuilderController.h>
|
||||
#include <ProjectBuilderWorker.h>
|
||||
#include <ProjectButtonWidget.h>
|
||||
#include <ProjectManagerSettings.h>
|
||||
|
||||
#include <AzFramework/IO/LocalFileIO.h>
|
||||
#include <AzCore/Settings/SettingsRegistry.h>
|
||||
|
||||
#include <QMessageBox>
|
||||
#include <QDesktopServices>
|
||||
#include <QUrl>
|
||||
|
||||
|
||||
|
||||
namespace O3DE::ProjectManager
|
||||
{
|
||||
ProjectBuilderController::ProjectBuilderController(const ProjectInfo& projectInfo, ProjectButton* projectButton, QWidget* parent)
|
||||
@@ -29,6 +31,15 @@ namespace O3DE::ProjectManager
|
||||
m_worker = new ProjectBuilderWorker(m_projectInfo);
|
||||
m_worker->moveToThread(&m_workerThread);
|
||||
|
||||
auto settingsRegistry = AZ::SettingsRegistry::Get();
|
||||
if (settingsRegistry)
|
||||
{
|
||||
// Remove key here in case Project Manager crashing while building that causes HandleResults to not be called
|
||||
QString settingsKey = QString("%1/Projects/%2/BuiltSuccesfully").arg(ProjectManagerKeyPrefix).arg(m_projectInfo.m_projectName);
|
||||
settingsRegistry->Remove(settingsKey.toStdString().c_str());
|
||||
SaveProjectManagerSettings();
|
||||
}
|
||||
|
||||
connect(&m_workerThread, &QThread::finished, m_worker, &ProjectBuilderWorker::deleteLater);
|
||||
connect(&m_workerThread, &QThread::started, m_worker, &ProjectBuilderWorker::BuildProject);
|
||||
connect(m_worker, &ProjectBuilderWorker::Done, this, &ProjectBuilderController::HandleResults);
|
||||
@@ -82,9 +93,7 @@ namespace O3DE::ProjectManager
|
||||
|
||||
void ProjectBuilderController::HandleResults(const QString& result)
|
||||
{
|
||||
AZ::IO::LocalFileIO fileIO;
|
||||
AZStd::string successBuildFilePath = AZStd::string::format("%s/%s",
|
||||
m_projectInfo.m_path.toStdString().c_str(), "ProjectManagerBuildSuccess");
|
||||
QString settingsKey = QString("%1/Projects/%2/BuiltSuccesfully").arg(ProjectManagerKeyPrefix).arg(m_projectInfo.m_projectName);
|
||||
|
||||
if (!result.isEmpty())
|
||||
{
|
||||
@@ -115,7 +124,12 @@ namespace O3DE::ProjectManager
|
||||
emit NotifyBuildProject(m_projectInfo);
|
||||
}
|
||||
|
||||
fileIO.Remove(successBuildFilePath.c_str());
|
||||
auto settingsRegistry = AZ::SettingsRegistry::Get();
|
||||
if (settingsRegistry)
|
||||
{
|
||||
settingsRegistry->Remove(settingsKey.toStdString().c_str());
|
||||
SaveProjectManagerSettings();
|
||||
}
|
||||
|
||||
emit Done(false);
|
||||
return;
|
||||
@@ -124,11 +138,11 @@ namespace O3DE::ProjectManager
|
||||
{
|
||||
m_projectInfo.m_buildFailed = false;
|
||||
|
||||
AZ::IO::HandleType fileHandle;
|
||||
if (fileIO.Open(successBuildFilePath.c_str(), AZ::IO::OpenMode::ModeWrite | AZ::IO::OpenMode::ModeText, fileHandle))
|
||||
auto settingsRegistry = AZ::SettingsRegistry::Get();
|
||||
if (settingsRegistry)
|
||||
{
|
||||
// We just need the file to exist
|
||||
fileIO.Close(fileHandle);
|
||||
settingsRegistry->Set(settingsKey.toStdString().c_str(), true);
|
||||
SaveProjectManagerSettings();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ProjectManagerSettings.h"
|
||||
|
||||
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
|
||||
#include <AzCore/IO/ByteContainerStream.h>
|
||||
#include <AzCore/Utils/Utils.h>
|
||||
|
||||
namespace O3DE::ProjectManager
|
||||
{
|
||||
void SaveProjectManagerSettings()
|
||||
{
|
||||
auto settingsRegistry = AZ::SettingsRegistry::Get();
|
||||
AZ::SettingsRegistryMergeUtils::DumperSettings dumperSettings;
|
||||
dumperSettings.m_prettifyOutput = true;
|
||||
dumperSettings.m_jsonPointerPrefix = ProjectManagerKeyPrefix;
|
||||
|
||||
AZStd::string stringBuffer;
|
||||
AZ::IO::ByteContainerStream stringStream(&stringBuffer);
|
||||
if (!AZ::SettingsRegistryMergeUtils::DumpSettingsRegistryToStream(
|
||||
*settingsRegistry, ProjectManagerKeyPrefix, stringStream, dumperSettings))
|
||||
{
|
||||
AZ_Warning("ProjectManager", false, "Could not save Project Manager settings to stream");
|
||||
return;
|
||||
}
|
||||
|
||||
AZ::IO::FixedMaxPath o3deUserPath = AZ::Utils::GetO3deManifestDirectory();
|
||||
o3deUserPath /= AZ::SettingsRegistryInterface::RegistryFolder;
|
||||
o3deUserPath /= "ProjectManager.setreg";
|
||||
|
||||
bool saved = false;
|
||||
constexpr auto configurationMode =
|
||||
AZ::IO::SystemFile::SF_OPEN_CREATE | AZ::IO::SystemFile::SF_OPEN_CREATE_PATH | AZ::IO::SystemFile::SF_OPEN_WRITE_ONLY;
|
||||
|
||||
AZ::IO::SystemFile outputFile;
|
||||
if (outputFile.Open(o3deUserPath.c_str(), configurationMode))
|
||||
{
|
||||
saved = outputFile.Write(stringBuffer.data(), stringBuffer.size()) == stringBuffer.size();
|
||||
}
|
||||
|
||||
AZ_Warning("ProjectManager", saved, "Unable to save Project Manager registry file to path: %s", o3deUserPath.c_str());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace O3DE::ProjectManager
|
||||
{
|
||||
static constexpr char ProjectManagerKeyPrefix[] = "/O3DE/ProjectManager";
|
||||
|
||||
void SaveProjectManagerSettings();
|
||||
}
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <ProjectUtils.h>
|
||||
#include <ProjectBuilderController.h>
|
||||
#include <ScreensCtrl.h>
|
||||
#include <ProjectManagerSettings.h>
|
||||
|
||||
#include <AzQtComponents/Components/FlowLayout.h>
|
||||
#include <AzCore/Platform.h>
|
||||
@@ -22,7 +23,7 @@
|
||||
#include <AzFramework/Process/ProcessCommon.h>
|
||||
#include <AzFramework/Process/ProcessWatcher.h>
|
||||
#include <AzCore/Utils/Utils.h>
|
||||
#include <AzFramework/IO/LocalFileIO.h>
|
||||
#include <AzCore/Settings/SettingsRegistry.h>
|
||||
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
@@ -290,11 +291,15 @@ namespace O3DE::ProjectManager
|
||||
// Check whether project manager has successfully built the project
|
||||
if (currentButton)
|
||||
{
|
||||
AZStd::string successfulBuildFilePath = AZStd::string::format("%s/%s",
|
||||
project.m_path.toStdString().c_str(), "ProjectManagerBuildSuccess");
|
||||
|
||||
AZ::IO::LocalFileIO fileIO;
|
||||
if (!fileIO.Exists(successfulBuildFilePath.c_str()))
|
||||
auto settingsRegistry = AZ::SettingsRegistry::Get();
|
||||
bool projectBuiltSuccessfully = false;
|
||||
if (settingsRegistry)
|
||||
{
|
||||
QString settingsKey =
|
||||
QString("%1/Projects/%2/BuiltSuccesfully").arg(ProjectManagerKeyPrefix).arg(project.m_projectName);
|
||||
settingsRegistry->Get(projectBuiltSuccessfully, settingsKey.toStdString().c_str());
|
||||
}
|
||||
if (!projectBuiltSuccessfully)
|
||||
{
|
||||
currentButton->ShowBuildRequired();
|
||||
}
|
||||
|
||||
@@ -15,6 +15,9 @@
|
||||
#include <UpdateProjectCtrl.h>
|
||||
#include <UpdateProjectSettingsScreen.h>
|
||||
#include <ProjectUtils.h>
|
||||
#include <ProjectManagerSettings.h>
|
||||
|
||||
#include <AzCore/Settings/SettingsRegistry.h>
|
||||
|
||||
#include <QDialogButtonBox>
|
||||
#include <QMessageBox>
|
||||
@@ -280,6 +283,23 @@ namespace O3DE::ProjectManager
|
||||
}
|
||||
}
|
||||
|
||||
if (newProjectSettings.m_projectName != m_projectInfo.m_projectName)
|
||||
{
|
||||
// update reg key
|
||||
QString oldSettingsKey =
|
||||
QString("%1/Projects/%2/BuiltSuccesfully").arg(ProjectManagerKeyPrefix).arg(m_projectInfo.m_projectName);
|
||||
QString newSettingsKey =
|
||||
QString("%1/Projects/%2/BuiltSuccesfully").arg(ProjectManagerKeyPrefix).arg(newProjectSettings.m_projectName);
|
||||
|
||||
auto settingsRegistry = AZ::SettingsRegistry::Get();
|
||||
bool projectBuiltSuccessfully = false;
|
||||
if (settingsRegistry && settingsRegistry->Get(projectBuiltSuccessfully, oldSettingsKey.toStdString().c_str()))
|
||||
{
|
||||
settingsRegistry->Set(newSettingsKey.toStdString().c_str(), projectBuiltSuccessfully);
|
||||
SaveProjectManagerSettings();
|
||||
}
|
||||
}
|
||||
|
||||
if (!newProjectSettings.m_newPreviewImagePath.isEmpty())
|
||||
{
|
||||
if (!ProjectUtils::ReplaceProjectFile(
|
||||
|
||||
@@ -58,6 +58,8 @@ set(FILES
|
||||
Source/CreateProjectCtrl.cpp
|
||||
Source/UpdateProjectCtrl.h
|
||||
Source/UpdateProjectCtrl.cpp
|
||||
Source/ProjectManagerSettings.h
|
||||
Source/ProjectManagerSettings.cpp
|
||||
Source/ProjectsScreen.h
|
||||
Source/ProjectsScreen.cpp
|
||||
Source/ProjectSettingsScreen.h
|
||||
|
||||
Reference in New Issue
Block a user