Skip to content

Commit 6868dcd

Browse files
author
junlong.lin
committed
修复一些越界报错
1 parent 399c474 commit 6868dcd

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

LuaProfiler/example/Assets/LuaProfiler/Editor/Window/ProfilerWin/TreeView/LuaProfilerTreeView.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -911,6 +911,7 @@ public void LoadRootSample(Sample sample)
911911

912912
public int GetNextFrame(int start, bool isChange)
913913
{
914+
start = Math.Max(1, Math.Min(start, history.Count - 1));
914915
int ret = start;
915916
int frameCount = history[start].frameCount;
916917
for (int i = start + 1, imax = history.Count; i < imax; i++)
@@ -930,6 +931,9 @@ public int GetNextFrame(int start, bool isChange)
930931

931932
public int GetPreFrame(int start, bool isChange)
932933
{
934+
if (history.Count <= 0) return 0;
935+
936+
start = Math.Max(1, Math.Min(start, history.Count - 1));
933937
int ret = start;
934938
int frameCount = history[start].frameCount;
935939
for (int i = start - 1; i >= 0; i--)
@@ -950,7 +954,10 @@ public int GetPreFrame(int start, bool isChange)
950954

951955
public int GetNextProgramFrame(int start)
952956
{
957+
if (history.Count <= 0) return 0;
958+
start = Math.Max(1, Math.Min(start, history.Count - 1));
953959
int ret = start + 1;
960+
if (ret >= history.Count) return history.Count - 1;
954961

955962
var setting = LuaDeepProfilerSetting.Instance;
956963
for (int i = start + 1, imax = history.Count; i < imax; i++)

0 commit comments

Comments
 (0)