Skip to content

Commit ed0597a

Browse files
committed
Multiple LoadJson calls fix #1831
1 parent cde9bb9 commit ed0597a

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

Analogy.CommonControls/Tools/JsonTreeView.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,11 @@ private void LoadImageList()
119119
}
120120

121121
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
122-
private List<TreeNode> LoadTree(object jsonData, CancellationToken cancellationToken)
122+
private (bool valid, List<TreeNode> result) LoadTree(object jsonData, CancellationToken cancellationToken)
123123
{
124124
if (cancellationToken.IsCancellationRequested)
125125
{
126-
return new();
126+
return (false, new());
127127
}
128128
List<TreeNode> nodes = new();
129129
if (jsonData is JArray jsonArray)
@@ -155,7 +155,7 @@ private List<TreeNode> LoadTree(object jsonData, CancellationToken cancellationT
155155
rootNode.ExpandAll();
156156
}
157157

158-
return nodes;
158+
return (!cancellationToken.IsCancellationRequested, nodes);
159159
}
160160
[MethodImpl(MethodImplOptions.AggressiveInlining)]
161161
private static bool TryParse(string strInput, out JToken output)
@@ -368,9 +368,9 @@ public async Task ShowJson(string jsonString)
368368
var token = cancellationTokenSource.Token;
369369
object json = JsonConvert.DeserializeObject(jsonString);
370370
var nodes = await Task.Run(() => LoadTree(json, token));
371-
if (!token.IsCancellationRequested)
371+
if (nodes.valid)
372372
{
373-
Nodes.AddRange(nodes.ToArray());
373+
Nodes.AddRange(nodes.result.ToArray());
374374
}
375375
EndUpdate();
376376
}

Analogy/CommonChangeLog.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ public static class CommonChangeLog
88
public static IEnumerable<AnalogyChangeLog> GetChangeLog()
99
{
1010
return new List<AnalogyChangeLog>
11-
{
11+
{
12+
new ("V5.0.0 - Multiple LoadJson calls #1831", AnalogChangeLogType.Bug,"Lior Banai",new DateTime(2023,09,05),"5.0.0.0"),
1213
new ("V5.0.0 - Disable Updates If Running from Program Data Folder #1841", AnalogChangeLogType.Improvement,"Lior Banai",new DateTime(2023,09,05),"5.0.0.0"),
1314
new ("V5.0.0 - Support running from MSI Installer #1838", AnalogChangeLogType.Improvement,"Lior Banai",new DateTime(2023,09,03),"5.0.0.0"),
1415
new ("V5.0.0 - DevExpress 23.1 #1837", AnalogChangeLogType.Improvement,"Lior Banai",new DateTime(2023,09,03),"5.0.0.0"),

0 commit comments

Comments
 (0)