Skip to content

Commit f0954b0

Browse files
committed
Robustness
1 parent da67fe4 commit f0954b0

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

org.mixedrealitytoolkit.uxcore/FontIcons/FontIconSelector.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public class FontIconSelector : MonoBehaviour
2525

2626
[Tooltip("The currently selected icon's name, as defined by the FontIconSet.")]
2727
[SerializeField]
28-
private string currentIconName;
28+
private string currentIconName = string.Empty;
2929

3030
/// <summary>
3131
/// The currently selected icon's name, as defined by the <see cref="FontIcons"/>.

org.mixedrealitytoolkit.uxcore/FontIcons/FontIconSet.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ public class FontIconSet : ScriptableObject
6565
/// <returns><see langword="true"/> if icon name found, otherwise <see langword="false"/>.</returns>
6666
public bool TryGetGlyphIcon(string iconName, out uint unicodeValue)
6767
{
68+
if (string.IsNullOrEmpty(iconName))
69+
{
70+
unicodeValue = 0;
71+
return false;
72+
}
6873
return glyphIconsByName.TryGetValue(iconName, out unicodeValue);
6974
}
7075

@@ -110,6 +115,10 @@ public bool AddIcon(string name, uint unicodeValue)
110115
/// <returns>Whether it was able to find the name and remove it.</returns>
111116
public bool RemoveIcon(string iconName)
112117
{
118+
if (string.IsNullOrEmpty(iconName))
119+
{
120+
return false;
121+
}
113122
return glyphIconsByName.Remove(iconName);
114123
}
115124

@@ -125,6 +134,11 @@ public bool RemoveIcon(string iconName)
125134
/// <returns><see langword="true"/> if it was able to find and update the name.</returns>
126135
public bool UpdateIconName(string oldName, string newName)
127136
{
137+
if (string.IsNullOrEmpty(oldName) || string.IsNullOrEmpty(newName))
138+
{
139+
return false;
140+
}
141+
128142
if (glyphIconsByName.TryGetValue(oldName, out uint unicodeValue) && glyphIconsByName.TryAdd(newName, unicodeValue) && glyphIconsByName.Remove(oldName))
129143
{
130144
SortIcons();

0 commit comments

Comments
 (0)