Components for Delphi and C++ Builder.

Go to Russian forum
Go to EhLib.com
It is currently 27 Apr 2024, 19:14

All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: 11 Dec 2023, 14:04 
Offline

Joined: 13 Jul 2019, 19:08
Posts: 91
This is a type of error that is difficult to make happen outside of my system.

There are two types of errors

one is "EInvalidOperation" which happens when I do a search on the GridEh and then press enter on the Grid to open another form

the other is "AccessViolation" which when pressing enter in the Grid will close the form and give an error


Attachments:
Grid Error Setfocus.7z [16.42 KiB]
Downloaded 820 times
Top
 Profile  
 
PostPosted: 14 Dec 2023, 00:14 
Offline

Joined: 08 May 2014, 18:06
Posts: 663
Hello Luciano

I think it is not correct to Destroy the Form in the OnClose event.
It is better to set the parameter Action := caFree;

Code:
Procedure TForm3.FormClose(Sender: TObject; Var Action: TCloseAction);
Begin
// Self.Free;
Action := caFree;
Form3 := Nil;
End;

_________________
Best regards
EhLib Support Team


Top
 Profile  
 
PostPosted: 14 Dec 2023, 13:37 
Offline

Joined: 13 Jul 2019, 19:08
Posts: 91
EhLibSupport wrote:
Hello Luciano

I think it is not correct to Destroy the Form in the OnClose event.
It is better to set the parameter Action := caFree;

Code:
Procedure TForm3.FormClose(Sender: TObject; Var Action: TCloseAction);
Begin
// Action := caFree;  // I can't use it that way

Self.Free;   // It needs to be this way
Form3 := Nil;
End;


I can't use it the way you mentioned
because my forms are destroyed by reference using a method

I created an example where clicking the button does not generate an error

and in fact there are two bugs in GridEh
one is Focus and the other accessViolation


Attachments:
ErroLog_Notelu.7z [988 Bytes]
Downloaded 762 times
Top
 Profile  
 
PostPosted: 29 Dec 2023, 12:41 
Offline

Joined: 08 May 2014, 18:06
Posts: 663
Hello

You cannot delete a Form inside the OnClose handler because After the OnClose event is executed,
the TCustomForm.Close method also accesses other properties of the Form.
And if the memory for the Form has already been freed, then the system accesses the properties of the non-existent object.

To avoid this, an Action parameter with a possible value of caFree was introduced in the OnClose event.

_________________
Best regards
EhLib Support Team


Top
 Profile  
 
PostPosted: 30 Dec 2023, 11:46 
Offline

Joined: 13 Jul 2019, 19:08
Posts: 91
As I already mentioned that I can't use Action because I destroy the form by reference

I have an existing method on all my forms that does several things.

Procedure TForm_ScanntechControl.FormClose(Sender: TObject; Var Action: TCloseAction);
Begin
Inherited;

P_SalvaCtrls(Self); // Within this method I do "Self.Free;"

End;

I see that there is a problem in the Grid because it only gives this type of error, other components have no problems
No contact on Setfocus error you didn't mention anything


Top
 Profile  
 
PostPosted: 09 Feb 2024, 10:39 
Offline

Joined: 13 Jul 2019, 19:08
Posts: 91
Hello, any position ?

This is a bug and it is difficult to resolve


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 60 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group