Skip to content

Commit

Permalink
add handler for unhandled exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
a1xd committed Mar 11, 2021
1 parent 59e86a6 commit 66f1f4c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
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");
}
}
}

0 comments on commit 66f1f4c

Please sign in to comment.