mirror of
https://github.com/salvadordf/CEF4Delphi.git
synced 2025-04-17 06:57:13 +02:00
Fixed an access violation in TChromium.ShowDevTools with some Delphi versions
This commit is contained in:
parent
a32686c7ef
commit
1624d8712d
@ -615,12 +615,12 @@ end;
|
||||
|
||||
function TCefBrowserHostRef.IsMouseCursorChangeDisabled: Boolean;
|
||||
begin
|
||||
Result := PCefBrowserHost(FData)^.is_mouse_cursor_change_disabled(FData) <> 0
|
||||
Result := PCefBrowserHost(FData)^.is_mouse_cursor_change_disabled(FData) <> 0;
|
||||
end;
|
||||
|
||||
function TCefBrowserHostRef.IsWindowRenderingDisabled: Boolean;
|
||||
begin
|
||||
Result := PCefBrowserHost(FData)^.is_window_rendering_disabled(FData) <> 0
|
||||
Result := PCefBrowserHost(FData)^.is_window_rendering_disabled(FData) <> 0;
|
||||
end;
|
||||
|
||||
procedure TCefBrowserHostRef.NotifyMoveOrResizeStarted;
|
||||
|
@ -2971,28 +2971,42 @@ end;
|
||||
|
||||
procedure TChromium.ShowDevTools(inspectElementAt: TPoint; const aDevTools : TWinControl);
|
||||
var
|
||||
TempPoint : TCefPoint;
|
||||
TempPoint : TCefPoint;
|
||||
TempClient : ICefClient;
|
||||
TempPPoint : PCefPoint;
|
||||
begin
|
||||
if not(Initialized) or HasDevTools then Exit;
|
||||
try
|
||||
try
|
||||
if Initialized then
|
||||
begin
|
||||
InitializeSettings(FDevBrowserSettings);
|
||||
|
||||
InitializeSettings(FDevBrowserSettings);
|
||||
if (aDevTools <> nil) then
|
||||
WindowInfoAsChild(FDevWindowInfo, aDevTools.Handle, aDevTools.ClientRect, aDevTools.Name)
|
||||
else
|
||||
WindowInfoAsPopUp(FDevWindowInfo, WindowHandle, DEVTOOLS_WINDOWNAME);
|
||||
|
||||
if (aDevTools <> nil) then
|
||||
WindowInfoAsChild(FDevWindowInfo, aDevTools.Handle, aDevTools.ClientRect, aDevTools.Name)
|
||||
else
|
||||
WindowInfoAsPopUp(FDevWindowInfo, WindowHandle, DEVTOOLS_WINDOWNAME);
|
||||
TempClient := TCefClientOwn.Create;
|
||||
|
||||
if (inspectElementAt.x <> low(integer)) and
|
||||
(inspectElementAt.y <> low(integer)) then
|
||||
begin
|
||||
TempPoint.x := inspectElementAt.x;
|
||||
TempPoint.y := inspectElementAt.y;
|
||||
TempPPoint := @TempPoint;
|
||||
end
|
||||
else
|
||||
TempPPoint := nil;
|
||||
|
||||
if (inspectElementAt.x <> low(integer)) and
|
||||
(inspectElementAt.y <> low(integer)) then
|
||||
begin
|
||||
TempPoint.x := inspectElementAt.x;
|
||||
TempPoint.y := inspectElementAt.y;
|
||||
|
||||
FBrowser.Host.ShowDevTools(@FDevWindowInfo, TCefClientOwn.Create as ICefClient, @FDevBrowserSettings, @TempPoint);
|
||||
end
|
||||
else
|
||||
FBrowser.Host.ShowDevTools(@FDevWindowInfo, TCefClientOwn.Create as ICefClient, @FDevBrowserSettings, nil);
|
||||
FBrowser.Host.ShowDevTools(@FDevWindowInfo, TempClient, @FDevBrowserSettings, TempPPoint);
|
||||
end;
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TChromium.ShowDevTools', e) then raise;
|
||||
end;
|
||||
finally
|
||||
TempClient := nil;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TChromium.CloseDevTools(const aDevTools : TWinControl);
|
||||
|
@ -98,6 +98,11 @@ type
|
||||
implementation
|
||||
|
||||
uses
|
||||
{$IFDEF DELPHI16_UP}
|
||||
System.Math,
|
||||
{$ELSE}
|
||||
Math,
|
||||
{$ENDIF}
|
||||
uCEFMiscFunctions, uCEFLibFunctions;
|
||||
|
||||
|
||||
@ -246,18 +251,21 @@ end;
|
||||
function TCefBytesWriteHandler.Write(const ptr: Pointer; size, n: NativeUInt): NativeUInt;
|
||||
var
|
||||
TempPointer : pointer;
|
||||
TempSize : int64;
|
||||
begin
|
||||
EnterCriticalSection(FCriticalSection);
|
||||
|
||||
if ((FOffset + (size * n)) >= FBufferSize) and (Grow(size * n) = 0) then
|
||||
TempSize := size * n;
|
||||
|
||||
if ((FOffset + TempSize) >= FBufferSize) and (Grow(TempSize) = 0) then
|
||||
Result := 0
|
||||
else
|
||||
begin
|
||||
TempPointer := Pointer(cardinal(FBuffer) + FOffset);
|
||||
|
||||
CopyMemory(TempPointer, ptr, size * n);
|
||||
CopyMemory(TempPointer, ptr, TempSize);
|
||||
|
||||
FOffset := FOffset + (size * n);
|
||||
FOffset := FOffset + TempSize;
|
||||
Result := n;
|
||||
end;
|
||||
|
||||
@ -337,21 +345,21 @@ end;
|
||||
|
||||
function TCefBytesWriteHandler.Grow(size : NativeUInt) : NativeUInt;
|
||||
var
|
||||
s : NativeUInt;
|
||||
TempTotal : int64;
|
||||
begin
|
||||
EnterCriticalSection(FCriticalSection);
|
||||
try
|
||||
EnterCriticalSection(FCriticalSection);
|
||||
|
||||
if (size > FGrow) then
|
||||
s := size
|
||||
else
|
||||
s := FGrow;
|
||||
TempTotal := max(size, FGrow);
|
||||
inc(TempTotal, FBufferSize);
|
||||
|
||||
ReallocMem(FBuffer, FBufferSize + s);
|
||||
ReallocMem(FBuffer, TempTotal);
|
||||
|
||||
FBufferSize := FBufferSize + s;
|
||||
Result := FBufferSize;
|
||||
|
||||
LeaveCriticalSection(FCriticalSection);
|
||||
FBufferSize := TempTotal;
|
||||
Result := FBufferSize;
|
||||
finally
|
||||
LeaveCriticalSection(FCriticalSection);
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
Loading…
x
Reference in New Issue
Block a user