File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -206,8 +206,20 @@ namespace AzToolsFramework
206
206
{
207
207
if (m_widget)
208
208
{
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
+ }
211
223
}
212
224
IndividualPropertyHandlerEditNotifications::Bus::Handler::BusDisconnect ();
213
225
}
You can’t perform that action at this time.
0 commit comments