Atozed Forums

Full Version: IWCallBackFunc Bug IW 15.1.4
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
IW is trying to clear an uncreated object, Add Lines commented below //OPH20190826 Prevent Bug


unit IWCallBackFunc;
//OPH20190826 Prevent Bug

interface

...

implementation

...

procedure TIWCallBacks.Invoke(ACallbackRec: TIWCallbackRec);
var
  LResult: string;
  LHandled: Boolean;
  LForm: TIWForm;
  LSession: TIWApplicationAccess;
begin
  LSession := TIWApplicationAccess(FSession);
  if not Assigned(LSession) or not Assigned(LSession.ActiveForm) then begin
    Exit;
  end;

  LForm := TIWForm(LSession.ActiveForm);
  try
    //Pass a copy of all Request params to the Callback.
    if not Assigned(FEventParams) then begin
      FEventParams := TIWStringList.Create;
    end;
    FEventParams.AddStrings(LForm.Params, False);
    if Assigned(ACallbackRec.Method) then begin
      ACallbackRec.Method(FEventParams);
    end else if Assigned(ACallbackRec.Proc) then begin
      LResult := '';
      LHandled := False;
      ACallbackRec.Proc(FEventParams, LResult, LHandled);
      if LHandled then begin    // user code handles the response
        LSession.CallBackResponse.SendResponse := False;
        Exit;
      end;
      if LResult <> '' then begin
        // Write result to response as is
        LSession.CallBackResponse.AddRawText(LResult);
      end;
    end;
    if LForm.SendAJAXNotification then begin
      LSession.CallBackResponse.AddJavaScriptToExecute(LForm.GetIWAJAXNotificationJSCode);
    end;
  finally
    if Assigned(FEventParams) then //OPH20190826 Prevent Bug
      FEventParams.Clear;
  end;
end;

...
First, thanks for your report but, next time, publish only the part of the code that's related to the problem.
IntraWeb code is copyrighted and can't be published.

Having said that:

I don't think there is a bug there. As you can see, FEventParams object is created if it doesn't exist, in the second line after the try:

try
//Pass a copy of all Request params to the Callback.
if not Assigned(FEventParams) then begin
FEventParams := TIWStringList.Create;
end;

When it gets to the finally block, FEventParams must be assigned. There is no other option.

I'm curious to know why you are thinking that this is the culprit of some weird AV you might have been facing...