Answer the question
In order to leave comments, you need to log in
How to determine what is causing the exception?
Colleagues, good afternoon!
There was an unpleasant exception, there is no description and not a memory access error.
Just raise and that's it
The code is executed in the chronology in which I stated the essence of the question
MKNextPage is an event handler.
procedure TMainForm.MKNextPage(Sender: TObject; ACountPages,
ACurrentPage: Integer);
begin
success(Format('%d из %d', [ACurrentPage, ACountPages]));
end;
procedure TMainForm.success(msg: string);
var
js: string;
begin
try
CoInitialize(nil);
js := Format('this.success("%s")', [msg]);
MainForm.WbLog.EvaluateJavaScript(js);
finally
CoUninitialize;
end;
end;
procedure TDelegatedOleControl.CreateControl;
var
Stream: IStream;
CS: IOleClientSite;
X: Integer;
begin
FOleControl := nil;
if FOleControl = nil then
try
try // work around ATL bug
X := FOleObject.GetClientSite(CS);
except
X := -1;
end;
if (X <> 0) or (CS = nil) then
OleCheck(FOleObject.SetClientSite(Self));
if (FObjectData = 0) and Assigned(FPersistStream) then
OleCheck(FPersistStream.InitNew)
else
begin
OleCheck(CreateStreamOnHGlobal(FObjectData, False, Stream));
OleCheck(FPersistStream.Load(Stream));
DestroyStorage;
end;
OleCheck(FOleObject.QueryInterface(IOleControl, FOleControl));
FControlInfo.cb := SizeOf(FControlInfo);
FOleControl.GetControlInfo(FControlInfo);
OleCheck(FOleObject.QueryInterface(IDispatch, FControlDispatch));
InterfaceConnect(FOleObject, IPropertyNotifySink, Self, FPropConnection);
InterfaceConnect(FOleObject, FControlData^.EventIID, FEventDispatch, FEventsConnection);
{
if FControlData^.Flags then
OnChanged(DISPID_BACKCOLOR);
if FControlData^.Flags and cfEnabled <> 0 then
OnChanged(DISPID_ENABLED);
if FControlData^.Flags and cfFont <> 0 then
OnChanged(DISPID_FONT);
if FControlData^.Flags and cfForeColor <> 0 then
OnChanged(DISPID_FORECOLOR);
}
FOleControl.OnAmbientPropertyChange(DISPID_UNKNOWN);
RequestNewObjectLayout;
except
DestroyControl;
raise;
end;
end;
procedure TMKSearch.ASyncResult(const ASyncResult: IAsyncResult);
var
Ss: TStringStream;
begin
try
Ss := TStringStream.Create('', TEncoding.UTF8);
Ss.LoadFromStream(THTTPClient.EndAsyncHTTP(ASyncResult).ContentStream);
Ss.SaveToFile('debug.html');
FCount := GetCount(Ss.DataString);
if FCount < 0 then exit;
FCountPages := Math.Ceil( FCount / 25 );
if Assigned(FOnNextPage) then
FOnNextPage(Self, FCountPages, FCurrentPage);;
if FCurrentPage >= FCountPages then
begin
if Assigned(FOnSearchComplete) then
FOnSearchComplete(Self);
Exit;
end;
Parsing(Ss.DataString);
Inc(FCurrentPage);
Query(Fq, FCurrentPage);
finally
Ss.Free;
end;
end;
Answer the question
In order to leave comments, you need to log in
It will not work from a thread, in my case, the thread created THttpClient
That is, I could not synchronize.
Solution:
Used the TTHread class
and did the sync.
remove the try/except and find out which line the error is on
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question