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;
|
function TCefBrowserHostRef.IsMouseCursorChangeDisabled: Boolean;
|
||||||
begin
|
begin
|
||||||
Result := PCefBrowserHost(FData)^.is_mouse_cursor_change_disabled(FData) <> 0
|
Result := PCefBrowserHost(FData)^.is_mouse_cursor_change_disabled(FData) <> 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCefBrowserHostRef.IsWindowRenderingDisabled: Boolean;
|
function TCefBrowserHostRef.IsWindowRenderingDisabled: Boolean;
|
||||||
begin
|
begin
|
||||||
Result := PCefBrowserHost(FData)^.is_window_rendering_disabled(FData) <> 0
|
Result := PCefBrowserHost(FData)^.is_window_rendering_disabled(FData) <> 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCefBrowserHostRef.NotifyMoveOrResizeStarted;
|
procedure TCefBrowserHostRef.NotifyMoveOrResizeStarted;
|
||||||
|
@ -2972,9 +2972,13 @@ end;
|
|||||||
procedure TChromium.ShowDevTools(inspectElementAt: TPoint; const aDevTools : TWinControl);
|
procedure TChromium.ShowDevTools(inspectElementAt: TPoint; const aDevTools : TWinControl);
|
||||||
var
|
var
|
||||||
TempPoint : TCefPoint;
|
TempPoint : TCefPoint;
|
||||||
|
TempClient : ICefClient;
|
||||||
|
TempPPoint : PCefPoint;
|
||||||
|
begin
|
||||||
|
try
|
||||||
|
try
|
||||||
|
if Initialized then
|
||||||
begin
|
begin
|
||||||
if not(Initialized) or HasDevTools then Exit;
|
|
||||||
|
|
||||||
InitializeSettings(FDevBrowserSettings);
|
InitializeSettings(FDevBrowserSettings);
|
||||||
|
|
||||||
if (aDevTools <> nil) then
|
if (aDevTools <> nil) then
|
||||||
@ -2982,17 +2986,27 @@ begin
|
|||||||
else
|
else
|
||||||
WindowInfoAsPopUp(FDevWindowInfo, WindowHandle, DEVTOOLS_WINDOWNAME);
|
WindowInfoAsPopUp(FDevWindowInfo, WindowHandle, DEVTOOLS_WINDOWNAME);
|
||||||
|
|
||||||
|
TempClient := TCefClientOwn.Create;
|
||||||
|
|
||||||
if (inspectElementAt.x <> low(integer)) and
|
if (inspectElementAt.x <> low(integer)) and
|
||||||
(inspectElementAt.y <> low(integer)) then
|
(inspectElementAt.y <> low(integer)) then
|
||||||
begin
|
begin
|
||||||
TempPoint.x := inspectElementAt.x;
|
TempPoint.x := inspectElementAt.x;
|
||||||
TempPoint.y := inspectElementAt.y;
|
TempPoint.y := inspectElementAt.y;
|
||||||
|
TempPPoint := @TempPoint;
|
||||||
FBrowser.Host.ShowDevTools(@FDevWindowInfo, TCefClientOwn.Create as ICefClient, @FDevBrowserSettings, @TempPoint);
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
FBrowser.Host.ShowDevTools(@FDevWindowInfo, TCefClientOwn.Create as ICefClient, @FDevBrowserSettings, nil);
|
TempPPoint := 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;
|
end;
|
||||||
|
|
||||||
procedure TChromium.CloseDevTools(const aDevTools : TWinControl);
|
procedure TChromium.CloseDevTools(const aDevTools : TWinControl);
|
||||||
|
@ -98,6 +98,11 @@ type
|
|||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
|
{$IFDEF DELPHI16_UP}
|
||||||
|
System.Math,
|
||||||
|
{$ELSE}
|
||||||
|
Math,
|
||||||
|
{$ENDIF}
|
||||||
uCEFMiscFunctions, uCEFLibFunctions;
|
uCEFMiscFunctions, uCEFLibFunctions;
|
||||||
|
|
||||||
|
|
||||||
@ -246,18 +251,21 @@ end;
|
|||||||
function TCefBytesWriteHandler.Write(const ptr: Pointer; size, n: NativeUInt): NativeUInt;
|
function TCefBytesWriteHandler.Write(const ptr: Pointer; size, n: NativeUInt): NativeUInt;
|
||||||
var
|
var
|
||||||
TempPointer : pointer;
|
TempPointer : pointer;
|
||||||
|
TempSize : int64;
|
||||||
begin
|
begin
|
||||||
EnterCriticalSection(FCriticalSection);
|
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
|
Result := 0
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
TempPointer := Pointer(cardinal(FBuffer) + FOffset);
|
TempPointer := Pointer(cardinal(FBuffer) + FOffset);
|
||||||
|
|
||||||
CopyMemory(TempPointer, ptr, size * n);
|
CopyMemory(TempPointer, ptr, TempSize);
|
||||||
|
|
||||||
FOffset := FOffset + (size * n);
|
FOffset := FOffset + TempSize;
|
||||||
Result := n;
|
Result := n;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -337,21 +345,21 @@ end;
|
|||||||
|
|
||||||
function TCefBytesWriteHandler.Grow(size : NativeUInt) : NativeUInt;
|
function TCefBytesWriteHandler.Grow(size : NativeUInt) : NativeUInt;
|
||||||
var
|
var
|
||||||
s : NativeUInt;
|
TempTotal : int64;
|
||||||
begin
|
begin
|
||||||
|
try
|
||||||
EnterCriticalSection(FCriticalSection);
|
EnterCriticalSection(FCriticalSection);
|
||||||
|
|
||||||
if (size > FGrow) then
|
TempTotal := max(size, FGrow);
|
||||||
s := size
|
inc(TempTotal, FBufferSize);
|
||||||
else
|
|
||||||
s := FGrow;
|
|
||||||
|
|
||||||
ReallocMem(FBuffer, FBufferSize + s);
|
ReallocMem(FBuffer, TempTotal);
|
||||||
|
|
||||||
FBufferSize := FBufferSize + s;
|
FBufferSize := TempTotal;
|
||||||
Result := FBufferSize;
|
Result := FBufferSize;
|
||||||
|
finally
|
||||||
LeaveCriticalSection(FCriticalSection);
|
LeaveCriticalSection(FCriticalSection);
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user