Recent

Author Topic: Problem inheriting registration form  (Read 1539 times)

StraightFree

  • New Member
  • *
  • Posts: 38
Problem inheriting registration form
« on: March 12, 2020, 03:35:21 pm »

Hello people,

Once again I ask for your help in solving a problem.

I have a standard form, in it I define the standard size of my forms in addition to colors and other details.

From this form I inherit another form which is a standard formCadastroPadrao.
In this form, I have a TDataSource and I have two events associated with it onDataChange and onStateChange.

From this form I inherit all the registration forms from my system.

I also have a formPrincipal (which inherits from the Standard form), which is responsible for calling the registration forms.

And everything works perfectly.

I open the system, access the registration screens and everything works. The problem occurs when I close the application using formPrincipal. I do one:

Code: Pascal  [Select][+][-]
  1. Application.Terminate;

For some reason, which I have not yet identified, the onStateChange event of the formCadastroPadrao is executed once for each open registration form (if I open the formCadastroPessoa 10 times, the event will be executed 10 times).
Then, it ends up giving the following error:

Code: Pascal  [Select][+][-]
  1. Project Test raised exception class 'External: SIGSEGV'.

Am I doing something wrong when using inheritance?

Does anyone have any suggestions as to what may be causing the problem?

Any help is very welcome.

Thanks!

StraightFree

  • New Member
  • *
  • Posts: 38
Re: Problem inheriting registration form
« Reply #1 on: March 12, 2020, 04:37:32 pm »
cdesim,

Thank you for your reply.

And excuses by my poor english.

I call Application.Terminate, because in this point I close the application. But, I can change to self.close in the main form, have the same effect.

The registration form is a base form to inherit all forms that I use to register information about produtcs, people, for exemple.

In the form father I have a TDataSource and the visual components, like edits, labels, groupbox, buttons.

And, all child inherited this components.

The problem occur when I close the application not in the close forms of register.

The main form dont have any relation with register forms, but when I close this form the onStateChange of the father form.

Do you have any idea why its occur?

eljo

  • Sr. Member
  • ****
  • Posts: 468
Re: Problem inheriting registration form
« Reply #2 on: March 12, 2020, 04:47:10 pm »
for the exception I have no idea for the onstatechange it should be executed as many times as the state is changed on as many forms as you create.

Inheriting a form does not mean that a single parent form is created on the background and every other child form uses that created form as a template to initialize it self.

It means that the code and components of the parent form and their position at compile time are recreated precisly the same for all children forms the parent form at this point can stay uninitialized, never created and the children forms will work all the same.

As for the exception it looks to me like an index going out of bounds and trying to access an object or an array cell to far.

With out the code there is no way to know what is going on really.

StraightFree

  • New Member
  • *
  • Posts: 38
Re: Problem inheriting registration form
« Reply #3 on: March 12, 2020, 09:19:19 pm »
eljo,

Thank for your reply.

What you told me makes perfect sense, but in practice it is behaving differently.
I dont create parent form, only create a child form.

I believe it is exactly that, he is trying to access an object that no longer exists.

What I cannot understand is why this occurs when closing the mainPrincipal and not when closing the registration forms.

StraightFree

  • New Member
  • *
  • Posts: 38
Re: Problem inheriting registration form
« Reply #4 on: March 12, 2020, 09:23:27 pm »
cdesim,

Your suggestion stop de error.

But, it does not solve the main problem. It just stops the event from happening, as it is no longer associated with TDataSource.

I believe there is something left in the memory of the parent form and this is triggering the event by closing the main form.

For now your solution solves the problem, but I will continue studying the problem to see where this error occurs.

Thanks again!

 

TinyPortal © 2005-2018