Skip to content

Commit

Permalink
Fix error for showing storage data (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
imengyu committed Dec 1, 2024
1 parent 5327564 commit 107e9c2
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions ONICPU/FCPU.cs
Original file line number Diff line number Diff line change
Expand Up @@ -938,25 +938,32 @@ public void OnShowProgramEditor()
if (CPUType == FCPUType.JavaScript)
{
var sb = new StringBuilder();
var js = JsonConvert.DeserializeObject<Dictionary<string, object>>(cpuStorageData);
var len = 0;
foreach (var item in js)
var js = string.IsNullOrEmpty(cpuStorageData) ?
null :
JsonConvert.DeserializeObject<Dictionary<string, object>>(cpuStorageData);
if (js == null || js.Count == 0)
{
sb.Append(item.Key);
sb.Append(" : ");
sb.AppendLine(item.Value.ToString());

if (len > 30)
sb.Append("Empty, No storaged data");
}
else
{
var len = 0;
foreach (var item in js)
{
sb.Append("... (");
sb.Append(js.Count - len);
sb.Append("+)");
sb.Append(item.Key);
sb.Append(" : ");
sb.AppendLine(item.Value.ToString());

if (len > 30)
{
sb.Append("... (");
sb.Append(js.Count - len);
sb.Append("+)");
}

len++;
}

len++;
}
if (js.Count == 0)
sb.Append("Empty, No storaged data");

UIUtils.ShowMessageModal(
"storage",
Expand Down

0 comments on commit 107e9c2

Please sign in to comment.