From d24062af3b1a476f786106c3a0defa2d812abfca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kaj=20Gr=C3=B6nholm?= Date: Tue, 27 Aug 2019 16:09:26 +0300 Subject: Fix guide selection status Match to scene object behavior where after delete -> undo restored item is not selected. Task-number: QT3DS-3223 Change-Id: Iedaca14c7df43b0dd44aeefb149a2dd0db56f724 Reviewed-by: Mahmoud Badri Reviewed-by: Miikka Heikkinen --- src/Authoring/Qt3DStudio/Render/StudioRenderer.cpp | 8 +++++--- src/Authoring/Qt3DStudio/Render/StudioRendererTranslation.cpp | 4 +++- src/Authoring/Qt3DStudio/Render/StudioRendererTranslation.h | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Authoring/Qt3DStudio/Render/StudioRenderer.cpp b/src/Authoring/Qt3DStudio/Render/StudioRenderer.cpp index ef5c385c..320bca23 100644 --- a/src/Authoring/Qt3DStudio/Render/StudioRenderer.cpp +++ b/src/Authoring/Qt3DStudio/Render/StudioRenderer.cpp @@ -1088,18 +1088,20 @@ struct SRendererImpl : public IStudioRenderer, { m_MaybeDragStart = false; m_mouseDown = false; + bool guideExists = true; Qt3DSDMGuideHandle theSelectedGuide; if (m_PickResult.getType() == StudioPickValueTypes::Guide) { theSelectedGuide = m_PickResult.getData(); - m_Translation->CheckGuideInPresentationRect(theSelectedGuide, m_UpdatableEditor); + guideExists = m_Translation->CheckGuideInPresentationRect(theSelectedGuide, + m_UpdatableEditor); } m_UpdatableEditor.CommitEditor(); m_PickResult = SStudioPickValue(); if (m_Translation) m_Translation->EndDrag(); if (theSelectedGuide.GetHandleValue()) { - // Get rid of selection if things aren't editable. - if (m_Doc.GetDocumentReader().AreGuidesEditable()) + // Get rid of selection if things aren't editable or if guide has been deleted. + if (guideExists && m_Doc.GetDocumentReader().AreGuidesEditable()) m_Doc.NotifySelectionChanged(theSelectedGuide); else m_Doc.NotifySelectionChanged(); diff --git a/src/Authoring/Qt3DStudio/Render/StudioRendererTranslation.cpp b/src/Authoring/Qt3DStudio/Render/StudioRendererTranslation.cpp index 06d6be76..b53084bc 100644 --- a/src/Authoring/Qt3DStudio/Render/StudioRendererTranslation.cpp +++ b/src/Authoring/Qt3DStudio/Render/StudioRendererTranslation.cpp @@ -3980,7 +3980,7 @@ void STranslation::PerformGuideDrag(Qt3DSDMGuideHandle inGuide, CPt inPoint, inEditor.FireImmediateRefresh(qt3dsdm::Qt3DSDMInstanceHandle()); } -void STranslation::CheckGuideInPresentationRect(Qt3DSDMGuideHandle inGuide, +bool STranslation::CheckGuideInPresentationRect(Qt3DSDMGuideHandle inGuide, CUpdateableDocumentEditor &inEditor) { qt3dsdm::SGuideInfo theInfo = m_Doc.GetDocumentReader().GetGuideInfo(inGuide); @@ -4000,6 +4000,8 @@ void STranslation::CheckGuideInPresentationRect(Qt3DSDMGuideHandle inGuide, if (!inPresentation) inEditor.EnsureEditor(QObject::tr("Delete Guide"), __FILE__, __LINE__).DeleteGuide(inGuide); + + return inPresentation; } void STranslation::PerformPathDrag(qt3ds::studio::SPathPick &inPathPick, CPt inOriginalCoords, diff --git a/src/Authoring/Qt3DStudio/Render/StudioRendererTranslation.h b/src/Authoring/Qt3DStudio/Render/StudioRendererTranslation.h index 8f38d8e0..66ae9fcc 100644 --- a/src/Authoring/Qt3DStudio/Render/StudioRendererTranslation.h +++ b/src/Authoring/Qt3DStudio/Render/StudioRendererTranslation.h @@ -632,7 +632,7 @@ namespace studio { void PerformGuideDrag(Qt3DSDMGuideHandle inGuide, CPt inPoint, CUpdateableDocumentEditor &inEditor); - void CheckGuideInPresentationRect(Qt3DSDMGuideHandle inGuide, + bool CheckGuideInPresentationRect(Qt3DSDMGuideHandle inGuide, CUpdateableDocumentEditor &inEditor); void PerformPathDrag(qt3ds::studio::SPathPick &inPathPick, CPt inOriginalCoords, -- cgit v1.2.3