mirror of
https://github.com/2dust/v2rayN.git
synced 2025-07-01 12:32:10 +00:00
fix: 当过滤器是无效的正则时, 会输出大量异常日志
This commit is contained in:
parent
4eb076540e
commit
8285688ec9
1 changed files with 21 additions and 7 deletions
|
@ -11,6 +11,10 @@ namespace v2rayN.Views
|
||||||
public partial class MsgView
|
public partial class MsgView
|
||||||
{
|
{
|
||||||
private static Config _config;
|
private static Config _config;
|
||||||
|
|
||||||
|
private string lastMsgFilter;
|
||||||
|
private bool lastMsgFilterNotAvailable;
|
||||||
|
|
||||||
public MsgView()
|
public MsgView()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
@ -28,29 +32,39 @@ namespace v2rayN.Views
|
||||||
|
|
||||||
void DelegateAppendText(string msg)
|
void DelegateAppendText(string msg)
|
||||||
{
|
{
|
||||||
Dispatcher.BeginInvoke(new Action<string>(AppendText), DispatcherPriority.Send, msg);
|
Dispatcher.BeginInvoke(AppendText, DispatcherPriority.Send, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AppendText(string msg)
|
public void AppendText(string msg)
|
||||||
{
|
{
|
||||||
if (msg.Equals(Global.CommandClearMsg))
|
if (msg == Global.CommandClearMsg)
|
||||||
{
|
{
|
||||||
ClearMsg();
|
ClearMsg();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!togAutoRefresh.IsChecked.Value)
|
if (togAutoRefresh.IsChecked == false)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var MsgFilter = cmbMsgFilter.Text.TrimEx();
|
var MsgFilter = cmbMsgFilter.Text.TrimEx();
|
||||||
if (!Utils.IsNullOrEmpty(MsgFilter))
|
if (MsgFilter != lastMsgFilter) lastMsgFilterNotAvailable = false;
|
||||||
|
if (!string.IsNullOrEmpty(MsgFilter) && !lastMsgFilterNotAvailable)
|
||||||
{
|
{
|
||||||
if (!Regex.IsMatch(msg, MsgFilter))
|
try
|
||||||
{
|
{
|
||||||
return;
|
if (!Regex.IsMatch(msg, MsgFilter)) // 如果不是正则表达式会异常
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
lastMsgFilterNotAvailable = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
lastMsgFilter = MsgFilter;
|
||||||
|
|
||||||
ShowMsg(msg);
|
ShowMsg(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue