我突然注意到我们的代码库中有一个TDataModuleTestExchange(nil)
'构造函数调用':
procedure TDialoogConfigExchange.ButtonTestClick(Sender: TObject);
var
lDataModuleTestExchange: TDataModuleTestExchange;
lResult : Boolean;
begin
inherited;
[snip]
begin
lDataModuleTestExchange := TDataModuleTestExchange(nil); // *** HERE ***
try
lResult := lDataModuleTestExchange.GetCalendarFolder(EditHost.Text,EditGebruiker.Text,EditWachtwoord.Text);
if lResult then
ToonMelding(sExchangeTestGelukt, mtInformation, [mbOk])
else
ToonMelding(Meldingen.Text, mtError, [mbOK]);
finally
lDataModuleTestExchange.Free;
end;
end;
end;
所以,不要使用TDataModuleTestExchange.**Create**(nil)
,使用以下代码即可:
unit dmTestExchange;
interface
uses
System.SysUtils, System.Classes,
Xml.XMLDoc, Xml.XMLIntf, Xml.XMLDOM,
TimeTellDM;
type
TDataModuleTestExchange = class(TTimeTellDataModule) // TDataModule descendant
private
public
function GetCalendarFolder(const AExchangeServerURL,AExchangeLoginName,AExchangePass: String): Boolean;
end;
没有编译错误,也没有运行时问题。为什么呢?
TButton(nil).Dragging
也是安全的 ;) - kobikTButton(nil).Dragging
是True
! - David Heffernan