fix: OnDisable + Dispose 替代 OnDestroy + Close,修复 domain reload SQLite 崩溃
OnDisable 在 domain reload 前触发,Dispose() 清理 prepared statements 并调用 GC.SuppressFinalize,阻止 GC finalizer 线程崩溃
This commit is contained in:
parent
8366bfcb93
commit
5667aef495
Binary file not shown.
@ -22,7 +22,7 @@ namespace CounterDrone.Unity
|
||||
_service = new GroupService(new GroupRepository(_db));
|
||||
}
|
||||
|
||||
void OnDestroy() => _db?.Close();
|
||||
void OnDisable() { _db?.Dispose(); _db = null; }
|
||||
|
||||
public Group Create(string name, GroupType type, string desc = "")
|
||||
=> _service.CreateGroup(name, type, desc);
|
||||
|
||||
@ -24,7 +24,7 @@ namespace CounterDrone.Unity
|
||||
_service = new ModelService(new ModelRepository(_db), _paths);
|
||||
}
|
||||
|
||||
void OnDestroy() => _db?.Close();
|
||||
void OnDisable() { _db?.Dispose(); _db = null; }
|
||||
|
||||
public ModelInfo Import(string filePath, string name) => _service.ImportModel(filePath, name);
|
||||
public void Delete(string id) => _service.DeleteModel(id);
|
||||
|
||||
@ -22,7 +22,7 @@ namespace CounterDrone.Unity
|
||||
_service = new ReportService(_db, _paths);
|
||||
}
|
||||
|
||||
void OnDestroy() => _db?.Close();
|
||||
void OnDisable() { _db?.Dispose(); _db = null; }
|
||||
|
||||
public SimulationReport Generate(string taskId, TaskFullConfig cfg, List<SimEvent> events, string status, float duration)
|
||||
=> _service.Generate(taskId, cfg, events, status, duration);
|
||||
|
||||
@ -35,7 +35,7 @@ namespace CounterDrone.Unity
|
||||
}
|
||||
}
|
||||
|
||||
void OnDestroy() => _db?.Close();
|
||||
void OnDisable() { _db?.Dispose(); _db = null; }
|
||||
|
||||
public SimTask CreateTask(string name, string number) => _service.CreateTask(name, number);
|
||||
public void DeleteTask(string id) => _service.DeleteTask(id);
|
||||
|
||||
@ -149,7 +149,8 @@ namespace CounterDrone.Unity
|
||||
}
|
||||
|
||||
public void Stop() => _engine?.Stop();
|
||||
void OnDestroy() { Stop(); _db?.Close(); }
|
||||
void OnDisable() { _db?.Dispose(); _db = null; }
|
||||
void OnDestroy() => Stop();
|
||||
|
||||
private void SpawnDroneVisual(DroneEntity drone)
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user