Fixed several material editor bugs related to file paths and hot reload prompts (#6374)
* draft Signed-off-by: Guthrie Adams <guthadam@amazon.com> * Removes automatic generation of relative paths for external references for materials Updated material editor functions for creating new materials, creating or saving model or lighting presets, to save to the project asset folder instead of the material folder which is not included in the new templates Changed function for getting saved file names to handle case where Qt save file dialog adds double extensions if the extension contains a dot Signed-off-by: Guthrie Adams <guthadam@amazon.com> * Fixed problems with material editor hot reloading after documents or dependencies changed. Triggering message boxes within the tick function, which is executed from the main application timer, caused the tick function to be called a second time recursively. Switched from using the tick bus to a timer so that the documents re opening and dialogs are triggered outside of the main tick. Signed-off-by: Guthrie Adams <guthadam@amazon.com>
This commit is contained in:
+14
-11
@@ -24,6 +24,7 @@ AZ_PUSH_DISABLE_WARNING(4251 4800, "-Wunknown-warning-option") // disable warnin
|
||||
#include <QApplication>
|
||||
#include <QMessageBox>
|
||||
#include <QString>
|
||||
#include <QTimer>
|
||||
AZ_POP_DISABLE_WARNING
|
||||
|
||||
namespace AtomToolsFramework
|
||||
@@ -121,7 +122,6 @@ namespace AtomToolsFramework
|
||||
|
||||
void AtomToolsDocumentSystemComponent::Deactivate()
|
||||
{
|
||||
AZ::TickBus::Handler::BusDisconnect();
|
||||
AtomToolsDocumentNotificationBus::Handler::BusDisconnect();
|
||||
AtomToolsDocumentSystemRequestBus::Handler::BusDisconnect();
|
||||
m_documentMap.clear();
|
||||
@@ -160,25 +160,30 @@ namespace AtomToolsFramework
|
||||
void AtomToolsDocumentSystemComponent::OnDocumentExternallyModified(const AZ::Uuid& documentId)
|
||||
{
|
||||
m_documentIdsWithExternalChanges.insert(documentId);
|
||||
if (!AZ::TickBus::Handler::BusIsConnected())
|
||||
{
|
||||
AZ::TickBus::Handler::BusConnect();
|
||||
}
|
||||
QueueReopenDocuments();
|
||||
}
|
||||
|
||||
void AtomToolsDocumentSystemComponent::OnDocumentDependencyModified(const AZ::Uuid& documentId)
|
||||
{
|
||||
m_documentIdsWithDependencyChanges.insert(documentId);
|
||||
if (!AZ::TickBus::Handler::BusIsConnected())
|
||||
QueueReopenDocuments();
|
||||
}
|
||||
|
||||
void AtomToolsDocumentSystemComponent::QueueReopenDocuments()
|
||||
{
|
||||
if (!m_queueReopenDocuments)
|
||||
{
|
||||
AZ::TickBus::Handler::BusConnect();
|
||||
m_queueReopenDocuments = true;
|
||||
QTimer::singleShot(0, [this] { ReopenDocuments(); });
|
||||
}
|
||||
}
|
||||
|
||||
void AtomToolsDocumentSystemComponent::OnTick([[maybe_unused]] float deltaTime, [[maybe_unused]] AZ::ScriptTimePoint time)
|
||||
void AtomToolsDocumentSystemComponent::ReopenDocuments()
|
||||
{
|
||||
for (const AZ::Uuid& documentId : m_documentIdsWithExternalChanges)
|
||||
{
|
||||
m_documentIdsWithDependencyChanges.erase(documentId);
|
||||
|
||||
AZStd::string documentPath;
|
||||
AtomToolsDocumentRequestBus::EventResult(documentPath, documentId, &AtomToolsDocumentRequestBus::Events::GetAbsolutePath);
|
||||
|
||||
@@ -191,8 +196,6 @@ namespace AtomToolsFramework
|
||||
continue;
|
||||
}
|
||||
|
||||
m_documentIdsWithDependencyChanges.erase(documentId);
|
||||
|
||||
AtomToolsFramework::TraceRecorder traceRecorder(m_maxMessageBoxLineCount);
|
||||
|
||||
bool openResult = false;
|
||||
@@ -235,7 +238,7 @@ namespace AtomToolsFramework
|
||||
|
||||
m_documentIdsWithDependencyChanges.clear();
|
||||
m_documentIdsWithExternalChanges.clear();
|
||||
AZ::TickBus::Handler::BusDisconnect();
|
||||
m_queueReopenDocuments = false;
|
||||
}
|
||||
|
||||
AZ::Uuid AtomToolsDocumentSystemComponent::OpenDocument(AZStd::string_view sourcePath)
|
||||
|
||||
Reference in New Issue
Block a user