Jump to content
Sign in to follow this  
field

TW3HttpRequest.Destroy + TW3Storage.LoadFile/LoadXML causes exception

Recommended Posts

Hi,

 

SMS 2.2.2.4543:

 

using TW3Storage.LoadFile / LoadXML can cause an exception in TW3HttpRequest.Destroy, because 

 

TW3Storage.LoadFile&LoadXML set up event handlers both for TW3HttpRequest.OnDataReady and TW3HttpRequest.OnError, and both include a call to TW3HttpRequest.free.

Therefore it can happen (at least in the browsers I tested with), that both OnDataReady AND OnError get called, which both call TW3HttpRequest.Free!

 

My solution to it was fixing TW3HttpRequest.Destroy by adding a check if FReqObj is still assigned (see below), but basically fixing TW3Storage.LoadFile and TW3Storage.LoadXML (by clearing mLoader) should be the better approach!

 

destructor TW3HttpRequest.Destroy;

begin
  // detach handler so no more events wikl be received during destruction
 
  if Assigned(FReqObj) then //FLD
    FReqObj.OnReadyStateChange := NIL;
 
  FReqObj := NIL;
  inherited;
end;
 

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×