Skip to content

Commit 11b62cf

Browse files
authored
Merge pull request RawAccelOfficial#81 from a1xd/log-unhandled-ex
add handler for unhandled exceptions
2 parents 59e86a6 + 66f1f4c commit 11b62cf

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

common/rawaccel-version.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#define RA_VER_MAJOR 1
44
#define RA_VER_MINOR 4
5-
#define RA_VER_PATCH 2
5+
#define RA_VER_PATCH 3
66

77
#define RA_OS "Win7+"
88

grapher/Form1.cs

+9-6
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,16 @@ public RawAcceleration()
176176

177177
protected override void WndProc(ref Message m)
178178
{
179-
if (m.Msg == 0x00ff) // WM_INPUT
179+
if (!(AccelGUI is null))
180180
{
181-
AccelGUI.MouseWatcher.ReadMouseMove(m);
182-
}
183-
else if (m.Msg == 0x00fe) // WM_INPUT_DEVICE_CHANGE
184-
{
185-
AccelGUI.UpdateInputManagers();
181+
if (m.Msg == 0x00ff) // WM_INPUT
182+
{
183+
AccelGUI.MouseWatcher.ReadMouseMove(m);
184+
}
185+
else if (m.Msg == 0x00fe) // WM_INPUT_DEVICE_CHANGE
186+
{
187+
AccelGUI.UpdateInputManagers();
188+
}
186189
}
187190

188191
base.WndProc(ref m);

grapher/Program.cs

+11-2
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,20 @@ static void Main()
1919
return;
2020
}
2121

22+
AppDomain.CurrentDomain.UnhandledException += GlobalUnhandledExceptionHandler;
23+
2224
Application.EnableVisualStyles();
2325
Application.SetCompatibleTextRenderingDefault(false);
2426
Application.Run(new RawAcceleration());
25-
26-
GC.KeepAlive(mutex);
27+
28+
GC.KeepAlive(mutex);
29+
}
30+
31+
static void GlobalUnhandledExceptionHandler(object sender, UnhandledExceptionEventArgs e)
32+
{
33+
var ex = (Exception)e.ExceptionObject;
34+
System.IO.File.WriteAllText("error.log", ex.ToString());
35+
MessageBox.Show(ex.Message, "Error");
2736
}
2837
}
2938
}

0 commit comments

Comments
 (0)