Skip to content

Commit

Permalink
[fix] FanControl was not disposed on call to Stop() because it was al…
Browse files Browse the repository at this point in the history
…ready marked as disposed.
  • Loading branch information
hirschmann committed May 22, 2014
1 parent b572087 commit e6e7f05
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 28 deletions.
15 changes: 15 additions & 0 deletions NbfcSetup/Configs.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,21 @@
<Component Id="cmpC44EFEBABECB63D258739911099329A1" Directory="dir42B6B52760D807EF6B53FE218617E2D6" Guid="*">
<File Id="filC05321758B1FA1B7BE703A6B35EE38B1" KeyPath="yes" Source="$(var.ConfigsDir)\Acer Aspire 1825PTZ.xml" />
</Component>
<Component Id="cmpB4D731767D9B54C3B31DCD01F1B102D0" Directory="dir42B6B52760D807EF6B53FE218617E2D6" Guid="*">
<File Id="fil22DDA4DD710E4CCC6B76B89CCBCB20CC" KeyPath="yes" Source="$(var.ConfigsDir)\Acer Aspire 5738G.xml" />
</Component>
<Component Id="cmpC0795ECB5FB91D448337AC58831AB910" Directory="dir42B6B52760D807EF6B53FE218617E2D6" Guid="*">
<File Id="fil52B50575765079A6493D16EB7F1CC36F" KeyPath="yes" Source="$(var.ConfigsDir)\Acer Aspire 5930.xml" />
</Component>
<Component Id="cmp35DA0C4F6296CE79607B94F0A3085C62" Directory="dir42B6B52760D807EF6B53FE218617E2D6" Guid="*">
<File Id="filECFA816057C0C833D042C2D88BC9AE8C" KeyPath="yes" Source="$(var.ConfigsDir)\Acer Aspire 7551G.xml" />
</Component>
<Component Id="cmp73E51126EC5D80726E5E0573DF8F2139" Directory="dir42B6B52760D807EF6B53FE218617E2D6" Guid="*">
<File Id="fil6F7C4D5BE5A5781F205B66620A7F62EC" KeyPath="yes" Source="$(var.ConfigsDir)\Acer Aspire 7735.xml" />
</Component>
<Component Id="cmpF4E96941555B91560BAC8025D9512327" Directory="dir42B6B52760D807EF6B53FE218617E2D6" Guid="*">
<File Id="fil5D70EDE59E8BDCAA79164BAD37A4E04D" KeyPath="yes" Source="$(var.ConfigsDir)\Acer Aspire 7741G.xml" />
</Component>
<Component Id="cmp3557EB72E8E98F4BBD32BFBC7E825026" Directory="dir42B6B52760D807EF6B53FE218617E2D6" Guid="*">
<File Id="fil782B91716C8C0FD6D15A1AA19436A032" KeyPath="yes" Source="$(var.ConfigsDir)\Acer Aspire LT-10Q.xml" />
</Component>
Expand Down Expand Up @@ -73,6 +82,9 @@
<Component Id="cmpD086105289B944ED3B305922651396C8" Directory="dir42B6B52760D807EF6B53FE218617E2D6" Guid="*">
<File Id="fil25401F2CECA3E2ABCD52FCB70B663A57" KeyPath="yes" Source="$(var.ConfigsDir)\Asus Zenbook UX32A.xml" />
</Component>
<Component Id="cmp578E6F9D223FDEA8EE9910CB3D4B0C6A" Directory="dir42B6B52760D807EF6B53FE218617E2D6" Guid="*">
<File Id="filE458BF9417FB4D3E82FC490330C05113" KeyPath="yes" Source="$(var.ConfigsDir)\Asus Zenbook UX32LN.xml" />
</Component>
<Component Id="cmpEE41396EC16FF3E82DB7189A069C6057" Directory="dir42B6B52760D807EF6B53FE218617E2D6" Guid="*">
<File Id="fil4E6DC583C3EFD0FF9DBFF3E2EB5CEE51" KeyPath="yes" Source="$(var.ConfigsDir)\Asus Zenbook UX32VD.xml" />
</Component>
Expand Down Expand Up @@ -133,6 +145,9 @@
<Component Id="cmp08E4B62915B894B885B146B0E34D3F73" Directory="dir42B6B52760D807EF6B53FE218617E2D6" Guid="*">
<File Id="fil7F5008181DDA358A4635B9CF1A9C0BB3" KeyPath="yes" Source="$(var.ConfigsDir)\HP ProBook 4720s.xml" />
</Component>
<Component Id="cmp414E31CDADE98F0F7A4A78192DA8FB45" Directory="dir42B6B52760D807EF6B53FE218617E2D6" Guid="*">
<File Id="fil178FB081BC7A9958E5A84EE280EADA97" KeyPath="yes" Source="$(var.ConfigsDir)\HP ProBook 5330m.xml" />
</Component>
<Component Id="cmp5D780640405364A89CDB4E6587F60ADA" Directory="dir42B6B52760D807EF6B53FE218617E2D6" Guid="*">
<File Id="filEF5249934DB5BEA582F7B4C51925C6C1" KeyPath="yes" Source="$(var.ConfigsDir)\HP ProBook 6460b.xml" />
</Component>
Expand Down
2 changes: 1 addition & 1 deletion NbfcSetup/Constants.wxi
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
<?define CompanyName = "StagWare"?>
<?define ProductName = "NoteBook FanControl"?>
<?define UpgradeGuid = "5602C3F6-014B-41DD-B89F-14BCB1701B57"?>
<?define Version = "1.1.0.17"?>
<?define Version = "1.1.0.18"?>
</Include>
21 changes: 15 additions & 6 deletions NbfcSetup/Product.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,10 @@
<Component Id="Service" Guid="A178E4FC-45EF-4246-B946-EC6CC879A26C">
<File Id="NbfcService.exe" Name="NbfcService.exe" DiskId="1" Vital="yes" KeyPath="yes"
Source="$(var.NbfcService.TargetDir)NbfcService.exe">
<netfx:NativeImage Id="NbfcServiceNativeImage" Priority="1" Platform="all"/>

