Skip to content

Commit 326c7b1

Browse files
committed
[修复]1. 修复子类获取数据可能为空的问题
1 parent 9ef9f30 commit 326c7b1

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

GameFrameX.Core/Components/StateComponent.cs

+11-3
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@ internal override bool ReadyToInactive
112112
/// 激活状态的时候异步读取数据
113113
/// </summary>
114114
/// <returns>返回查询的数据结果对象,没有数据返回null</returns>
115-
protected virtual Task<TState> ActiveReadStateAsync()
115+
protected virtual async Task ActiveReadStateAsync()
116116
{
117-
return null;
117+
await Task.CompletedTask;
118118
}
119119

120120
/// <summary>
@@ -123,7 +123,15 @@ protected virtual Task<TState> ActiveReadStateAsync()
123123
/// <returns></returns>
124124
public async Task ReadStateAsync()
125125
{
126-
State = await ActiveReadStateAsync();
126+
try
127+
{
128+
await ActiveReadStateAsync();
129+
}
130+
catch (Exception e)
131+
{
132+
LogHelper.Error(e);
133+
}
134+
127135
if (State.IsNull())
128136
{
129137
State = await GameDb.FindAsync<TState>(ActorId);

0 commit comments

Comments
 (0)