log error fix

This commit is contained in:
Frank Skare
2020-05-04 15:15:40 +02:00
parent 51f9e17380
commit 415fd266a2
3 changed files with 14 additions and 13 deletions

View File

@@ -1,8 +1,8 @@
5.4.5.2 Beta (not yet released)
5.4.6.1 Beta (not yet released)
============
- log error fix
5.4.6.0

View File

@@ -89,13 +89,6 @@ namespace mpvnet
core.Shutdown += Shutdown;
core.Initialized += Initialized;
core.LogMessage += ShowFatalError;
}
static void ShowFatalError(mpv_log_level level, string msg)
{
if (!App.IsStartedFromTerminal && level == mpv_log_level.MPV_LOG_LEVEL_FATAL)
Msg.ShowError(msg);
}
public static void RunAction(Action action)

View File

@@ -396,10 +396,18 @@ namespace mpvnet
case mpv_event_id.MPV_EVENT_LOG_MESSAGE:
{
var data = (mpv_event_log_message)Marshal.PtrToStructure(evt.data, typeof(mpv_event_log_message));
mpv_log_level level = data.log_level;
string msg = $"[{ConvertFromUtf8(data.prefix)}] {ConvertFromUtf8(data.text)}";
InvokeAsync<mpv_log_level, string>(LogMessageAsync, level, msg);
LogMessage?.Invoke(level, msg);
if (LogMessage != null || LogMessageAsync != null ||
data.log_level == mpv_log_level.MPV_LOG_LEVEL_FATAL)
{
string msg = $"[{ConvertFromUtf8(data.prefix)}] {ConvertFromUtf8(data.text)}";
if (data.log_level == mpv_log_level.MPV_LOG_LEVEL_FATAL)
App.RunAction(() => App.ShowError("Fatal Error", msg));
InvokeAsync<mpv_log_level, string>(LogMessageAsync, data.log_level, msg);
LogMessage?.Invoke(data.log_level, msg);
}
}
break;
case mpv_event_id.MPV_EVENT_CLIENT_MESSAGE: