1
0
mirror of https://github.com/salvadordf/CEF4Delphi.git synced 2025-08-04 21:32:54 +02:00

Possible fix for issue #538

This commit is contained in:
Salvador Díaz Fau
2024-12-04 16:10:43 +01:00
parent 6badc8f3bd
commit a87256405a
6 changed files with 33 additions and 41 deletions

View File

@@ -21,18 +21,31 @@ uses
{$ENDIF}{$ENDIF}
Interfaces,
Forms,
uExternalPumpBrowser, GlobalCefApplication
uExternalPumpBrowser, GlobalCefApplication, uCEFApplication, uCEFWorkScheduler
{ you can add units after this }
;
{$R *.res}
begin
RequireDerivedFormResource:=True;
Application.Title:='External Pump Browser';
Application.Scaled:=True;
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
CreateGlobalCEFApp;
if GlobalCEFApp.StartMainProcess then
begin
RequireDerivedFormResource := True;
Application.Title := 'External Pump Browser';
Application.Scaled := True;
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
// The form needs to be destroyed *BEFORE* stopping the scheduler.
Form1.Free;
GlobalCEFWorkScheduler.StopScheduler;
end;
DestroyGlobalCEFApp;
DestroyGlobalCEFWorkScheduler;
end.

View File

@@ -6,7 +6,7 @@ unit GlobalCefApplication;
interface
uses
uCEFApplication, uCEFWorkScheduler, uCEFConstants;
uCEFLazarusCocoa, uCEFApplication, uCEFWorkScheduler, uCEFConstants;
procedure CreateGlobalCEFApp;
@@ -19,8 +19,7 @@ end;
procedure CreateGlobalCEFApp;
begin
if GlobalCEFApp <> nil then
exit;
AddCrDelegate;
// TCEFWorkScheduler will call cef_do_message_loop_work when
// it's told in the GlobalCEFApp.OnScheduleMessagePumpWork event.

View File

@@ -10,7 +10,6 @@ object Form1: TForm1
OnCloseQuery = FormCloseQuery
OnCreate = FormCreate
Position = poScreenCenter
LCLVersion = '2.2.6.0'
object AddressPnl: TPanel
Left = 0
Height = 23
@@ -29,16 +28,16 @@ object Form1: TForm1
Width = 35
Align = alRight
Caption = 'Go'
OnClick = GoBtnClick
TabOrder = 0
OnClick = GoBtnClick
end
object AddressEdt: TComboBox
Left = 0
Height = 24
Height = 20
Top = 0
Width = 932
Align = alClient
ItemHeight = 16
ItemHeight = 19
ItemIndex = 0
Items.Strings = (
'https://www.google.com'

View File

@@ -6,12 +6,9 @@ unit uExternalPumpBrowser;
interface
uses
GlobalCefApplication,
uCEFLazarusCocoa, // required for Cocoa
Classes, SysUtils, Messages, Forms, Controls, Graphics,
Dialogs, ExtCtrls, StdCtrls, LMessages, uCEFChromium, uCEFWindowParent,
uCEFConstants, uCEFTypes, uCEFInterfaces, uCEFChromiumEvents,
uCEFLinkedWindowParent, uCEFWorkScheduler;
Dialogs, ExtCtrls, StdCtrls, LMessages, uCEFChromium,
uCEFTypes, uCEFInterfaces, uCEFLinkedWindowParent;
type
@@ -91,8 +88,6 @@ implementation
// 2. TChromium.OnClose sets aAction to cbaClose to destroy the browser, which triggers the TChromium.OnBeforeClose event.
// 3. TChromium.OnBeforeClose sets FCanClose := True and sends CEF_BEFORECLOSE to close the form.
uses
uCEFApplication;
{ TForm1 }
@@ -233,23 +228,5 @@ begin
Chromium1.NotifyMoveOrResizeStarted;
end;
initialization
AddCrDelegate;
if GlobalCEFApp = nil then begin
CreateGlobalCEFApp;
if not GlobalCEFApp.StartMainProcess then begin
DestroyGlobalCEFApp;
DestroyGlobalCEFWorkScheduler;
halt(0); // exit the subprocess
end;
end;
finalization
(* Destroy from this unit, which is used after "Interfaces". So this happens before the Application object is destroyed *)
if GlobalCEFWorkScheduler <> nil then
GlobalCEFWorkScheduler.StopScheduler;
DestroyGlobalCEFApp;
DestroyGlobalCEFWorkScheduler;
end.

View File

@@ -157,7 +157,8 @@ end;
procedure TCEFLinkedWinControlBase.UpdateSize;
{$IFDEF MACOSX}{$IFDEF FPC}
var
TempSize: NSSize;
TempSize : NSSize;
TempPoint : NSPoint;
{$ENDIF}{$ENDIF}
begin
{$IFDEF MSWINDOWS}
@@ -177,6 +178,9 @@ begin
(Chromium <> nil) and
Chromium.Initialized then
begin
TempPoint.x:= 0;
TempPoint.y:= 0;
NSView(Chromium.WindowHandle).setFrameOrigin(TempPoint);
TempSize.width:= Width;
TempSize.height:= Height;
NSView(Chromium.WindowHandle).setFrameSize(TempSize);

View File

@@ -2,7 +2,7 @@
"UpdateLazPackages" : [
{
"ForceNotify" : true,
"InternalVersion" : 680,
"InternalVersion" : 681,
"Name" : "cef4delphi_lazarus.lpk",
"Version" : "131.2.7"
}