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.

Closing application correctly

andreykrasnodar
Posts: 112
Joined: Wed Jul 01, 2020 10:22 am

Re: Closing application correctly

Post by andreykrasnodar »

Also there was problems with

Code: Select all

Form1.Hide
when I call it after

Code: Select all

Chromium1.CloseBrowser(true);
When I started to use

Code: Select all

Form1.Hide
1st, some problems disappear.
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Closing application correctly

Post by salvadordf »

Please, use the code I sent you. I tested it and it works correctly.

As I comented before, "Application.ProcessMessages" is not recomended.

In fact, you will find many web pages that suggest the same thing for other kind of Delphi components. Application.ProcessMessages can only be used if you're really sure it won't cause problems with other components and this is one of the cases where its use is discouraged.

Additionally, some VCL functions were not designed with Chromium in mind. Sometimes they recreate handles when you don't expect it and this can also cause problems.
andreykrasnodar
Posts: 112
Joined: Wed Jul 01, 2020 10:22 am

Re: Closing application correctly

Post by andreykrasnodar »

I have removed 2nd TChromium component and now program still not able to close. When I press X button, it hides main form and closes Chromium process, next I see
Access violation at address 006AEACA in module 'browser.exe'. Read of address 00000000.
OK
After pressing OK, program terminates. So everything is ok except this message.

Code: Select all

I removed this message making simple timer with code
procedure TForm1.Timer3Timer(Sender: TObject);
begin
  close;
end;
but... this it not a solution...
andreykrasnodar
Posts: 112
Joined: Wed Jul 01, 2020 10:22 am

Re: Closing application correctly

Post by andreykrasnodar »

Sub-process terminates correctly
Application hides main form
After hiding the form, application is in processes for about 12-13 seconds
After 13 seconds it shows error message with OK button
After pressing OK it terminates.
Student
Posts: 72
Joined: Tue Aug 07, 2018 9:20 am

Re: Closing application correctly

Post by Student »

Я сомневаюсь в правильности построения функций по работе с хромиумом, может поэтому и ошибки сыпит, что не может прочитать адрес несуществующего объекта. Ты писал ранее у тебя 1000 функций, вот убедись, что перед завершением работы хромиума эти функции не пытаются обращаться к хромиуму никоим образом, когда ты нажимаешь кнопку закрыть, все функции должны прервать свою работу, затем ты посылаешь сигнал завершения хромиума и потом закрывается программа.
Post Reply