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

View File

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

View File

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

View File

@@ -6,12 +6,9 @@ unit uExternalPumpBrowser;
interface interface
uses uses
GlobalCefApplication,
uCEFLazarusCocoa, // required for Cocoa
Classes, SysUtils, Messages, Forms, Controls, Graphics, Classes, SysUtils, Messages, Forms, Controls, Graphics,
Dialogs, ExtCtrls, StdCtrls, LMessages, uCEFChromium, uCEFWindowParent, Dialogs, ExtCtrls, StdCtrls, LMessages, uCEFChromium,
uCEFConstants, uCEFTypes, uCEFInterfaces, uCEFChromiumEvents, uCEFTypes, uCEFInterfaces, uCEFLinkedWindowParent;
uCEFLinkedWindowParent, uCEFWorkScheduler;
type type
@@ -91,8 +88,6 @@ implementation
// 2. TChromium.OnClose sets aAction to cbaClose to destroy the browser, which triggers the TChromium.OnBeforeClose event. // 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. // 3. TChromium.OnBeforeClose sets FCanClose := True and sends CEF_BEFORECLOSE to close the form.
uses
uCEFApplication;
{ TForm1 } { TForm1 }
@@ -233,23 +228,5 @@ begin
Chromium1.NotifyMoveOrResizeStarted; Chromium1.NotifyMoveOrResizeStarted;
end; 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. end.

View File

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

View File

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