From 28ac73337a8ce5b526c9e4ab03935cdda6ac8a85 Mon Sep 17 00:00:00 2001 From: mark-sil <83427558+mark-sil@users.noreply.github.com> Date: Wed, 28 Oct 2026 15:50:36 -0400 Subject: [PATCH] PropertyTable: a stored default no longer broadcasts A Get*Property or GetValue read with a default, and SetDefault, now store the value for an absent key without queueing OnPropertyChanged, and SetDefault has no broadcast flag. Until now the first reader of an unset property was a hidden setter: it created the key and queued a broadcast of the default, so a handler could run on a placeholder before the real value was set. Dropping that broadcast loses nothing a handler could use. A handler receives only the name and reads the table when the queued item drains, which is after the code that read the default has set the real value; so the read's item either repeated the set's own broadcast with the same value, or delivered a placeholder nobody wanted (null, "" or "????") when no set followed. At startup the first view was built on the null currentContentControl item from the primed menus; it is now built on AreaListener's own set, which queues right behind it with the same parameters node. The names whose first read used to reach a live handler, now stored silently: * currentContentControl and areaChoice (null, at window build, every launch, because their persistence is switched off) * BestStyleName ("????" from the Styles combo at the first idle) * InterlinearTab ("" from the Parser menu at window build) * ShowHiddenFields- (one per tool), ShowFailingItems- lexiconClassifiedDictionary, ShowInvisibleSpaces and ClickInvisibleSpace (pane-bar and menu items) * DictionaryPublicationLayout and ReversalIndexPublicationLayout ("" before GetCurrentConfiguration sets the path) * currentFilterForRecordClerk_ and ReversalIndexGuid The SetDefault flag never reached a colleague: the window-level config defaults load before any colleague registers, the tool-level ones find their keys already set, and every code caller passed false. Co-Authored-By: Claude Fable 5.1 --- .../Controls/DetailControls/DataTree.cs | 2 +- Src/Common/Controls/XMLViews/BrowseViewer.cs | 4 +- Src/XCore/xCoreInterfaces/PropertyTable.cs | 42 ++----- .../PropertyTableTests.cs | 105 ++++++++++++++---- Src/XCore/xWindow.cs | 12 +- Src/xWorks/RecordClerk.cs | 2 +- 6 files changed, 104 insertions(+), 63 deletions(-) diff --git a/Src/Common/Controls/DetailControls/DataTree.cs b/Src/Common/Controls/DetailControls/DataTree.cs index 16da10365b..317648cb56 100644 --- a/Src/Common/Controls/DetailControls/DataTree.cs +++ b/Src/Common/Controls/DetailControls/DataTree.cs @@ -1071,7 +1071,7 @@ public virtual void ShowObject(ICmObject root, string layoutName, string layoutC // Initialize our internal state with the state of the PropertyTable m_fShowAllFields = m_propertyTable.GetBoolProperty("ShowHiddenFields-" + toolName, false, PropertyTable.SettingsGroup.LocalSettings); m_propertyTable.SetPropertyPersistence("ShowHiddenFields-" + toolName, true, PropertyTable.SettingsGroup.LocalSettings); - m_propertyTable.SetDefault("ShowHiddenFields", m_fShowAllFields, PropertyTable.SettingsGroup.LocalSettings, false); + m_propertyTable.SetDefault("ShowHiddenFields", m_fShowAllFields, PropertyTable.SettingsGroup.LocalSettings); SetCurrentSlicePropertyNames(); m_currentSlicePartName = m_propertyTable.GetStringProperty(m_sPartNameProperty, null, PropertyTable.SettingsGroup.LocalSettings); m_currentSliceObjGuid = m_propertyTable.GetValue(m_sObjGuidProperty, PropertyTable.SettingsGroup.LocalSettings, Guid.Empty); diff --git a/Src/Common/Controls/XMLViews/BrowseViewer.cs b/Src/Common/Controls/XMLViews/BrowseViewer.cs index 7f4fa72836..68db6dc9a6 100644 --- a/Src/Common/Controls/XMLViews/BrowseViewer.cs +++ b/Src/Common/Controls/XMLViews/BrowseViewer.cs @@ -995,10 +995,10 @@ internal void ContructorSurrogate(XmlNode nodeSpec, int hvoRoot, int fakeFlid, } // set default property, so it doesn't accidentally get set // in OnPropertyChanged() when user right clicks for the first time (cf. LT-2789). - m_propertyTable.SetDefault("SortedFromEnd", false, PropertyTable.SettingsGroup.LocalSettings, false); + m_propertyTable.SetDefault("SortedFromEnd", false, PropertyTable.SettingsGroup.LocalSettings); // set default property, so it doesn't accidentally get set // in OnPropertyChanged() when user right clicks for the first time (cf. LT-2789). - m_propertyTable.SetDefault("SortedByLength", false, PropertyTable.SettingsGroup.LocalSettings, false); + m_propertyTable.SetDefault("SortedByLength", false, PropertyTable.SettingsGroup.LocalSettings); // // FilterBar diff --git a/Src/XCore/xCoreInterfaces/PropertyTable.cs b/Src/XCore/xCoreInterfaces/PropertyTable.cs index eb312f676b..96fd633725 100644 --- a/Src/XCore/xCoreInterfaces/PropertyTable.cs +++ b/Src/XCore/xCoreInterfaces/PropertyTable.cs @@ -428,7 +428,7 @@ private T GetValueInternal(string key, T defaultValue) if (prop == null) { result = defaultValue; - SetDefaultInternal(key, defaultValue, true); + SetDefaultInternal(key, defaultValue); } else { @@ -436,7 +436,6 @@ private T GetValueInternal(string key, T defaultValue) { prop.value = defaultValue; result = defaultValue; - SetDefaultInternal(key, defaultValue, true); } else { @@ -454,52 +453,35 @@ private T GetValueInternal(string key, T defaultValue) } /// - /// set the default; does nothing if this value is already in the PropertyTable (local or global). + /// Stores the default under the best settings group; does nothing if the property already + /// exists there. /// - /// - /// - /// - /// "true" if the property should be broadcast, and then, only if it has changed. - /// "false" to not broadcast it at all. - /// - public void SetDefault(string name, object defaultValue, bool doBroadcastIfChanged) + public void SetDefault(string name, object defaultValue) { CheckDisposed(); - SetDefault(name, defaultValue, SettingsGroup.BestSettings, doBroadcastIfChanged); + SetDefault(name, defaultValue, SettingsGroup.BestSettings); } /// - /// set the default; does nothing if this value is already in the specified settingsGroup. + /// Stores the default; does nothing if the property already exists in the specified + /// settingsGroup. /// - /// - /// - /// - /// - /// "true" if the property should be broadcast, and then, only if it has changed. - /// "false" to not broadcast it at all. - /// - public void SetDefault(string name, object defaultValue, SettingsGroup settingsGroup, bool doBroadcastIfChanged) + public void SetDefault(string name, object defaultValue, SettingsGroup settingsGroup) { CheckDisposed(); string key; GetBestSettingsGroupAndKey(name, settingsGroup, out key); - SetDefaultInternal(key, defaultValue, doBroadcastIfChanged); + SetDefaultInternal(key, defaultValue); } /// - /// set a default; does nothing if this value is already in the PropertyTable. + /// Stores the default; does nothing if the key already exists. /// - /// - /// - /// - /// "true" if the property should be broadcast, and then, only if it has changed. - /// "false" to not broadcast it at all. - /// - private void SetDefaultInternal(string key, object defaultValue, bool doBroadcastIfChanged) + private void SetDefaultInternal(string key, object defaultValue) { if (!m_properties.ContainsKey(key)) { - SetPropertyInternal(key, defaultValue, doBroadcastIfChanged); + SetPropertyInternal(key, defaultValue, false); } } diff --git a/Src/XCore/xCoreInterfaces/xCoreInterfacesTests/PropertyTableTests.cs b/Src/XCore/xCoreInterfaces/xCoreInterfacesTests/PropertyTableTests.cs index 8661dfe294..01dc9cb31c 100644 --- a/Src/XCore/xCoreInterfaces/xCoreInterfacesTests/PropertyTableTests.cs +++ b/Src/XCore/xCoreInterfaces/xCoreInterfacesTests/PropertyTableTests.cs @@ -3,7 +3,9 @@ // (http://www.gnu.org/licenses/lgpl-2.1.html) using System; +using System.Collections.Generic; using System.IO; +using System.Xml; using NUnit.Framework; using XCore.Properties; @@ -733,22 +735,22 @@ public void SetProperty() public void SetDefault() { // Try changing existing Global & Local values, check that they don't overwrite existing ones. - m_propertyTable.SetDefault("BooleanPropertyA", false, PropertyTable.SettingsGroup.LocalSettings, false); - m_propertyTable.SetDefault("BooleanPropertyA", true, PropertyTable.SettingsGroup.GlobalSettings, false); + m_propertyTable.SetDefault("BooleanPropertyA", false, PropertyTable.SettingsGroup.LocalSettings); + m_propertyTable.SetDefault("BooleanPropertyA", true, PropertyTable.SettingsGroup.GlobalSettings); bool gpba = m_propertyTable.GetValue("BooleanPropertyA", PropertyTable.SettingsGroup.GlobalSettings); Assert.That(gpba, Is.False, String.Format("Invalid value for {0} {1}.", "global", "BooleanPropertyA")); bool lpba = m_propertyTable.GetValue("BooleanPropertyA", PropertyTable.SettingsGroup.LocalSettings); Assert.That(lpba, Is.True, String.Format("Invalid value for {0} {1}.", "local", "BooleanPropertyA")); - m_propertyTable.SetDefault("IntegerPropertyA", 253, PropertyTable.SettingsGroup.LocalSettings, false); - m_propertyTable.SetDefault("IntegerPropertyA", -253, PropertyTable.SettingsGroup.GlobalSettings, false); + m_propertyTable.SetDefault("IntegerPropertyA", 253, PropertyTable.SettingsGroup.LocalSettings); + m_propertyTable.SetDefault("IntegerPropertyA", -253, PropertyTable.SettingsGroup.GlobalSettings); int gpia = m_propertyTable.GetValue("IntegerPropertyA", PropertyTable.SettingsGroup.GlobalSettings); Assert.That(gpia, Is.EqualTo(253), String.Format("Invalid value for {0} {1}.", "global", "IntegerPropertyA")); int lpia = m_propertyTable.GetValue("IntegerPropertyA", PropertyTable.SettingsGroup.LocalSettings); Assert.That(lpia, Is.EqualTo(333), String.Format("Invalid value for {0} {1}.", "local", "IntegerPropertyA")); - m_propertyTable.SetDefault("StringPropertyA", "local_StringPropertyC_value", PropertyTable.SettingsGroup.LocalSettings, false); - m_propertyTable.SetDefault("StringPropertyA", "global_StringPropertyC_value", PropertyTable.SettingsGroup.GlobalSettings, false); + m_propertyTable.SetDefault("StringPropertyA", "local_StringPropertyC_value", PropertyTable.SettingsGroup.LocalSettings); + m_propertyTable.SetDefault("StringPropertyA", "global_StringPropertyC_value", PropertyTable.SettingsGroup.GlobalSettings); string gpsa = m_propertyTable.GetValue("StringPropertyA", PropertyTable.SettingsGroup.GlobalSettings, "local_StringPropertyC_value"); Assert.That(gpsa, Is.EqualTo("global_StringPropertyA_value"), String.Format("Invalid value for {0} {1}.", "global", "StringPropertyA")); string lpsa = m_propertyTable.GetValue("StringPropertyA", PropertyTable.SettingsGroup.LocalSettings); @@ -756,34 +758,34 @@ public void SetDefault() // Make new properties. ------------------ //---- Global Settings - m_propertyTable.SetDefault("BooleanPropertyC", true, PropertyTable.SettingsGroup.GlobalSettings, true); + m_propertyTable.SetDefault("BooleanPropertyC", true, PropertyTable.SettingsGroup.GlobalSettings); bool gpbc = m_propertyTable.GetBoolProperty("BooleanPropertyC", false, PropertyTable.SettingsGroup.GlobalSettings); Assert.That(gpbc, Is.True, String.Format("Invalid value for {0} {1}.", "global", "BooleanPropertyC")); - m_propertyTable.SetDefault("IntegerPropertyC", 352, PropertyTable.SettingsGroup.GlobalSettings, true); + m_propertyTable.SetDefault("IntegerPropertyC", 352, PropertyTable.SettingsGroup.GlobalSettings); int gpic = m_propertyTable.GetIntProperty("IntegerPropertyC", -352, PropertyTable.SettingsGroup.GlobalSettings); Assert.That(gpic, Is.EqualTo(352), String.Format("Invalid value for {0} {1}.", "global", "IntegerPropertyC")); - m_propertyTable.SetDefault("StringPropertyC", "global_StringPropertyC_value", PropertyTable.SettingsGroup.GlobalSettings, true); + m_propertyTable.SetDefault("StringPropertyC", "global_StringPropertyC_value", PropertyTable.SettingsGroup.GlobalSettings); string gpsc = m_propertyTable.GetStringProperty("StringPropertyC", "local_StringPropertyC_value", PropertyTable.SettingsGroup.GlobalSettings); Assert.That(gpsc, Is.EqualTo("global_StringPropertyC_value"), String.Format("Invalid value for {0} {1}.", "global", "StringPropertyC")); //---- Local Settings - m_propertyTable.SetDefault("BooleanPropertyC", false, PropertyTable.SettingsGroup.LocalSettings, false); + m_propertyTable.SetDefault("BooleanPropertyC", false, PropertyTable.SettingsGroup.LocalSettings); bool lpbc = m_propertyTable.GetBoolProperty("BooleanPropertyC", true, PropertyTable.SettingsGroup.LocalSettings); Assert.That(lpbc, Is.False, String.Format("Invalid value for {0} {1}.", "local", "BooleanPropertyC")); - m_propertyTable.SetDefault("IntegerPropertyC", 111, PropertyTable.SettingsGroup.LocalSettings, false); + m_propertyTable.SetDefault("IntegerPropertyC", 111, PropertyTable.SettingsGroup.LocalSettings); int lpic = m_propertyTable.GetIntProperty("IntegerPropertyC", -111, PropertyTable.SettingsGroup.LocalSettings); Assert.That(lpic, Is.EqualTo(111), String.Format("Invalid value for {0} {1}.", "local", "IntegerPropertyC")); - m_propertyTable.SetDefault("StringPropertyC", "local_StringPropertyC_value", PropertyTable.SettingsGroup.LocalSettings, false); + m_propertyTable.SetDefault("StringPropertyC", "local_StringPropertyC_value", PropertyTable.SettingsGroup.LocalSettings); string lpsc = m_propertyTable.GetStringProperty("StringPropertyC", "local_StringPropertyC_value", PropertyTable.SettingsGroup.LocalSettings); Assert.That(lpsc, Is.EqualTo("local_StringPropertyC_value"), String.Format("Invalid value for {0} {1}.", "local", "StringPropertyC")); object nullObject; // Set best setting on unique globals. - m_propertyTable.SetDefault("BestBooleanPropertyA", false, PropertyTable.SettingsGroup.BestSettings, false); + m_propertyTable.SetDefault("BestBooleanPropertyA", false, PropertyTable.SettingsGroup.BestSettings); bool ubpba = m_propertyTable.GetValue("BestBooleanPropertyA", PropertyTable.SettingsGroup.BestSettings); Assert.That(ubpba, Is.True, String.Format("Invalid value for {0} {1}.", "best", "BestBooleanPropertyA")); bool ugpba = m_propertyTable.GetValue("BestBooleanPropertyA", PropertyTable.SettingsGroup.GlobalSettings); @@ -791,7 +793,7 @@ public void SetDefault() nullObject = m_propertyTable.GetValue("BestBooleanPropertyA", PropertyTable.SettingsGroup.LocalSettings); Assert.That(nullObject, Is.Null, String.Format("Invalid value for {0} {1}.", "best", "BestBooleanPropertyA")); - m_propertyTable.SetDefault("BestIntegerPropertyA", 101, PropertyTable.SettingsGroup.BestSettings, false); + m_propertyTable.SetDefault("BestIntegerPropertyA", 101, PropertyTable.SettingsGroup.BestSettings); int ubpia = m_propertyTable.GetValue("BestIntegerPropertyA", PropertyTable.SettingsGroup.BestSettings); Assert.That(ubpia, Is.EqualTo(-101), String.Format("Invalid value for {0} {1}.", "best", "BestIntegerPropertyA")); int ugpia = m_propertyTable.GetValue("BestIntegerPropertyA", PropertyTable.SettingsGroup.GlobalSettings); @@ -799,7 +801,7 @@ public void SetDefault() nullObject = m_propertyTable.GetValue("BestIntegerPropertyA", PropertyTable.SettingsGroup.LocalSettings); Assert.That(nullObject, Is.Null, String.Format("Invalid value for {0} {1}.", "best", "BestIntegerPropertyA")); - m_propertyTable.SetDefault("BestStringPropertyA", "best_BestStringPropertyA_value", PropertyTable.SettingsGroup.BestSettings, false); + m_propertyTable.SetDefault("BestStringPropertyA", "best_BestStringPropertyA_value", PropertyTable.SettingsGroup.BestSettings); string ubpsa = m_propertyTable.GetValue("BestStringPropertyA", PropertyTable.SettingsGroup.BestSettings); Assert.That(ubpsa, Is.EqualTo("global_BestStringPropertyA_value"), String.Format("Invalid value for {0} {1}.", "best", "BestStringPropertyA")); string ugpsa = m_propertyTable.GetValue("BestStringPropertyA", PropertyTable.SettingsGroup.GlobalSettings); @@ -808,7 +810,7 @@ public void SetDefault() Assert.That(nullObject, Is.Null, String.Format("Invalid value for {0} {1}.", "best", "BestStringPropertyA")); // Set best setting on unique locals - m_propertyTable.SetDefault("BestBooleanPropertyB", true, PropertyTable.SettingsGroup.BestSettings, false); + m_propertyTable.SetDefault("BestBooleanPropertyB", true, PropertyTable.SettingsGroup.BestSettings); ubpba = m_propertyTable.GetValue("BestBooleanPropertyB", PropertyTable.SettingsGroup.BestSettings); Assert.That(ubpba, Is.False, String.Format("Invalid value for {0} {1}.", "best", "BestBooleanPropertyB")); bool ulpba = m_propertyTable.GetValue("BestBooleanPropertyB", PropertyTable.SettingsGroup.LocalSettings); @@ -816,7 +818,7 @@ public void SetDefault() nullObject = m_propertyTable.GetValue("BestBooleanPropertyB", PropertyTable.SettingsGroup.GlobalSettings); Assert.That(nullObject, Is.Null, String.Format("Invalid value for {0} {1}.", "best", "BestBooleanPropertyB")); - m_propertyTable.SetDefault("BestIntegerPropertyB", 586, PropertyTable.SettingsGroup.BestSettings, false); + m_propertyTable.SetDefault("BestIntegerPropertyB", 586, PropertyTable.SettingsGroup.BestSettings); ubpia = m_propertyTable.GetValue("BestIntegerPropertyB", PropertyTable.SettingsGroup.BestSettings); Assert.That(ubpia, Is.EqualTo(-586), String.Format("Invalid value for {0} {1}.", "best", "BestIntegerPropertyB")); int ulpia = m_propertyTable.GetValue("BestIntegerPropertyB", PropertyTable.SettingsGroup.LocalSettings); @@ -824,7 +826,7 @@ public void SetDefault() nullObject = m_propertyTable.GetValue("BestIntegerPropertyB", PropertyTable.SettingsGroup.GlobalSettings); Assert.That(nullObject, Is.Null, String.Format("Invalid value for {0} {1}.", "best", "BestIntegerPropertyB")); - m_propertyTable.SetDefault("BestStringPropertyB", "best_BestStringPropertyB_value", PropertyTable.SettingsGroup.BestSettings, false); + m_propertyTable.SetDefault("BestStringPropertyB", "best_BestStringPropertyB_value", PropertyTable.SettingsGroup.BestSettings); ubpsa = m_propertyTable.GetValue("BestStringPropertyB", PropertyTable.SettingsGroup.BestSettings); Assert.That(ubpsa, Is.EqualTo("local_BestStringPropertyB_value"), String.Format("Invalid value for {0} {1}.", "best", "BestStringPropertyB")); string ulpsa = m_propertyTable.GetValue("BestStringPropertyB", PropertyTable.SettingsGroup.LocalSettings); @@ -833,7 +835,7 @@ public void SetDefault() Assert.That(nullObject, Is.Null, String.Format("Invalid value for {0} {1}.", "best", "BestStringPropertyB")); // Make new best (global) properties - m_propertyTable.SetDefault("BestBooleanPropertyC", false, false); + m_propertyTable.SetDefault("BestBooleanPropertyC", false); ugpba = m_propertyTable.GetValue("BestBooleanPropertyC"); Assert.That(ugpba, Is.False, String.Format("Invalid value for {0} {1}.", "best", "BestBooleanPropertyC")); ugpba = m_propertyTable.GetValue("BestBooleanPropertyC", PropertyTable.SettingsGroup.GlobalSettings); @@ -841,7 +843,7 @@ public void SetDefault() nullObject = m_propertyTable.GetValue("BestBooleanPropertyC", PropertyTable.SettingsGroup.LocalSettings); Assert.That(nullObject, Is.Null, String.Format("Invalid value for {0} {1}.", "local", "BestBooleanPropertyC")); - m_propertyTable.SetDefault("BestIntegerPropertyC", -818, false); + m_propertyTable.SetDefault("BestIntegerPropertyC", -818); ugpia = m_propertyTable.GetValue("BestIntegerPropertyC"); Assert.That(ugpia, Is.EqualTo(-818), String.Format("Invalid value for {0} {1}.", "best", "BestIntegerPropertyC")); ugpia = m_propertyTable.GetValue("BestIntegerPropertyC", PropertyTable.SettingsGroup.GlobalSettings); @@ -849,7 +851,7 @@ public void SetDefault() nullObject = m_propertyTable.GetValue("BestIntegerPropertyC", PropertyTable.SettingsGroup.LocalSettings); Assert.That(nullObject, Is.Null, String.Format("Invalid value for {0} {1}.", "local", "BestIntegerPropertyC")); - m_propertyTable.SetDefault("BestStringPropertyC", "global_BestStringPropertyC_value", false); + m_propertyTable.SetDefault("BestStringPropertyC", "global_BestStringPropertyC_value"); ugpsa = m_propertyTable.GetValue("BestStringPropertyC"); Assert.That(ugpsa, Is.EqualTo("global_BestStringPropertyC_value"), String.Format("Invalid value for {0} {1}.", "best", "BestStringPropertyC")); ugpsa = m_propertyTable.GetValue("BestStringPropertyC", PropertyTable.SettingsGroup.GlobalSettings); @@ -858,6 +860,67 @@ public void SetDefault() Assert.That(nullObject, Is.Null, String.Format("Invalid value for {0} {1}.", "local", "BestStringPropertyA")); } + /// + /// A read with a default and SetDefault store the value for an absent or null-valued key + /// and + /// deliver no OnPropertyChanged; a SetProperty with the flag still does. + /// + [Test] + public void GetWithDefaultAndSetDefault_StoreWithoutBroadcast() + { + var spy = new PropertyChangeSpy(); + m_mediator.AddColleague(spy); + try + { + Assert.That(m_mediator.ProcessMessages, Is.True); + m_propertyTable.SetProperty("ReadNullValued", null, false); + Assert.That(m_propertyTable.GetStringProperty("ReadNullValued", "filled"), Is.EqualTo("filled")); + Assert.That(m_propertyTable.GetBoolProperty("ReadBool", true), Is.True); + Assert.That(m_propertyTable.GetIntProperty("ReadInt", 7), Is.EqualTo(7)); + Assert.That(m_propertyTable.GetStringProperty("ReadString", "s"), Is.EqualTo("s")); + Assert.That(m_propertyTable.GetStringProperty("ReadLocalString", "ls", + PropertyTable.SettingsGroup.LocalSettings), Is.EqualTo("ls")); + Assert.That(m_propertyTable.GetValue("ReadGeneric", 3.5), Is.EqualTo(3.5)); + m_propertyTable.SetDefault("DefaultBest", "d"); + m_propertyTable.SetDefault("DefaultLocal", "dl", PropertyTable.SettingsGroup.LocalSettings); + DrainMediator(); + Assert.That(spy.Names, Is.Empty); + Assert.That(m_propertyTable.GetValue("ReadNullValued"), Is.EqualTo("filled")); + foreach (var name in new[] { "ReadBool", "ReadInt", "ReadString", "ReadGeneric", "DefaultBest" }) + Assert.That(m_propertyTable.PropertyExists(name), Is.True, name); + foreach (var name in new[] { "ReadLocalString", "DefaultLocal" }) + Assert.That(m_propertyTable.PropertyExists(name, PropertyTable.SettingsGroup.LocalSettings), Is.True, name); + + m_propertyTable.SetProperty("ReadBool", false, true); + DrainMediator(); + Assert.That(spy.Names, Is.EqualTo(new[] { "ReadBool" })); + } + finally + { + m_mediator.RemoveColleague(spy); + } + } + + private void DrainMediator() + { + for (var i = 0; m_mediator.JobItems > 0; i++) + { + Assert.That(i, Is.LessThan(100), "Mediator queue did not drain"); + m_mediator.ProcessItem(); + } + } + + /// Records every OnPropertyChanged name the Mediator delivers. + private sealed class PropertyChangeSpy : IxCoreColleague + { + public List Names { get; } = new List(); + public void Init(Mediator mediator, PropertyTable propertyTable, XmlNode configurationParameters) { } + public IxCoreColleague[] GetMessageTargets() => new IxCoreColleague[] { this }; + public bool ShouldNotCall => false; + public int Priority => (int)ColleaguePriority.Medium; + public void OnPropertyChanged(string name) => Names.Add(name); + } + [Test] public void ReadOnlyPropertyTable_GetWithDefaultDoesNotSet() { diff --git a/Src/XCore/xWindow.cs b/Src/XCore/xWindow.cs index 6542f2f4ed..205ca5229e 100644 --- a/Src/XCore/xWindow.cs +++ b/Src/XCore/xWindow.cs @@ -526,16 +526,14 @@ protected void LoadDefaultProperties(XmlNode configurationNode) m_propertyTable.SetDefault( name, XmlUtils.GetBooleanAttributeValue(node, "bool"), - settingsGroup, - true); + settingsGroup); } else if (node.Attributes["intValue"] != null) { m_propertyTable.SetDefault( name, XmlUtils.GetMandatoryIntegerAttributeValue(node, "intValue"), - settingsGroup, - true); + settingsGroup); } //this one allows us to just create an object on-the-fly and stick it directly in a property. else if (node.Attributes["assemblyPath"] != null) @@ -543,8 +541,7 @@ protected void LoadDefaultProperties(XmlNode configurationNode) m_propertyTable.SetDefault( name, DynamicLoader.CreateObject(node, m_mediator), - settingsGroup, - true); + settingsGroup); m_propertyTable.SetPropertyPersistence(name, false, settingsGroup); } else @@ -555,8 +552,7 @@ protected void LoadDefaultProperties(XmlNode configurationNode) m_propertyTable.SetDefault( name, XmlUtils.GetMandatoryAttributeValue(node, "value"), - settingsGroup, - true); + settingsGroup); } } diff --git a/Src/xWorks/RecordClerk.cs b/Src/xWorks/RecordClerk.cs index 80d1f5a3d6..dc910ec7bd 100644 --- a/Src/xWorks/RecordClerk.cs +++ b/Src/xWorks/RecordClerk.cs @@ -353,7 +353,7 @@ public virtual void Init(Mediator mediator, PropertyTable propertyTable, XmlNode { m_activeMenuBarFilter = menuBarFilterOption; m_filterProvider.OnAdjustFilterSelection(m_activeMenuBarFilter); - m_propertyTable.SetDefault(CurrentFilterPropertyTableId, m_activeMenuBarFilter.id, PropertyTable.SettingsGroup.LocalSettings, false); + m_propertyTable.SetDefault(CurrentFilterPropertyTableId, m_activeMenuBarFilter.id, PropertyTable.SettingsGroup.LocalSettings); fSetFilterMenu = true; break; }