Merge pull request #2094 from aws-lumberyard-dev/cgalvan/gitflow_210712

Merged stabilization/2106 to development
This commit is contained in:
Chris Galvan
2021-07-12 14:05:19 -05:00
committed by GitHub
221 changed files with 2398 additions and 9445 deletions
+18 -5
View File
@@ -27,11 +27,17 @@ namespace AZ
template <typename... Params>
EventHandler<Params...>::EventHandler(const EventHandler& rhs)
: m_callback(rhs.m_callback)
, m_event(rhs.m_event)
{
// Copy the callback function, then perform a Connect with the new event
if (rhs.m_event)
// Copy the callback and event, then perform a Connect to the event
if (m_callback && m_event)
{
rhs.m_event->Connect(*this);
m_event->Connect(*this);
}
else
{
// It was not possible to connect to the event, set it to nullptr
m_event = nullptr;
}
}
@@ -65,9 +71,16 @@ namespace AZ
{
Disconnect();
m_callback = rhs.m_callback;
if (rhs.m_event)
m_event = rhs.m_event;
// Copy the callback and event, then perform a Connect to the event
if (m_callback && m_event)
{
rhs.m_event->Connect(*this);
m_event->Connect(*this);
}
else
{
// It was not possible to connect to the event, set it to nullptr
m_event = nullptr;
}
}
@@ -32,6 +32,15 @@ namespace AZ
{
if (m_hashes.size() < m_hashes.max_size())
{
constexpr size_t MaxTagSize = TagName{}.max_size();
if (specialization.size() > MaxTagSize)
{
AZ_Error("Settings Registry", false, R"(Cannot append Specialization tag of "%.*s.")"
" It is longer than the MaxTagNameSize of %zu", AZ_STRING_ARG(specialization),
MaxTagSize);
return false;
}
m_names.push_back(TagName{ specialization });
TagName& tag = m_names.back();
AZStd::to_lower(tag.begin(), tag.end());
@@ -49,7 +49,7 @@ namespace AZ
class Specializations
{
public:
static constexpr size_t MaxTagNameSize = 32;
static constexpr size_t MaxTagNameSize = 64;
static constexpr size_t MaxCount = 15;
static constexpr size_t NotFound = static_cast<size_t>(-1);
using TagName = AZStd::fixed_string<MaxTagNameSize>;
@@ -146,7 +146,7 @@ namespace AZ {
AZStd::mutex g_dbgLoadingMutex;
HANDLE g_currentProcess = 0; /// We deal with only one process for now.
CRITICAL_SECTION g_csDbgHelpDll; /// All dbg help functions are single threaded, so we need to control the access.
AZStd::fixed_vector<SymbolStorage::ModuleInfo, 256> g_moduleInfo;
AZStd::fixed_vector<SymbolStorage::ModuleInfo, 2048> g_moduleInfo;
// reserve 4k of scratch space so that we can get some callstack information without any allocations and as little stack frame usage as possible.
const size_t g_scratchSpaceSize = 2048;
@@ -257,6 +257,48 @@ namespace UnitTest
EXPECT_FALSE(testEvent1.HasHandlerConnected());
EXPECT_TRUE(testEvent2.HasHandlerConnected());
}
TEST_F(EventTests, TestHandlerCopyConstructorOperator)
{
int32_t invokedCounter = 0;
AZ::Event<> testEvent;
AZ::Event<>::Handler testHandler([&invokedCounter]() { invokedCounter++; });
testHandler.Connect(testEvent);
AZ::Event<>::Handler testHandler2(testHandler);
EXPECT_TRUE(testHandler.IsConnected());
EXPECT_TRUE(testHandler2.IsConnected());
EXPECT_TRUE(invokedCounter == 0);
testEvent.Signal();
EXPECT_TRUE(invokedCounter == 2);
}
TEST_F(EventTests, TestHandlerCopyAssignmentOperator)
{
int32_t invokedCounter = 0;
AZ::Event<> testEvent;
AZ::Event<>::Handler testHandler([&invokedCounter]() { invokedCounter++; });
testHandler.Connect(testEvent);
AZ::Event<>::Handler testHandler2;
EXPECT_TRUE(testHandler.IsConnected());
EXPECT_FALSE(testHandler2.IsConnected());
testHandler2 = testHandler;
EXPECT_TRUE(testHandler2.IsConnected());
EXPECT_TRUE(invokedCounter == 0);
testEvent.Signal();
EXPECT_TRUE(invokedCounter == 2);
}
}
#if defined(HAVE_BENCHMARK)
@@ -12,5 +12,5 @@
#define AZ_TRAIT_AZFRAMEWORK_USE_ERRNO_T_TYPEDEF 1
#define AZ_TRAIT_AZFRAMEWORK_USE_POSIX_LOCALTIME_R 0
#define AZ_TRAIT_AZFRAMEWORK_PYTHON_SHELL "python.sh"
#define AZ_TRAIT_AZFRAMEWORK_USE_PROJECT_MANAGER 0
#define AZ_TRAIT_AZFRAMEWORK_USE_PROJECT_MANAGER 1
#define AZ_TRAIT_AZFRAMEWORK_PROCESSLAUNCH_DEFAULT 0
@@ -12,5 +12,5 @@
#define AZ_TRAIT_AZFRAMEWORK_USE_ERRNO_T_TYPEDEF 0
#define AZ_TRAIT_AZFRAMEWORK_USE_POSIX_LOCALTIME_R 1
#define AZ_TRAIT_AZFRAMEWORK_PYTHON_SHELL "python.sh"
#define AZ_TRAIT_AZFRAMEWORK_USE_PROJECT_MANAGER 0
#define AZ_TRAIT_AZFRAMEWORK_USE_PROJECT_MANAGER 1
#define AZ_TRAIT_AZFRAMEWORK_PROCESSLAUNCH_DEFAULT 0
@@ -36,8 +36,47 @@ namespace AzToolsFramework
/// Retrieve the main application window.
virtual QWidget* GetAppMainWindow() { return nullptr; }
};
using EditorWindowRequestBus = AZ::EBus<EditorWindowRequests>;
class EditorWindowUIRequests : public AZ::EBusTraits
{
public:
using Bus = AZ::EBus<EditorWindowUIRequests>;
//////////////////////////////////////////////////////////////////////////
// EBusTraits overrides
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Multiple;
//////////////////////////////////////////////////////////////////////////
/// Enable/Disable the Editor UI.
virtual void SetEditorUiEnabled([[maybe_unused]] bool enable) {}
};
using EditorWindowUIRequestBus = AZ::EBus<EditorWindowUIRequests>;
using EnableUiFunction = AZStd::function<void(bool)>;
/// Helper for EditorWindowRequests to be used as a
/// member instead of inheriting from EBus directly.
class EditorWindowRequestBusImpl
: public EditorWindowUIRequestBus::Handler
{
public:
/// Set the function to be called when entering ImGui Mode.
void SetEnableEditorUiFunc(const EnableUiFunction enableEditorUiFunc)
{
m_enableEditorUiFunc = AZStd::move(enableEditorUiFunc);
}
private:
// EditorWindowRequestBus
void SetEditorUiEnabled( [[maybe_unused]] bool enable) override
{
m_enableEditorUiFunc(enable);
}
EnableUiFunction m_enableEditorUiFunc; ///< Function to call when entering ImGui Mode.
};
} // namespace AzToolsFramework
#endif // AZTOOLSFRAMEWORK_EDITORWINDOWREQUESTBUS_H
@@ -34,7 +34,24 @@ namespace AzToolsFramework
bool EntityOutlinerSortFilterProxyModel::lessThan(const QModelIndex& leftIndex, const QModelIndex& rightIndex) const
{
return sourceModel()->data(leftIndex).toString() < sourceModel()->data(rightIndex).toString();
if (leftIndex.isValid() && rightIndex.isValid())
{
QVariant leftData = sourceModel()->data(leftIndex);
QVariant rightData = sourceModel()->data(rightIndex);
// make sure to compare the correct data types for sorting the current column
AZ_Assert(leftData.type() == rightData.type(), "EntityOutlinerSortFilterProxyModel::lessThan types do not agree!");
if (static_cast<QMetaType::Type>(leftData.type()) == QMetaType::QString)
{
return leftData.toString() < rightData.toString();
}
else if (static_cast<QMetaType::Type>(leftData.type()) == QMetaType::ULongLong)
{
return leftData.toULongLong() < rightData.toULongLong();
}
AZ_Error("Editor", false, "Error! Unhandled type \"%s\" in EntityOutlinerSortFilterProxyModel::lessThan", leftData.typeName());
}
return false;
}
void EntityOutlinerSortFilterProxyModel::sort(int /*column*/, Qt::SortOrder /*order*/)
@@ -291,10 +291,12 @@ namespace AzToolsFramework
GetEntityContextId());
EditorEntityInfoNotificationBus::Handler::BusConnect();
Prefab::PrefabPublicNotificationBus::Handler::BusConnect();
EditorWindowUIRequestBus::Handler::BusConnect();
}
EntityOutlinerWidget::~EntityOutlinerWidget()
{
EditorWindowUIRequestBus::Handler::BusDisconnect();
Prefab::PrefabPublicNotificationBus::Handler::BusDisconnect();
ComponentModeFramework::EditorComponentModeNotificationBus::Handler::BusDisconnect();
EditorEntityInfoNotificationBus::Handler::BusDisconnect();
@@ -1106,16 +1108,25 @@ namespace AzToolsFramework
AzQtComponents::SetWidgetInteractEnabled(entityOutlinerUi->m_searchWidget, on);
}
void EntityOutlinerWidget::EnableUi(bool enable)
{
SetEntityOutlinerState(m_gui, enable);
setEnabled(enable);
}
void EntityOutlinerWidget::SetEditorUiEnabled(bool enable)
{
EnableUi(enable);
}
void EntityOutlinerWidget::EnteredComponentMode([[maybe_unused]] const AZStd::vector<AZ::Uuid>& componentModeTypes)
{
SetEntityOutlinerState(m_gui, false);
setEnabled(false);
EnableUi(false);
}
void EntityOutlinerWidget::LeftComponentMode([[maybe_unused]] const AZStd::vector<AZ::Uuid>& componentModeTypes)
{
setEnabled(true);
SetEntityOutlinerState(m_gui, true);
EnableUi(true);
}
void EntityOutlinerWidget::OnPrefabInstancePropagationBegin()
@@ -11,6 +11,7 @@
#include <AzCore/Memory/SystemAllocator.h>
#include <AzCore/base.h>
#include <AzToolsFramework/API/EditorWindowRequestBus.h>
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
#include <AzToolsFramework/ComponentMode/EditorComponentModeBus.h>
#include <AzToolsFramework/Entity/EditorEntityInfoBus.h>
@@ -58,6 +59,7 @@ namespace AzToolsFramework
, private EditorEntityInfoNotificationBus::Handler
, private ComponentModeFramework::EditorComponentModeNotificationBus::Handler
, private Prefab::PrefabPublicNotificationBus::Handler
, private EditorWindowUIRequestBus::Handler
{
Q_OBJECT;
public:
@@ -105,6 +107,9 @@ namespace AzToolsFramework
void OnPrefabInstancePropagationBegin() override;
void OnPrefabInstancePropagationEnd() override;
// EditorWindowUIRequestBus overrides
void SetEditorUiEnabled(bool enable) override;
// Build a selection object from the given entities. Entities already in the Widget's selection buffers are ignored.
template <class EntityIdCollection>
QItemSelection BuildSelectionFromEntities(const EntityIdCollection& entityIds);
@@ -155,6 +160,7 @@ namespace AzToolsFramework
AZ::EntityId GetEntityIdFromIndex(const QModelIndex& index) const;
QModelIndex GetIndexFromEntityId(const AZ::EntityId& entityId) const;
void ExtractEntityIdsFromSelection(const QItemSelection& selection, EntityIdList& entityIdList) const;
void EnableUi(bool enable);
// OutlinerModelNotificationBus::Handler
// Receive notification from the outliner model that we should scroll
@@ -376,6 +376,7 @@ namespace AzToolsFramework
ToolsApplicationEvents::Bus::Handler::BusConnect();
AZ::EntitySystemBus::Handler::BusConnect();
EntityPropertyEditorRequestBus::Handler::BusConnect();
EditorWindowUIRequestBus::Handler::BusConnect();
m_spacer = nullptr;
m_emptyIcon = QIcon();
@@ -421,6 +422,7 @@ namespace AzToolsFramework
{
qApp->removeEventFilter(this);
EditorWindowUIRequestBus::Handler::BusDisconnect();
EntityPropertyEditorRequestBus::Handler::BusDisconnect();
ToolsApplicationEvents::Bus::Handler::BusDisconnect();
AZ::EntitySystemBus::Handler::BusDisconnect();
@@ -4961,6 +4963,27 @@ namespace AzToolsFramework
EnableDisableComponentActions(widget, actions, false);
}
void EntityPropertyEditor::SetEditorUiEnabled(bool enable)
{
if (enable)
{
EnableComponentActions(this, m_entityComponentActions);
}
else
{
DisableComponentActions(this, m_entityComponentActions);
}
m_disabled = !enable;
SetPropertyEditorState(m_gui, enable);
for (auto componentEditor : m_componentEditors)
{
AzQtComponents::SetWidgetInteractEnabled(componentEditor, enable);
}
// record the selected state after entering/leaving component mode
SaveComponentEditorState();
}
void EntityPropertyEditor::EnteredComponentMode(const AZStd::vector<AZ::Uuid>& componentModeTypes)
{
DisableComponentActions(this, m_entityComponentActions);
@@ -21,6 +21,7 @@
#include <AzCore/Asset/AssetCommon.h>
#include <AzToolsFramework/UI/PropertyEditor/PropertyEditorAPI.h>
#include <AzToolsFramework/Undo/UndoSystem.h>
#include <AzToolsFramework/API/EditorWindowRequestBus.h>
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
#include <AzToolsFramework/API/EntityPropertyEditorRequestsBus.h>
#include <AzToolsFramework/ComponentMode/EditorComponentModeBus.h>
@@ -108,6 +109,7 @@ namespace AzToolsFramework
, public EditorInspectorComponentNotificationBus::MultiHandler
, private AzToolsFramework::ComponentModeFramework::EditorComponentModeNotificationBus::Handler
, public AZ::EntitySystemBus::Handler
, private EditorWindowUIRequestBus::Handler
{
Q_OBJECT;
public:
@@ -208,6 +210,9 @@ namespace AzToolsFramework
void GetSelectedEntities(EntityIdList& selectedEntityIds) override;
void SetNewComponentId(AZ::ComponentId componentId) override;
// EditorWindowRequestBus overrides
void SetEditorUiEnabled(bool enable) override;
bool IsEntitySelected(const AZ::EntityId& id) const;
bool IsSingleEntitySelected(const AZ::EntityId& id) const;