AzQtComponents does not attach AZ::Environment
A pull request for this has already been merged.
- #5151 by @pollend — merged
- Dominant language
- C++
- Stars
- 9.7k
- Forks
- 2.5k
- Avg merge
- 3d 18h
- Merged PRs (30d)
- 51
Description
Describe the bug
AzQtComponents does not attach to the AZ::Environment so any classes inside that use AZ memory allocators will fail. This library used to not have any components that used AZ allocators, but now does, so it should export methods to attach/detach the environment and the main programs that use AzQtComponents (AzToolsApplications, ProjectManager, etc.) should call the exported methods to attach/detach the environment.
Related issues:
Related branch:
Steps to reproduce
Steps to reproduce the behavior:
- Build debug binaries of the Project Manager, or other tool that uses AzQtComponents
- Instantiate a class in AzQtComponents that uses AZ allocators (DragAndDropContextBase, ViewportDragContext, StyledTreeView) or use any EBuses that use AZ::Environment for allocators or storage in AzQtComponents.
Expected behavior
The objects can be created and used because AZ::Environment is attached providing access to the necessary allocators and env vars.
Actual behavior
AZ::Environment is not attached in the AzQtComponents dynamic library and access to allocators when using aznew will crash. Sometimes you may get lucky in profile/release builds and you will not crash because inlining will cause the allocators to use another module's environment, but this simply hides the problem.
Assets required
n/a
Screenshots/Video
n/a
Found in Branch
development
Desktop/Device (please complete the following information):
- Device: PC
Additional context
Recommend we postpone tackling this till after GA release
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the linked Prism branch and commit, then inspect AzQtComponents and the listed allocator-using classes: DragAndDropContextBase, ViewportDragContext, and StyledTreeView. Trace how AzToolsApplications and ProjectManager load the library. Done means AzQtComponents exposes attach/detach operations and its main consumers call them so these objects and related EBuses can use AZ::Environment safely.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- desktop, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100