Skip to content

Commit 25cacde

Browse files
authored
Merge pull request o3de#17516 from aws-lumberyard-dev/daimini/dpe/deleteNow
DPE | Delete widgets later in the Editor
2 parents 294f163 + 23bfbc2 commit 25cacde

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyEditorAPI_Internals.h

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,20 @@ namespace AzToolsFramework
206206
{
207207
if (m_widget)
208208
{
209-
delete m_widget;
210-
m_widget = nullptr;
209+
// Detect whether this is being run in the Editor or during a Unit Test.
210+
AZ::ApplicationTypeQuery appType;
211+
AZ::ComponentApplicationBus::Broadcast(&AZ::ComponentApplicationBus::Events::QueryApplicationType, appType);
212+
if (appType.IsValid() && !appType.IsEditor())
213+
{
214+
// In Unit Tests, immediately delete the widget to prevent triggering the leak detection mechanism.
215+
delete m_widget;
216+
m_widget = nullptr;
217+
}
218+
else
219+
{
220+
// In the Editor, use deleteLater as it is more stable.
221+
m_widget->deleteLater();
222+
}
211223
}
212224
IndividualPropertyHandlerEditNotifications::Bus::Handler::BusDisconnect();
213225
}

0 commit comments

Comments
 (0)