diff --git a/Src/xWorks/InterestingTextsDecorator.cs b/Src/xWorks/InterestingTextsDecorator.cs index e325c7ce64..8b12f914d6 100644 --- a/Src/xWorks/InterestingTextsDecorator.cs +++ b/Src/xWorks/InterestingTextsDecorator.cs @@ -28,6 +28,9 @@ public class InterestingTextsDecorator : DomainDataByFlidDecoratorBase, ISetMedi // The object our property belongs to. We consider any object for which we are asked our special // property to be the root object. private int m_rootHvo; + private Mediator m_mediator; + private PropertyTable m_propertyTable; + public InterestingTextsDecorator(ISilDataAccessManaged domainDataByFlid, XmlNode configurationNode, ILcmServiceLocator services) : base(domainDataByFlid) @@ -55,6 +58,8 @@ public override void RemoveNotification(IVwNotifyChange nchng) // If a clerk were to be disposed some other time when another clerk was still using the ITL, // this would be a bad thing to do. base.RemoveNotification(m_interestingTexts); + m_interestingTexts = null; + m_interestingHvos = null; } } @@ -66,8 +71,21 @@ public override void AddNotification(IVwNotifyChange nchng) public void SetMediator(Mediator mediator, PropertyTable propertyTable) { - m_interestingTexts = GetInterestingTextList(mediator, propertyTable, m_services); - EnsureInterestingTextsSubscription(); + m_mediator = mediator; + m_propertyTable = propertyTable; + } + + private InterestingTextList InterestingTexts + { + get + { + if (m_interestingTexts == null) + { + m_interestingTexts = GetInterestingTextList(m_mediator, m_propertyTable, m_services); + EnsureInterestingTextsSubscription(); + } + return m_interestingTexts; + } } private void EnsureInterestingTextsSubscription() @@ -132,7 +150,7 @@ int[] GetInterestingTexts() // m_interestingHvos = new int[0]; // return m_interestingHvos; //} - m_interestingHvos = (from text in m_interestingTexts.InterestingTexts select text.Hvo).ToArray(); + m_interestingHvos = (from text in InterestingTexts.InterestingTexts select text.Hvo).ToArray(); } return m_interestingHvos; } @@ -161,12 +179,12 @@ public override int get_VecItem(int hvo, int tag, int index) public IEnumerable ScriptureTexts { - get { return m_interestingTexts.ScriptureTexts; } + get { return InterestingTexts.ScriptureTexts; } } public void SetInterestingTexts(IEnumerable newTexts) { - m_interestingTexts.SetInterestingTexts(newTexts); + InterestingTexts.SetInterestingTexts(newTexts); } public override int get_VecSize(int hvo, int tag)