mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-01-02 13:53: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 {
|
class DalamudLogWindow : IDisposable {
|
||||||
private readonly CommandManager commandManager;
|
private readonly CommandManager commandManager;
|
||||||
private bool autoScroll = true;
|
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;
|
private string commandText = string.Empty;
|
||||||
|
|
||||||
|
|
@ -44,11 +46,15 @@ namespace Dalamud.Interface
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Clear() {
|
public void Clear() {
|
||||||
this.logText.Clear();
|
lock (this.renderLock) {
|
||||||
|
this.logText.Clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddLog(string line, Vector4 color) {
|
public void AddLog(string line, Vector4 color) {
|
||||||
this.logText.Add((line, color));
|
lock (this.renderLock) {
|
||||||
|
this.logText.Add((line, color));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Draw() {
|
public bool Draw() {
|
||||||
|
|
@ -98,8 +104,10 @@ namespace Dalamud.Interface
|
||||||
|
|
||||||
ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(0, 0));
|
ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(0, 0));
|
||||||
|
|
||||||
foreach (var valueTuple in this.logText) {
|
lock (this.renderLock) {
|
||||||
ImGui.TextColored(valueTuple.color, valueTuple.line);
|
foreach (var (line, color) in this.logText) {
|
||||||
|
ImGui.TextColored(color, line);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.PopStyleVar();
|
ImGui.PopStyleVar();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue