Skip to content

Commit

Permalink
Added reference counting for on request loading (Mantis 6355)
Browse files Browse the repository at this point in the history
  • Loading branch information
obones committed Dec 4, 2014
1 parent 9e4ab04 commit d87ec8a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions jvcl/run/Hid.pas
Original file line number Diff line number Diff line change
Expand Up @@ -2167,6 +2167,7 @@ implementation
{$IFDEF HID_LINKONREQUEST}
var
HidLib: TModuleHandle = INVALID_MODULEHANDLE_VALUE;
HidLoadCount: Integer = 0;
{$ENDIF HID_LINKONREQUEST}

// (rom) this function is a macro and cannot be implemented with the original name
Expand Down Expand Up @@ -2213,6 +2214,9 @@ function IsHidLoaded: Boolean;
function LoadHid: Boolean;
begin
{$IFDEF HID_LINKONREQUEST}
Inc(HidLoadCount);
if HidLoadCount > 1 then
Exit;
Result := LoadModule(HidLib, HidModuleName);
if Result then
begin
Expand Down Expand Up @@ -2279,6 +2283,9 @@ function LoadHid: Boolean;
procedure UnloadHid;
begin
{$IFDEF HID_LINKONREQUEST}
Dec(HidLoadCount);
if HidLoadCount > 0 then
Exit;
UnloadModule(HidLib);
@HidD_Hello := nil;
@HidD_GetHidGuid := nil;
Expand Down

0 comments on commit d87ec8a

Please sign in to comment.