<?if $(var.Configuration) = "Release"?>
<netfx:NativeImage Id="NbfcServiceNativeImage" Priority="1" Platform="all"/>
<?endif?>
</File>

<ServiceInstall Id="ServiceInstaller" Type="ownProcess" Vital="yes" Name="NbfcService" Start="auto"
Expand Down Expand Up @@ -140,10 +143,13 @@

<Component Id="Client" Guid="6CD59558-48F7-4E1E-B4F6-470F8510D57A">
<File Id="NoteBookFanControl.exe" Name="NoteBook FanControl.exe" DiskId="1" Vital="yes" KeyPath="yes"
Source="$(var.NbfcServiceClient.TargetDir)NoteBook FanControl.exe">
<netfx:NativeImage Id="NoteBookFanControlNativeImage" Priority="1" Platform="all"/>
Source="$(var.NbfcServiceClient.TargetDir)NoteBook FanControl.exe">
<Shortcut Id="ClientStartMenuShortcut" Directory="ProgramMenuProductFolder" Name="$(var.ProductName)"
Icon="Nbfc.ico" Advertise="yes" />
Icon="Nbfc.ico" Advertise="yes" />

<?if $(var.Configuration) = "Release"?>
<netfx:NativeImage Id="NoteBookFanControlNativeImage" Priority="1" Platform="all" />
<?endif?>
</File>
</Component>

Expand All @@ -159,10 +165,13 @@

<Component Id="ConfigEditor" Guid="C3D8D023-75AB-49F5-B276-75E80FA87DBF">
<File Id="ConfigEditor.exe" Name="ConfigEditor.exe" DiskId="1" Vital="yes" KeyPath="yes"
Source="$(var.ConfigEditor.TargetDir)ConfigEditor.exe">
<netfx:NativeImage Id="ConfigEditorNativeImage" Priority="1" Platform="all"/>
Source="$(var.ConfigEditor.TargetDir)ConfigEditor.exe">
<Shortcut Id="EditorStartMenuShortcut" Directory="ProgramMenuProductFolder" Name="Config Editor"
Icon="Nbfc.ico" Advertise="yes" />

<?if $(var.Configuration) = "Release"?>
<netfx:NativeImage Id="ConfigEditorNativeImage" Priority="1" Platform="all"></netfx:NativeImage>
<?endif?>
</File>
</Component>

Expand Down
47 changes: 26 additions & 21 deletions StagWare.FanControl.Service/FanControlService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public void Stop()
if (this.initialized)
{
initialized = false;
Dispose();
DisposeFanControl();

using (var settings = ServiceSettings.Load(SettingsDir))
{
Expand Down Expand Up @@ -157,26 +157,7 @@ private void Dispose(bool disposeManagedResources)
{
if (disposeManagedResources)
{
if (fanControl != null)
{
try
{
using (var settings = ServiceSettings.Load(SettingsDir))
{
settings.AutoStart = this.initialized;
settings.TargetFanSpeeds = fanControl.FanInformation
.Select(x => x.AutoFanControlEnabled ? AutoControlFanSpeedPercentage : x.TargetFanSpeed).ToArray();

settings.Save();
}
}
catch
{
}

fanControl.Dispose();
fanControl = null;
}
DisposeFanControl();
}

disposed = true;
Expand Down Expand Up @@ -281,6 +262,30 @@ private bool Restart(ServiceSettings settings)
return this.initialized;
}

private void DisposeFanControl()
{
if (fanControl != null)
{
try
{
using (var settings = ServiceSettings.Load(SettingsDir))
{
settings.AutoStart = this.initialized;
settings.TargetFanSpeeds = fanControl.FanInformation
.Select(x => x.AutoFanControlEnabled ? AutoControlFanSpeedPercentage : x.TargetFanSpeed).ToArray();

settings.Save();
}
}
catch
{
}

fanControl.Dispose();
fanControl = null;
}
}

#endregion
}
}

0 comments on commit e6e7f05

Please sign in to comment.