mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-16 05:59:28 +02:00
* hopefully fpc_intf_assign_by_iid improved
git-svn-id: trunk@5842 -
This commit is contained in:
parent
fa493c7898
commit
4c7c5e5adf
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -7904,6 +7904,7 @@ tests/webtbs/tw6735.pp svneol=native#text/plain
|
||||
tests/webtbs/tw6742.pp svneol=native#text/plain
|
||||
tests/webtbs/tw6767.pp svneol=native#text/plain
|
||||
tests/webtbs/tw6865.pp svneol=native#text/plain
|
||||
tests/webtbs/tw6868.pp svneol=native#text/plain
|
||||
tests/webtbs/tw6960.pp svneol=native#text/plain
|
||||
tests/webtbs/tw6977.pp svneol=native#text/plain
|
||||
tests/webtbs/tw6980.pp svneol=native#text/plain
|
||||
|
@ -78,13 +78,25 @@
|
||||
end;
|
||||
|
||||
procedure fpc_intf_assign_by_iid(var D: pointer; const S: pointer; const iid: TGUID);[public,alias: 'FPC_INTF_ASSIGN2']; compilerproc;
|
||||
var
|
||||
tmp : pointer;
|
||||
begin
|
||||
if assigned(D) then
|
||||
IUnknown(D)._Release;
|
||||
if assigned(S) then
|
||||
IUnknown(S).QueryInterface(iid, D)
|
||||
begin
|
||||
if IUnknown(S).QueryInterface(iid,tmp)<>S_OK then
|
||||
handleerror(219);
|
||||
if assigned(tmp) then
|
||||
IUnknown(tmp)._AddRef;
|
||||
if assigned(D) then
|
||||
IUnknown(D)._Release;
|
||||
D:=tmp;
|
||||
end
|
||||
else
|
||||
D := nil;
|
||||
begin
|
||||
if assigned(D) then
|
||||
IUnknown(D)._Release;
|
||||
D:=nil;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
|
29
tests/webtbs/tw6868.pp
Normal file
29
tests/webtbs/tw6868.pp
Normal file
@ -0,0 +1,29 @@
|
||||
program project1;
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
uses Classes, SysUtils;
|
||||
|
||||
type IHelpSystem = interface(IInterface) end;
|
||||
THelpManager = class(TInterfacedObject, IHelpSystem) end;
|
||||
|
||||
var HelpManager : THelpManager = nil;
|
||||
function GetHelpSystem(out H: IHelpSystem) : Integer;
|
||||
begin
|
||||
if HelpManager = nil then HelpManager := THelpManager.Create; // if help manager is not created here, it works
|
||||
H := HelpManager; // <-- remove this and it works
|
||||
result := 0;
|
||||
end;
|
||||
|
||||
procedure FreeHelpSystem;
|
||||
begin
|
||||
if HelpManager <> nil then
|
||||
HelpManager._Release;
|
||||
HelpManager := nil;
|
||||
end;
|
||||
|
||||
var h : IHelpSystem;
|
||||
begin
|
||||
GetHelpSystem(h);
|
||||
FreeHelpSystem;
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user