Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.
Using DBGrid or DBNavigator in an App results in a crash (0xc0000005) when closing the app. Just placing one of these components on the main form leads to the error.
WIN 10 64 bit
CEF 90.6.7
Delphi 10.4.2
32-bit version of SimpleBrowser demo
further information:
Use of class constructor and FButtonsImageCollection used by tDBGrid/tDBNavigator triggers the problem. Using the following code in the demo the app crashes as well.
interface
uses ...,Vcl.ImageCollection;
type
TForm1 = class(TForm)
ChromiumWindow1: TChromiumWindow;
...
end;
tClassConstructorTest = class(TObject)
class var FButtonsImageCollection: TImageCollection;
class constructor Create;
class destructor Destroy;
end;
implementation
uses
uCEFApplication, vcl.DBCtrls;
{ tClassConstructorTest }
class constructor tClassConstructorTest.Create;
procedure InitButtonsImageCollection;
begin
FButtonsImageCollection := TImageCollection.Create(nil);
FButtonsImageCollection.Add('FIRST', HInstance, 'DBN_' + 'FIRST', ['', '_20X']); //this line triggers the problem
end;
begin
InitButtonsImageCollection;
end;
class destructor tClassConstructorTest.Destroy;
begin
FreeAndNil(FButtonsImageCollection);
end;
...
procedure TForm1.FormCreate(Sender: TObject);
var
IntCCT: tClassConstructorTest;
begin
FCanClose := False;
FClosing := False;
IntCCT := tClassConstructorTest.Create;
FreeAndNil(IntCCT);
// The browser will load the URL in AddressEdt initially.
end;
...
Check that your application follows the destruction steps described in the demo you used as a template for your app.
Class constructors and destructors are executed in the unit initialization and finalization. At first glance I don't see any problem with your code but you have to be careful because the unit initialization is executed before the CEF initialization and the unit finalization is executed after the CEF destruction.
the posted code is an addition to the SimpleBrowser-demo. Adding tClassConstructorTest to that demo and creating an instance in TForm1.FormCreate triggers the crash.
Same problem occurs if i place a DBGrid/DBNavigator component on the main form of that demo. No other changes in the code.
The class constructor is not the problem by itself. Using
I added a DBGrid and a DBNavigator component to the SimpleBrowser demo and I couldn't reproduce the crash.
CEF uses multiple processes and Delphi executes the initialization and finalization sections of all the units in the uses section in all of those processes. If the initialization or finalization sections are too complex or they require exclusive access to some files/devices/databases then anything can happen.
In these cases it's recommended using a different executable for the CEF subprocesses. See the SubProcess demo.
thanks for looking into this. A colleague advised me to be more precise. Crashing is one of the background processes. werfault.exe starts sends its data and an entry into windows event viewer (application) is generated. Then the demo closes. The demo itself shows no error message.