|

楼主 |
发表于 2009-12-17 19:31:17
|
显示全部楼层
找到原因了。但是不知道为什么?
问题就出在下面这段代码中:
function TtestPermission.Invoke(var Params: array of object): object;
var
up: array of string;
s: String;
lOrgUnit: TOrgUnit;
lOrgFuncKind:TOrgFuncKind;
lOrgFuncAllocItems:TOrgFuncAllocItems;
i:integer;
j:integer;
begin
result:=0;
s := objectHelper.ToString(Params[0]);
if s <> nil then
up :=s.Split([';']);//用户名和功能之间中不能有“;”号^_^
// lOrgUnit:=TOrgUnit.Create;
lOrgUnit:=org.OrgSys.OrgSystem.FindUnit('','',up[0]);
lOrgFuncKind:= TOrgFuncKind.ofkRun;
lOrgFuncAllocItems := TOrgFuncAllocItems.Create;
try
OrgSys.OrgSystem.GetAllFunc(lOrgUnit,lOrgFuncKind,lOrgFuncAllocItems);
for I := 0 to lOrgFuncAllocItems.Count - 1 do
begin
for j:=1 to up.Length-1 do
begin
if stringutils.PosIgnoreCase(up[j],TOrgFuncAllocItem(lOrgFuncAllocItems.Items).FuncURL)=1 then
begin
Result:=1;
break;
end;
end;//end for j
if Result=1 then
break;
end;
finally
lOrgFuncAllocItems.Free;
// lOrgUnit.Free;
end;
end;
就是注释的这两句:
// lOrgUnit:=TOrgUnit.Create;
// lOrgUnit.Free;
这两句注释了就不出错了。之前出错,就是因为我create了一下,又free了一下引起的。
但是我就不明白了,为什么会这样?
即便真的不用create,那我create一下到底影响什么了? |
|