Jump to content


Photo

TW3HttpRequest.Destroy + TW3Storage.LoadFile/LoadXML causes exception


  • Please log in to reply
No replies to this topic

#1 field

field
  • Members
  • 10 posts

Posted 02 January 2017 - 03:58 PM

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;
 

 






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users