Corrected unregister notify call

Changed location and corrected used handle
This commit is contained in:
Travis Nickles 2018-10-24 21:41:29 -05:00
parent dfcc3250cf
commit 687ff05948

View File

@ -57,6 +57,7 @@ namespace DS4Windows
bool turnOffTemp;
bool runningBat;
private bool changingService;
private IntPtr regHandle = new IntPtr();
private static DS4Form instance;
Dictionary<Control, string> hoverTextDict = new Dictionary<Control, string>();
// 0 index is used for application version text. 1 - 4 indices are used for controller status
@ -1049,8 +1050,7 @@ Properties.Resources.DS4Update, MessageBoxButtons.YesNo, MessageBoxIcon.Question
{
Guid hidGuid = new Guid();
NativeMethods.HidD_GetHidGuid(ref hidGuid);
IntPtr outHandle = new IntPtr();
bool result = ScpDevice.RegisterNotify(this.Handle, hidGuid, ref outHandle);
bool result = ScpDevice.RegisterNotify(this.Handle, hidGuid, ref regHandle);
if (!result)
{
ScpForm_Closing(this,
@ -1080,11 +1080,6 @@ Properties.Resources.DS4Update, MessageBoxButtons.YesNo, MessageBoxIcon.Question
}
break;
}
case WM_CLOSE:
{
ScpDevice.UnregisterNotify(Handle);
break;
}
case WM_QUERYENDSESSION:
{
systemShutdown = true;
@ -2176,6 +2171,14 @@ Properties.Resources.DS4Update, MessageBoxButtons.YesNo, MessageBoxIcon.Question
e.Cancel = true;
return;
}
else
{
ScpDevice.UnregisterNotify(regHandle);
}
}
else
{
ScpDevice.UnregisterNotify(Handle);
}
}
else if (userClosing && closeMini && !contextclose)