Skip to content

Commit

Permalink
Add passthrough to DynamoModel.PreferenceSettings when available
Browse files Browse the repository at this point in the history
  • Loading branch information
saintentropy committed Nov 30, 2023
1 parent 1649d66 commit 99061fc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/DynamoCore/Configuration/PreferenceSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,14 @@ internal static void CopyProperties(this PreferenceSettings source, PreferenceSe
/// </summary>
public class PreferenceSettings : NotificationObject, IPreferences, IRenderPrecisionPreference, IDisablePackageLoadingPreferences, ILogSource, IHideAutocompleteMethodOptions
{
internal static PreferenceSettings dynamoModelRuntimePreferenceSettings;

internal readonly static Lazy<PreferenceSettings>
lazy = new Lazy<PreferenceSettings>
(() => PreferenceSettings.Load(PathManager.Instance.PreferenceFilePath));

[XmlIgnore]
public static PreferenceSettings Instance { get { return lazy.Value; } }
public static PreferenceSettings Instance { get { return dynamoModelRuntimePreferenceSettings ?? lazy.Value; } }

private string numberFormat;
private string lastUpdateDownloadPath;
Expand Down
7 changes: 7 additions & 0 deletions src/DynamoCore/Models/DynamoModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,10 @@ protected DynamoModel(IStartConfiguration config)
OnRequestUpdateLoadBarStatus(new SplashScreenLoadEventArgs(Resources.SplashScreenInitPreferencesSettings, 30));

PreferenceSettings = (PreferenceSettings)CreateOrLoadPreferences(config.Preferences);

//Set the DynamoModel.PreferenceSetting as a static reference to the PreferenceSetting class for use in PreferenceSettings.Instance
PreferenceSettings.dynamoModelRuntimePreferenceSettings = PreferenceSettings;

if (PreferenceSettings != null)
{
SetUICulture(PreferenceSettings.Locale);
Expand Down Expand Up @@ -781,6 +785,9 @@ protected DynamoModel(IStartConfiguration config)
var isFirstRun = PreferenceSettings.IsFirstRun;
PreferenceSettings = migrator.PreferenceSettings;

//Set the DynamoModel.PreferenceSetting as a static reference to the PreferenceSetting class for use in PreferenceSettings.Instance
PreferenceSettings.dynamoModelRuntimePreferenceSettings = PreferenceSettings;

// Preserve the preference settings for IsFirstRun as this needs to be set
// only by UsageReportingManager
PreferenceSettings.IsFirstRun = isFirstRun;
Expand Down

0 comments on commit 99061fc

Please sign in to comment.