mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-01-02 05:43:40 +01:00
fix: thread-safety issue in log window
This commit is contained in:
parent
0a84d1c95b
commit
2868bd7227
1 changed files with 13 additions and 5 deletions
|
|
@ -14,7 +14,9 @@ namespace Dalamud.Interface
|
|||
class DalamudLogWindow : IDisposable {
|
||||
private readonly CommandManager commandManager;
|
||||
private bool autoScroll = true;
|
||||
private List<(string line, Vector4 color)> logText = new List<(string line, Vector4 color)>();
|
||||
private readonly List<(string line, Vector4 color)> logText = new List<(string line, Vector4 color)>();
|
||||
|
||||
private readonly object renderLock = new object();
|
||||
|
||||
private string commandText = string.Empty;
|
||||
|
||||
|
|
@ -44,11 +46,15 @@ namespace Dalamud.Interface
|
|||
}
|
||||
|
||||
public void Clear() {
|
||||
this.logText.Clear();
|
||||
lock (this.renderLock) {
|
||||
this.logText.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
public void AddLog(string line, Vector4 color) {
|
||||
this.logText.Add((line, color));
|
||||
lock (this.renderLock) {
|
||||
this.logText.Add((line, color));
|
||||
}
|
||||
}
|
||||
|
||||
public bool Draw() {
|
||||
|
|
@ -98,8 +104,10 @@ namespace Dalamud.Interface
|
|||
|
||||
ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(0, 0));
|
||||
|
||||
foreach (var valueTuple in this.logText) {
|
||||
ImGui.TextColored(valueTuple.color, valueTuple.line);
|
||||
lock (this.renderLock) {
|
||||
foreach (var (line, color) in this.logText) {
|
||||
ImGui.TextColored(color, line);
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.PopStyleVar();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue