mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-13 12:14:16 +01:00
Fix crash on regex error (#1477)
* Fix crash on regex error * Don't clear copylog flag until the end of the draw
This commit is contained in:
parent
df2474bc87
commit
b6897f3a8b
1 changed files with 112 additions and 96 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
@ -12,6 +12,7 @@ using Dalamud.Game.Command;
|
||||||
using Dalamud.Interface.Colors;
|
using Dalamud.Interface.Colors;
|
||||||
using Dalamud.Interface.Components;
|
using Dalamud.Interface.Components;
|
||||||
using Dalamud.Interface.Utility;
|
using Dalamud.Interface.Utility;
|
||||||
|
using Dalamud.Interface.Utility.Raii;
|
||||||
using Dalamud.Interface.Windowing;
|
using Dalamud.Interface.Windowing;
|
||||||
using Dalamud.Logging.Internal;
|
using Dalamud.Logging.Internal;
|
||||||
using Dalamud.Plugin.Internal;
|
using Dalamud.Plugin.Internal;
|
||||||
|
|
@ -47,6 +48,7 @@ internal class ConsoleWindow : Window, IDisposable
|
||||||
private bool killGameArmed;
|
private bool killGameArmed;
|
||||||
private bool autoScroll;
|
private bool autoScroll;
|
||||||
private bool autoOpen;
|
private bool autoOpen;
|
||||||
|
private bool regexError;
|
||||||
|
|
||||||
private int historyPos;
|
private int historyPos;
|
||||||
private int copyStart = -1;
|
private int copyStart = -1;
|
||||||
|
|
@ -111,7 +113,6 @@ internal class ConsoleWindow : Window, IDisposable
|
||||||
public void CopyLog()
|
public void CopyLog()
|
||||||
{
|
{
|
||||||
ImGui.LogToClipboard();
|
ImGui.LogToClipboard();
|
||||||
this.copyLog = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -145,6 +146,13 @@ internal class ConsoleWindow : Window, IDisposable
|
||||||
|
|
||||||
this.DrawFilterToolbar();
|
this.DrawFilterToolbar();
|
||||||
|
|
||||||
|
if (this.regexError)
|
||||||
|
{
|
||||||
|
const string regexErrorString = "Regex Filter Error";
|
||||||
|
ImGui.SetCursorPosX(ImGui.GetContentRegionMax().X / 2.0f - ImGui.CalcTextSize(regexErrorString).X / 2.0f);
|
||||||
|
ImGui.TextColored(KnownColor.OrangeRed.Vector(), regexErrorString);
|
||||||
|
}
|
||||||
|
|
||||||
ImGui.BeginChild("scrolling", new Vector2(0, ImGui.GetFrameHeightWithSpacing() - 55 * ImGuiHelpers.GlobalScale), false, ImGuiWindowFlags.AlwaysHorizontalScrollbar | ImGuiWindowFlags.AlwaysVerticalScrollbar);
|
ImGui.BeginChild("scrolling", new Vector2(0, ImGui.GetFrameHeightWithSpacing() - 55 * ImGuiHelpers.GlobalScale), false, ImGuiWindowFlags.AlwaysHorizontalScrollbar | ImGuiWindowFlags.AlwaysVerticalScrollbar);
|
||||||
|
|
||||||
if (this.clearLog) this.Clear();
|
if (this.clearLog) this.Clear();
|
||||||
|
|
@ -276,6 +284,8 @@ internal class ConsoleWindow : Window, IDisposable
|
||||||
{
|
{
|
||||||
this.ProcessCommand();
|
this.ProcessCommand();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.copyLog = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleCopyMode(int i, LogEntry line)
|
private void HandleCopyMode(int i, LogEntry line)
|
||||||
|
|
@ -440,8 +450,9 @@ internal class ConsoleWindow : Window, IDisposable
|
||||||
if (!this.showFilterToolbar) return;
|
if (!this.showFilterToolbar) return;
|
||||||
|
|
||||||
PluginFilterEntry? removalEntry = null;
|
PluginFilterEntry? removalEntry = null;
|
||||||
if (ImGui.BeginTable("plugin_filter_entries", 4, ImGuiTableFlags.Resizable | ImGuiTableFlags.BordersInnerV))
|
using var table = ImRaii.Table("plugin_filter_entries", 4, ImGuiTableFlags.Resizable | ImGuiTableFlags.BordersInnerV);
|
||||||
{
|
if (!table) return;
|
||||||
|
|
||||||
ImGui.TableSetupColumn("##remove_button", ImGuiTableColumnFlags.WidthFixed, 25.0f * ImGuiHelpers.GlobalScale);
|
ImGui.TableSetupColumn("##remove_button", ImGuiTableColumnFlags.WidthFixed, 25.0f * ImGuiHelpers.GlobalScale);
|
||||||
ImGui.TableSetupColumn("##source_name", ImGuiTableColumnFlags.WidthFixed, 150.0f * ImGuiHelpers.GlobalScale);
|
ImGui.TableSetupColumn("##source_name", ImGuiTableColumnFlags.WidthFixed, 150.0f * ImGuiHelpers.GlobalScale);
|
||||||
ImGui.TableSetupColumn("##log_level", ImGuiTableColumnFlags.WidthFixed, 150.0f * ImGuiHelpers.GlobalScale);
|
ImGui.TableSetupColumn("##log_level", ImGuiTableColumnFlags.WidthFixed, 150.0f * ImGuiHelpers.GlobalScale);
|
||||||
|
|
@ -526,9 +537,6 @@ internal class ConsoleWindow : Window, IDisposable
|
||||||
if (ImGui.IsItemDeactivatedAfterEdit()) this.Refilter();
|
if (ImGui.IsItemDeactivatedAfterEdit()) this.Refilter();
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.EndTable();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (removalEntry is { } toRemove)
|
if (removalEntry is { } toRemove)
|
||||||
{
|
{
|
||||||
this.pluginFilters.Remove(toRemove);
|
this.pluginFilters.Remove(toRemove);
|
||||||
|
|
@ -540,7 +548,7 @@ internal class ConsoleWindow : Window, IDisposable
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (this.commandText is['/', ..])
|
if (this.commandText.StartsWith('/'))
|
||||||
{
|
{
|
||||||
this.commandText = this.commandText[1..];
|
this.commandText = this.commandText[1..];
|
||||||
}
|
}
|
||||||
|
|
@ -654,13 +662,11 @@ internal class ConsoleWindow : Window, IDisposable
|
||||||
HasException = logEvent.Exception != null,
|
HasException = logEvent.Exception != null,
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO (v9): Remove SourceContext property check.
|
|
||||||
if (logEvent.Properties.ContainsKey("Dalamud.ModuleName"))
|
if (logEvent.Properties.ContainsKey("Dalamud.ModuleName"))
|
||||||
{
|
{
|
||||||
entry.Source = "DalamudInternal";
|
entry.Source = "DalamudInternal";
|
||||||
}
|
}
|
||||||
else if ((logEvent.Properties.TryGetValue("Dalamud.PluginName", out var sourceProp) ||
|
else if (logEvent.Properties.TryGetValue("Dalamud.PluginName", out var sourceProp) &&
|
||||||
logEvent.Properties.TryGetValue("SourceContext", out sourceProp)) &&
|
|
||||||
sourceProp is ScalarValue { Value: string sourceValue })
|
sourceProp is ScalarValue { Value: string sourceValue })
|
||||||
{
|
{
|
||||||
entry.Source = sourceValue;
|
entry.Source = sourceValue;
|
||||||
|
|
@ -673,6 +679,8 @@ internal class ConsoleWindow : Window, IDisposable
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsFilterApplicable(LogEntry entry)
|
private bool IsFilterApplicable(LogEntry entry)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
// If this entry is below a newly set minimum level, fail it
|
// If this entry is below a newly set minimum level, fail it
|
||||||
if (EntryPoint.LogLevelSwitch.MinimumLevel > entry.Level)
|
if (EntryPoint.LogLevelSwitch.MinimumLevel > entry.Level)
|
||||||
|
|
@ -701,6 +709,14 @@ internal class ConsoleWindow : Window, IDisposable
|
||||||
|
|
||||||
return allowedLevel && matchesContent;
|
return allowedLevel && matchesContent;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
this.regexError = true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.regexError = false;
|
||||||
|
|
||||||
// else we couldn't find a filter for this entry, if we have any filters, we need to block this entry.
|
// else we couldn't find a filter for this entry, if we have any filters, we need to block this entry.
|
||||||
return !this.pluginFilters.Any();
|
return !this.pluginFilters.Any();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue