Skip to content

Commit

Permalink
only perform guid generation in getter
Browse files Browse the repository at this point in the history
  • Loading branch information
carlos-zamora committed Oct 27, 2020
1 parent 747aea8 commit 3104f7a
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,6 @@ namespace SettingsModelLocalTests

// TODO CARLOS:
// - temp/DebugBreak is only for testing. Remove after we're done here.
// - NiksaShell prints out a guid, when it shouldn't be
// - BhojwaniShell is missing entirely
const auto result{ settings->ToJson() };
const auto temp{ toString(result) };
Expand Down
18 changes: 0 additions & 18 deletions src/cascadia/TerminalSettingsModel/CascadiaSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,6 @@ void CascadiaSettings::_ValidateSettings()
// Make sure to check that profiles exists at all first and foremost:
_ValidateProfilesExist();

// Verify all profiles actually had a GUID specified, otherwise generate a
// GUID for them. Make sure to do this before de-duping profiles and
// checking that the default profile is set.
_ValidateProfilesHaveGuid();

// Re-order profiles so that all profiles from the user's settings appear
// before profiles that _weren't_ in the user profiles.
_ReorderProfilesToMatchUserSettingsOrder();
Expand Down Expand Up @@ -284,19 +279,6 @@ void CascadiaSettings::_ValidateProfilesExist()
}
}

// Method Description:
// - Walks through each profile, and ensures that they had a GUID set at some
// point. If the profile did _not_ have a GUID ever set for it, generate a
// temporary runtime GUID for it. This validation does not add any warnings.
void CascadiaSettings::_ValidateProfilesHaveGuid()
{
for (auto profile : _profiles)
{
auto profileImpl = winrt::get_self<implementation::Profile>(profile);
profileImpl->GenerateGuidIfNecessary();
}
}

// Method Description:
// - Resolves the "defaultProfile", which can be a profile name, to a GUID
// and stores it back to the globals.
Expand Down
1 change: 0 additions & 1 deletion src/cascadia/TerminalSettingsModel/CascadiaSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation

void _ValidateSettings();
void _ValidateProfilesExist();
void _ValidateProfilesHaveGuid();
void _ValidateDefaultProfileExists();
void _ValidateNoDuplicateProfiles();
void _ResolveDefaultProfile();
Expand Down
21 changes: 0 additions & 21 deletions src/cascadia/TerminalSettingsModel/Profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,27 +424,6 @@ std::wstring Profile::EvaluateStartingDirectory(const std::wstring& directory)
}
}

// Method Description:
// - If this profile never had a GUID set for it, generate a runtime GUID for
// the profile. If a profile had their guid manually set to {0}, this method
// will _not_ change the profile's GUID.
void Profile::GenerateGuidIfNecessary() noexcept
{
if (!_getGuidImpl().has_value())
{
// Always use the name to generate the temporary GUID. That way, across
// reloads, we'll generate the same static GUID.
_Guid = Profile::_GenerateGuidForProfile(Name(), Source());

TraceLoggingWrite(
g_hSettingsModelProvider,
"SynthesizedGuidForProfile",
TraceLoggingDescription("Event emitted when a profile is deserialized without a GUID"),
TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES),
TelemetryPrivacyDataTag(PDT_ProductAndServicePerformance));
}
}

// Function Description:
// - Returns true if the given JSON object represents a dynamic profile object.
// If it is a dynamic profile object, we should make sure to only layer the
Expand Down
1 change: 0 additions & 1 deletion src/cascadia/TerminalSettingsModel/Profile.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation

hstring EvaluatedStartingDirectory() const;
hstring ExpandedBackgroundImagePath() const;
void GenerateGuidIfNecessary() noexcept;
static guid GetGuidOrGenerateForJson(const Json::Value& json) noexcept;

// BackgroundImageAlignment is 1 setting saved as 2 separate values
Expand Down

0 comments on commit 3104f7a

Please sign in to comment.