diff --git a/Dalamud.Boot/veh.cpp b/Dalamud.Boot/veh.cpp index 194840e52..50ac9b34c 100644 --- a/Dalamud.Boot/veh.cpp +++ b/Dalamud.Boot/veh.cpp @@ -453,9 +453,3 @@ void veh::raise_external_event(const std::wstring& info) wcsncpy_s(g_external_event_info, info.c_str(), info_size); RaiseException(CUSTOM_EXCEPTION_EXTERNAL_EVENT, 0, 0, nullptr); } - -extern "C" __declspec(dllexport) void BootVehRaiseExternalEventW(LPCWSTR info) -{ - const std::wstring info_wstr(info); - veh::raise_external_event(info_wstr); -} diff --git a/Dalamud/EntryPoint.cs b/Dalamud/EntryPoint.cs index 0f8cb0480..15077f3d8 100644 --- a/Dalamud/EntryPoint.cs +++ b/Dalamud/EntryPoint.cs @@ -292,6 +292,7 @@ public sealed class EntryPoint } var pluginInfo = string.Empty; + var supportText = ", please visit us on Discord for more help"; try { var pm = Service.GetNullable(); @@ -299,6 +300,9 @@ public sealed class EntryPoint if (plugin != null) { pluginInfo = $"Plugin that caused this:\n{plugin.Name}\n\nClick \"Yes\" and remove it.\n\n"; + + if (plugin.IsThirdParty) + supportText = string.Empty; } } catch @@ -306,18 +310,31 @@ public sealed class EntryPoint // ignored } - Log.CloseAndFlush(); + const MESSAGEBOX_STYLE flags = MESSAGEBOX_STYLE.MB_YESNO | MESSAGEBOX_STYLE.MB_ICONERROR | MESSAGEBOX_STYLE.MB_SYSTEMMODAL; + var result = Windows.Win32.PInvoke.MessageBox( + new HWND(Process.GetCurrentProcess().MainWindowHandle), + $"An internal error in a Dalamud plugin occurred.\nThe game must close.\n\n{ex.GetType().Name}\n{info}\n\n{pluginInfo}More information has been recorded separately{supportText}.\n\nDo you want to disable all plugins the next time you start the game?", + "Dalamud", + flags); - ErrorHandling.CrashWithContext($"{ex}\n\n{info}\n\n{pluginInfo}"); + if (result == MESSAGEBOX_RESULT.IDYES) + { + Log.Information("User chose to disable plugins on next launch..."); + var config = Service.Get(); + config.PluginSafeMode = true; + config.ForceSave(); + } + + Log.CloseAndFlush(); + Environment.Exit(-1); break; default: Log.Fatal("Unhandled SEH object on AppDomain: {Object}", args.ExceptionObject); Log.CloseAndFlush(); + Environment.Exit(-1); break; } - - Environment.Exit(-1); } private static void OnUnhandledExceptionStallDebug(object sender, UnhandledExceptionEventArgs args) diff --git a/Dalamud/Interface/ImGuiSeStringRenderer/SeStringDrawParams.cs b/Dalamud/Interface/ImGuiSeStringRenderer/SeStringDrawParams.cs index 972013328..1d8126f3b 100644 --- a/Dalamud/Interface/ImGuiSeStringRenderer/SeStringDrawParams.cs +++ b/Dalamud/Interface/ImGuiSeStringRenderer/SeStringDrawParams.cs @@ -14,9 +14,8 @@ public record struct SeStringDrawParams /// (the default). /// /// If this value is set, will not be called, and ImGui ID will be ignored. - /// You must specify a valid draw list, a valid font via and if you set this value, + /// You must specify a valid draw list and a valid font via if you set this value, /// since the renderer will not be able to retrieve them from ImGui context. - /// Must be set when drawing off the main thread. /// public ImDrawListPtr? TargetDrawList { get; set; } @@ -30,13 +29,11 @@ public record struct SeStringDrawParams /// Gets or sets the font to use. /// Font to use, or null to use (the default). - /// Must be set when specifying a target draw-list or drawing off the main thread. public ImFontPtr? Font { get; set; } /// Gets or sets the font size. /// Font size in pixels, or 0 to use the current ImGui font size . /// - /// Must be set when specifying a target draw-list or drawing off the main thread. public float? FontSize { get; set; } /// Gets or sets the line height ratio. diff --git a/Dalamud/Interface/ImGuiSeStringRenderer/SeStringDrawState.cs b/Dalamud/Interface/ImGuiSeStringRenderer/SeStringDrawState.cs index 04d0501b1..11c1120b4 100644 --- a/Dalamud/Interface/ImGuiSeStringRenderer/SeStringDrawState.cs +++ b/Dalamud/Interface/ImGuiSeStringRenderer/SeStringDrawState.cs @@ -65,7 +65,7 @@ public unsafe ref struct SeStringDrawState this.drawList = ssdp.TargetDrawList.Value; this.ScreenOffset = Vector2.Zero; this.FontSize = ssdp.FontSize ?? throw new ArgumentException( - $"{nameof(ssdp.FontSize)} must be set when specifying a target draw list, as it cannot be fetched from the ImGui state."); + $"{nameof(ssdp.FontSize)} must be set to render outside the main thread."); this.WrapWidth = ssdp.WrapWidth ?? float.MaxValue; this.Color = ssdp.Color ?? uint.MaxValue; this.LinkHoverBackColor = 0; // Interactivity is unused outside the main thread. diff --git a/Dalamud/Interface/Internal/DalamudInterface.cs b/Dalamud/Interface/Internal/DalamudInterface.cs index bf55a5486..af78c5b0c 100644 --- a/Dalamud/Interface/Internal/DalamudInterface.cs +++ b/Dalamud/Interface/Internal/DalamudInterface.cs @@ -667,8 +667,6 @@ internal class DalamudInterface : IInternalDisposableService { if (this.isImGuiDrawDevMenu) { - using var barColor = ImRaii.PushColor(ImGuiCol.WindowBg, new Vector4(0.060f, 0.060f, 0.060f, 0.773f)); - barColor.Push(ImGuiCol.MenuBarBg, Vector4.Zero); if (ImGui.BeginMainMenuBar()) { var pluginManager = Service.Get(); @@ -841,11 +839,6 @@ internal class DalamudInterface : IInternalDisposableService ImGui.PopStyleVar(); } - if (ImGui.MenuItem("Raise external event through boot")) - { - ErrorHandling.CrashWithContext("Tést"); - } - ImGui.EndMenu(); } diff --git a/Dalamud/Utility/ErrorHandling.cs b/Dalamud/Utility/ErrorHandling.cs deleted file mode 100644 index 3c025a12e..000000000 --- a/Dalamud/Utility/ErrorHandling.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System.Runtime.InteropServices; - -namespace Dalamud.Utility; - -/// -/// Utilities for handling errors inside Dalamud. -/// -internal static partial class ErrorHandling -{ - /// - /// Crash the game at this point, and show the crash handler with the supplied context. - /// - /// The context to show in the crash handler. - public static void CrashWithContext(string context) - { - BootVehRaiseExternalEvent(context); - } - - [LibraryImport("Dalamud.Boot.dll", EntryPoint = "BootVehRaiseExternalEventW", StringMarshalling = StringMarshalling.Utf16)] - private static partial void BootVehRaiseExternalEvent(string info); -} diff --git a/DalamudCrashHandler/DalamudCrashHandler.cpp b/DalamudCrashHandler/DalamudCrashHandler.cpp index 3955bd983..1feec4b2f 100644 --- a/DalamudCrashHandler/DalamudCrashHandler.cpp +++ b/DalamudCrashHandler/DalamudCrashHandler.cpp @@ -1014,8 +1014,8 @@ int main() { config.pButtons = buttons; config.cButtons = ARRAYSIZE(buttons); config.nDefaultButton = IdButtonRestart; - config.pszExpandedControlText = L"Hide further information"; - config.pszCollapsedControlText = L"Further information for developers"; + config.pszExpandedControlText = L"Hide stack trace"; + config.pszCollapsedControlText = L"Stack trace for plugin developers"; config.pszExpandedInformation = window_log_str.c_str(); config.pszWindowTitle = L"Dalamud Crash Handler"; config.pRadioButtons = radios;