我有下面的代码:访问冲突异常德尔福的支援 - >的QueryInterface
for i := 0 to FControlList.Count - 1 do
if Supports(IMyControl(FControlList[i]), IMyControlEx) then
begin
MyControlEx := IMyControl(FControlList[i]) as IMyControlEx;
MyControlEx.DoYourMagic(Self, SomeData);
end;
此代码是我的应用程序执行期间被调用很多次,但在某些特定情况下它失败的支架内()方法。更具体地说 - 它似乎属于Supports()方法内的QueryInterface()调用。
我检查了FControlList不是零和FControlList [i]不为零,它仍然会发生。
任何想法可以理解的!
你能删除的支持投给IMyControl打电话?什么是FControlList,IInterfaceList? – mjn 2010-03-21 10:32:28
还要注意TControl可以有自己的生命周期管理,即使它们是TInterfacedPersistent的子类,它们也不使用引用计数。请参阅http://stackoverflow.com/questions/2182612 – mjn 2010-03-21 11:29:12
这只是因为TInterfacedPersistent不使用引用计数。否则使用TInterfacedObject。 – 2010-03-21 12:03:33