From 3e44a549776c6720ed437ccbe9580d44d5fea004 Mon Sep 17 00:00:00 2001 From: Anton Tarasenko Date: Thu, 4 Mar 2021 14:07:46 +0700 Subject: [PATCH] Fix `MutableText`'s hash code not bein constant `MutableText`'s hash code was previously dependent on it's contents, allowing it to change without reallocation. This patch fixes that. --- sources/Text/MutableText.uc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/sources/Text/MutableText.uc b/sources/Text/MutableText.uc index e6fb449..a216a70 100644 --- a/sources/Text/MutableText.uc +++ b/sources/Text/MutableText.uc @@ -351,6 +351,18 @@ private final function FormattedBlock CreateFormattedBlock(bool isOpening) return newBlock; } +/** + * Unlike `Text`, `MutableText` can change it's content and therefore it's + * hash code cannot depend on it. So we restore `AcediaObject`'s behavior and + * return random value, generated at the time of allocation. + * + * @return Hash code for the caller `MutableText`. + */ +public function int GetHashCode() +{ + return super(AcediaObject).GetHashCode(); +} + defaultproperties { } \ No newline at end of file