From 44b655d67772675152c2d21de071c7943de53ed3 Mon Sep 17 00:00:00 2001 From: mark-sil <83427558+mark-sil@users.noreply.github.com> Date: Tue, 27 Jan 2026 11:18:46 -0500 Subject: [PATCH] LT-22375: Implement PostponePropChanged in Pub/Sub system --- Src/Common/Controls/DetailControls/DataTree.cs | 8 ++++++-- Src/Common/Controls/DetailControls/GhostStringSlice.cs | 7 +++---- Src/Common/FwUtils/EventConstants.cs | 2 ++ Src/FdoUi/FdoUiCore.cs | 5 +++-- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/Src/Common/Controls/DetailControls/DataTree.cs b/Src/Common/Controls/DetailControls/DataTree.cs index 1aab4b5371..6e1e514030 100644 --- a/Src/Common/Controls/DetailControls/DataTree.cs +++ b/Src/Common/Controls/DetailControls/DataTree.cs @@ -5,6 +5,7 @@ using SIL.FieldWorks.Common.Controls; using SIL.FieldWorks.Common.Framework.DetailControls.Resources; using SIL.FieldWorks.Common.FwUtils; +using static SIL.FieldWorks.Common.FwUtils.FwUtils; using SIL.FieldWorks.Common.RootSites; using SIL.LCModel; using SIL.LCModel.Core.Cellar; @@ -529,13 +530,12 @@ public LcmStyleSheet StyleSheet } - public virtual bool OnPostponePropChanged(object commandObject) + private void PostponePropChanged(object commandObject) { if ((bool)commandObject == true) m_postponePropChanged = true; else m_postponePropChanged = false; - return true; } public void PropChanged(int hvo, int tag, int ivMin, int cvIns, int cvDel) @@ -1253,6 +1253,8 @@ protected override void Dispose(bool disposing) if (disposing) { + Subscriber.Unsubscribe(EventConstants.PostponePropChanged, PostponePropChanged); + // Do this first, before setting m_fDisposing to true. if (m_sda != null) m_sda.RemoveNotification(this); @@ -3713,6 +3715,8 @@ public void Init(Mediator mediator, PropertyTable propertyTable, XmlNode configu // it will override the persisted value. if (PersistenceProvder != null) RestorePreferences(); + + Subscriber.Subscribe(EventConstants.PostponePropChanged, PostponePropChanged); } public IxCoreColleague[] GetMessageTargets() diff --git a/Src/Common/Controls/DetailControls/GhostStringSlice.cs b/Src/Common/Controls/DetailControls/GhostStringSlice.cs index fcda37a7d4..a507cd4f07 100644 --- a/Src/Common/Controls/DetailControls/GhostStringSlice.cs +++ b/Src/Common/Controls/DetailControls/GhostStringSlice.cs @@ -12,6 +12,7 @@ using SIL.FieldWorks.Common.Framework.DetailControls.Resources; using SIL.LCModel.Core.KernelInterfaces; using SIL.FieldWorks.Common.FwUtils; +using static SIL.FieldWorks.Common.FwUtils.FwUtils; using SIL.FieldWorks.Common.RootSites; using SIL.LCModel; using SIL.LCModel.Application; @@ -455,17 +456,15 @@ private void SwitchToReal() // will typically dispose this and create a new string slice whose key is our own key // followed by the flid of the string property. // To avoid problems, PropChanged must not be postponed (cf. LT-22018). - // Copy m_mediator in case 'this' gets disposed. - Mediator mediator = m_mediator; int hvoNewObj; try { - mediator.SendMessage("PostponePropChanged", false); + Publisher.Publish(new PublisherParameterObject(EventConstants.PostponePropChanged, false)); hvoNewObj = MakeRealObject(tssTyped); } finally { - mediator.SendMessage("PostponePropChanged", true); + Publisher.Publish(new PublisherParameterObject(EventConstants.PostponePropChanged, true)); } // Now try to make a suitable selection in the slice that replaces this. diff --git a/Src/Common/FwUtils/EventConstants.cs b/Src/Common/FwUtils/EventConstants.cs index 6b278d327e..218e5efc40 100644 --- a/Src/Common/FwUtils/EventConstants.cs +++ b/Src/Common/FwUtils/EventConstants.cs @@ -20,9 +20,11 @@ public static class EventConstants public const string GetContentControlParameters = "GetContentControlParameters"; public const string GetToolForList = "GetToolForList"; public const string HandleLocalHotlink = "HandleLocalHotlink"; + public const string JumpToPopupLexEntry = "JumpToPopupLexEntry"; public const string JumpToRecord = "JumpToRecord"; public const string LinkFollowed = "LinkFollowed"; public const string MasterRefresh = "MasterRefresh"; + public const string PostponePropChanged = "PostponePropChanged"; public const string PrepareToRefresh = "PrepareToRefresh"; public const string RecordNavigation = "RecordNavigation"; public const string RefreshCurrentList = "RefreshCurrentList"; diff --git a/Src/FdoUi/FdoUiCore.cs b/Src/FdoUi/FdoUiCore.cs index 99a28f55b2..7bc60f3b97 100644 --- a/Src/FdoUi/FdoUiCore.cs +++ b/Src/FdoUi/FdoUiCore.cs @@ -17,6 +17,7 @@ using SIL.FieldWorks.Common.Framework; using SIL.LCModel.Core.KernelInterfaces; using SIL.FieldWorks.Common.FwUtils; +using static SIL.FieldWorks.Common.FwUtils.FwUtils; using SIL.FieldWorks.Common.RootSites; using SIL.LCModel; using SIL.LCModel.DomainServices; @@ -399,7 +400,7 @@ public static CmObjectUi CreateNewUiObject(Mediator mediator, PropertyTable prop try { // Don't postpone PropChanged (cf. LT-22095). - mediator?.SendMessage("PostponePropChanged", false); + Publisher.Publish(new PublisherParameterObject(EventConstants.PostponePropChanged, false)); var cache = propertyTable.GetValue("cache"); switch (classId) { @@ -419,7 +420,7 @@ public static CmObjectUi CreateNewUiObject(Mediator mediator, PropertyTable prop } finally { - mediator?.SendMessage("PostponePropChanged", true); + Publisher.Publish(new PublisherParameterObject(EventConstants.PostponePropChanged, true)); } }