Problem occured due to violation of module finalization order

Обсуждение возникших проблем, предложений и ошибок ODAC компонентов
Закрыто
seregaaltmer
Сообщения: 8
Зарегистрирован: Ср 05 мар 2014 13:54

Problem occured due to violation of module finalization order

Сообщение seregaaltmer » Пт 18 апр 2014 13:34

I'm sorry, my english is not very good.
I changed ODAC 6.25 to 8.6 and faced a problem. In 8.6 TDBMonitor implemented as a singletone. Moreover, it creates and destroys in a different places. This causes an access violation.

Код: Выделить всё

unit DBMonitorClient;
//...
initialization
//nothing here
finalization
  DBMonitor.Free;
If I use Halt procedure to terminate my application, at first DBMonitor.Free is executed. Then app goes through the components, and Destroys them. TOraSQLMonitor.Destroy ocuurs. It trying to call TDBMonitor.Finish, wich is already .Freed.

What's the reason to create and destroy TBDMonitor in a different places? Can you do something with this?

Alexp
Devart Team
Сообщения: 349
Зарегистрирован: Пн 27 дек 2010 10:34

Re: Problem occured due to violation of module finalization order

Сообщение Alexp » Вт 22 апр 2014 10:48

Hello,

We cannot reproduce the problem. When explicitly calling Halt, the Finish method is first called, and then - the Finalization section. Please try to reproduce the problem on the latest ODAC version 9.2.7.

seregaaltmer
Сообщения: 8
Зарегистрирован: Ср 05 мар 2014 13:54

Re: Problem occured due to violation of module finalization order

Сообщение seregaaltmer » Ср 23 апр 2014 10:48

Hello again. I have sent you a simple example, where problem occurs.
Вложения
DBMonCrashes.zip
(1.3 КБ) 273 скачивания

Alexp
Devart Team
Сообщения: 349
Зарегистрирован: Пн 27 дек 2010 10:34

Re: Problem occured due to violation of module finalization order

Сообщение Alexp » Ср 23 апр 2014 14:32

This problem is due to the fact that you have added the SQLMonitor component onto the form and deleted its declaration from the class. If you delete the component from the form, your sample will work correctly.

seregaaltmer
Сообщения: 8
Зарегистрирован: Ср 05 мар 2014 13:54

Re: Problem occured due to violation of module finalization order

Сообщение seregaaltmer » Пт 25 апр 2014 07:36

If you delete the component from the form, your sample will work correctly.
But how can I use DBMonitor in case I delete it? Most of it's methods are class functions or procedures, but they want DBMonitor inside of itself!

seregaaltmer
Сообщения: 8
Зарегистрирован: Ср 05 мар 2014 13:54

Re: Problem occured due to violation of module finalization order

Сообщение seregaaltmer » Пт 25 апр 2014 07:41

...or you mean, it will be better to create mon in runtime?

seregaaltmer
Сообщения: 8
Зарегистрирован: Ср 05 мар 2014 13:54

Re: Problem occured due to violation of module finalization order

Сообщение seregaaltmer » Пт 25 апр 2014 10:34

...the problem is due to DBMonitor was freed when DBMonitor module finalized, but TCustomDASQLMonitor, wich contains link to it, know nothing about it! Don't you thik it is not right?

Alexp
Devart Team
Сообщения: 349
Зарегистрирован: Пн 27 дек 2010 10:34

Re: Problem occured due to violation of module finalization order

Сообщение Alexp » Пн 28 апр 2014 09:08

When you place a component onto the form, it is placed to the published section of the form class:

Код: Выделить всё

  TForm3 = class(TForm)
    ...
    OraSQLMonitor1: TOraSQLMonitor;
    ...
    procedure FormCreate(Sender: TObject);
  private
    FMon: TOraSQLMonitor;
    ...
  end;
You have deleted OraSQLMonitor1: TOraSQLMonitor from the class declaration in your project. For correct functioning of your code, you should either remove the component from the form
(for work with the monitor, it is enough to add the OraSQLMonitor module to the uses section), or return the OraSQLMonitor1 declaration to the class.

seregaaltmer
Сообщения: 8
Зарегистрирован: Ср 05 мар 2014 13:54

Re: Problem occured due to violation of module finalization order

Сообщение seregaaltmer » Пн 28 апр 2014 13:29

Well, I returned DBMon declaration to the class, but it still doesn't work correctly.

Код: Выделить всё

type
  TForm3 = class(TForm)
    orsqlmntr1: TOraSQLMonitor;
    procedure FormCreate(Sender: TObject);
Вложения
DBMonCrashes2.zip
(1.33 КБ) 246 скачиваний

Alexp
Devart Team
Сообщения: 349
Зарегистрирован: Пн 27 дек 2010 10:34

Re: Problem occured due to violation of module finalization order

Сообщение Alexp » Пт 23 май 2014 12:45

Form and component classes declared in the form declaration section are registered automatically on form loading. Therefore you don't need to register this class again.

Закрыто