1
0
mirror of https://github.com/salvadordf/CEF4Delphi.git synced 2025-11-23 21:34:53 +02:00

Partial fix for issue #291

- Create the CefApp handlers only when they are needed in SingleProcess mode.
- Added several "RemoveReferences" procedures to disable events when the application is shutting down in the CefApp handlers.
This commit is contained in:
Salvador Diaz Fau
2020-11-10 15:02:49 +01:00
parent 9ac740613c
commit e72db93dd2
9 changed files with 164 additions and 65 deletions

View File

@@ -58,6 +58,8 @@ type
function GetDataResource(resourceId: Integer; var data: Pointer; var dataSize: NativeUInt): Boolean; virtual; abstract;
function GetDataResourceForScale(resourceId: Integer; scaleFactor: TCefScaleFactor; var data: Pointer; var dataSize: NativeUInt): Boolean; virtual; abstract;
procedure RemoveReferences; virtual; abstract;
public
constructor Create; virtual;
end;
@@ -70,6 +72,8 @@ type
function GetDataResource(resourceId: Integer; var data: Pointer; var dataSize: NativeUInt): Boolean; override;
function GetDataResourceForScale(resourceId: Integer; scaleFactor: TCefScaleFactor; var data: Pointer; var dataSize: NativeUInt): Boolean; override;
procedure RemoveReferences; override;
public
constructor Create(const aCefApp : TCefApplicationCore); reintroduce;
destructor Destroy; override;
@@ -95,7 +99,8 @@ begin
Result := Ord(False);
TempObject := CefGetObject(self);
if (TempObject <> nil) and (TempObject is TCefResourceBundleHandlerOwn) then
if (TempObject <> nil) and
(TempObject is TCefResourceBundleHandlerOwn) then
begin
TempString := '';
Result := Ord(TCefResourceBundleHandlerOwn(TempObject).GetLocalizedString(string_id, TempString));
@@ -118,7 +123,8 @@ begin
Result := Ord(False);
TempObject := CefGetObject(self);
if (TempObject <> nil) and (TempObject is TCefResourceBundleHandlerOwn) then
if (TempObject <> nil) and
(TempObject is TCefResourceBundleHandlerOwn) then
Result := Ord(TCefResourceBundleHandlerOwn(TempObject).GetDataResource(resource_id, data, data_size));
end;
@@ -133,7 +139,8 @@ begin
Result := Ord(False);
TempObject := CefGetObject(self);
if (TempObject <> nil) and (TempObject is TCefResourceBundleHandlerOwn) then
if (TempObject <> nil) and
(TempObject is TCefResourceBundleHandlerOwn) then
Result := Ord(TCefResourceBundleHandlerOwn(TempObject).GetDataResourceForScale(resource_id, scale_factor, data, data_size));
end;
@@ -162,11 +169,16 @@ end;
destructor TCefCustomResourceBundleHandler.Destroy;
begin
FCefApp := nil;
RemoveReferences;
inherited Destroy;
end;
procedure TCefCustomResourceBundleHandler.RemoveReferences;
begin
FCefApp := nil;
end;
function TCefCustomResourceBundleHandler.GetLocalizedString( stringid : Integer;
var stringVal : ustring): Boolean;
begin