Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add handler for unhandled exceptions #81

Merged
merged 1 commit into from
Mar 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion common/rawaccel-version.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#define RA_VER_MAJOR 1
#define RA_VER_MINOR 4
#define RA_VER_PATCH 2
#define RA_VER_PATCH 3

#define RA_OS "Win7+"

Expand Down
15 changes: 9 additions & 6 deletions grapher/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,16 @@ public RawAcceleration()

protected override void WndProc(ref Message m)
{
if (m.Msg == 0x00ff) // WM_INPUT
if (!(AccelGUI is null))
{
AccelGUI.MouseWatcher.ReadMouseMove(m);
}
else if (m.Msg == 0x00fe) // WM_INPUT_DEVICE_CHANGE
{
AccelGUI.UpdateInputManagers();
if (m.Msg == 0x00ff) // WM_INPUT
{
AccelGUI.MouseWatcher.ReadMouseMove(m);
}
else if (m.Msg == 0x00fe) // WM_INPUT_DEVICE_CHANGE
{
AccelGUI.UpdateInputManagers();
}
}

base.WndProc(ref m);
Expand Down
13 changes: 11 additions & 2 deletions grapher/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,20 @@ static void Main()
return;
}

AppDomain.CurrentDomain.UnhandledException += GlobalUnhandledExceptionHandler;

Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new RawAcceleration());

GC.KeepAlive(mutex);

GC.KeepAlive(mutex);
}

static void GlobalUnhandledExceptionHandler(object sender, UnhandledExceptionEventArgs e)
{
var ex = (Exception)e.ExceptionObject;
System.IO.File.WriteAllText("error.log", ex.ToString());
MessageBox.Show(ex.Message, "Error");
}
}
}