Ensure we disconnect from EditorInteractionSystemViewportSelectionRequestBus while recreating m_interactionRequests (#2884)
Fixes a crash while selecting an entity in the viewport while in 'pick' mode.
This commit is contained in:
+12
-4
@@ -50,11 +50,19 @@ namespace AzToolsFramework
|
||||
AzFramework::ViewportDebugDisplayEventBus::Handler::BusConnect(GetEntityContextId());
|
||||
}
|
||||
|
||||
m_entityDataCache = AZStd::make_unique<EditorVisibleEntityDataCache>();
|
||||
// temporarily disconnect from EditorInteractionSystemViewportSelectionRequestBus in case during the creation of
|
||||
// m_interactionRequests (see interactionRequestsBuilder below) an event is propagated to the handler, if this happens then
|
||||
// m_interactionRequests will be null as it will not have finished being created yet so we ensure no events are forwarded to it
|
||||
EditorInteractionSystemViewportSelectionRequestBus::Handler::BusDisconnect();
|
||||
|
||||
m_interactionRequests.reset(); // BusConnect/Disconnect in constructor/destructor,
|
||||
// so have to reset before assigning the new one
|
||||
m_interactionRequests = interactionRequestsBuilder(m_entityDataCache.get());
|
||||
{
|
||||
m_entityDataCache = AZStd::make_unique<EditorVisibleEntityDataCache>();
|
||||
m_interactionRequests.reset(); // BusConnect/Disconnect in constructor/destructor,
|
||||
// so have to reset before assigning the new one
|
||||
m_interactionRequests = interactionRequestsBuilder(m_entityDataCache.get());
|
||||
}
|
||||
|
||||
EditorInteractionSystemViewportSelectionRequestBus::Handler::BusConnect(GetEntityContextId());
|
||||
}
|
||||
|
||||
void EditorInteractionSystemComponent::SetDefaultHandler()
|
||||
|
||||
@@ -380,7 +380,6 @@ namespace AzToolsFramework::ViewportUi::Internal
|
||||
}
|
||||
|
||||
PrepareWidgetForViewportUi(widget);
|
||||
m_renderOverlay->setFocus();
|
||||
}
|
||||
|
||||
void ViewportUiDisplay::SetUiOverlayContentsAnchored(QPointer<QWidget> widget, const Qt::Alignment alignment)
|
||||
@@ -392,7 +391,6 @@ namespace AzToolsFramework::ViewportUi::Internal
|
||||
|
||||
PrepareWidgetForViewportUi(widget);
|
||||
m_uiOverlayLayout.AddAnchoredWidget(widget, alignment);
|
||||
m_renderOverlay->setFocus();
|
||||
}
|
||||
|
||||
void ViewportUiDisplay::UpdateUiOverlayGeometry()
|
||||
|
||||
Reference in New Issue
Block a user