diff --git a/Src/xWorks/LinkListener.cs b/Src/xWorks/LinkListener.cs index d8dd723e4d..686b7423b7 100644 --- a/Src/xWorks/LinkListener.cs +++ b/Src/xWorks/LinkListener.cs @@ -438,13 +438,13 @@ private bool FollowActiveLink(bool suspendLoadingRecord) { try { + var cache = m_propertyTable.GetValue("cache"); //Debug.Assert(!(m_lnkActive is FwAppArgs), "Beware: This will not handle link requests for other databases/applications." + // " To handle other databases or applications, pass the FwAppArgs to the IFieldWorksManager.HandleLinkRequest method."); if (m_lnkActive.ToolName == "default") { // Need some smarts here. The link creator was not sure what tool to use. // The object may also be a child we don't know how to jump to directly. - var cache = m_propertyTable.GetValue("cache"); ICmObject target; if (!cache.ServiceLocator.ObjectRepository.TryGetObject(m_lnkActive.TargetGuid, out target)) return false; // or message? @@ -500,6 +500,12 @@ private bool FollowActiveLink(bool suspendLoadingRecord) m_lnkActive = new FwLinkArgs(realTool, realTarget.Guid); // Todo JohnT: need to do something special here if we c } + // Return false if the link is to a different database + var databases = m_lnkActive.PropertyTableEntries.Where(p => p.name == "database"); + if (databases.Any() && databases.First().name != cache.LangProject.ShortName) + { + return false; + } // It's important to do this AFTER we set the real tool name if it is "default". Otherwise, the code that // handles the jump never realizes we have reached the desired tool (as indicated by the value of // SuspendLoadingRecordUntilOnJumpToRecord) and we stop recording context history and various similar problems. @@ -518,10 +524,8 @@ private bool FollowActiveLink(bool suspendLoadingRecord) // or more likely, when the HVO was set to -1. if (m_lnkActive.TargetGuid != Guid.Empty) { - LcmCache cache = m_propertyTable.GetValue("cache"); ICmObject obj = cache.ServiceLocator.GetInstance().GetObject(m_lnkActive.TargetGuid); - if (obj is IReversalIndexEntry && m_lnkActive.ToolName == "reversalToolEditComplete" || - (m_lnkActive?.PropertyTableEntries.Where(p => p.name.Equals("database")).Any() ?? false)) + if (obj is IReversalIndexEntry && m_lnkActive.ToolName == "reversalToolEditComplete") { // For the reversal index tool, just getting the tool right isn't enough. We // also need to be showing the proper index. (See FWR-1105.)