[Lazarus] Remove unmatched vars in published

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

[Lazarus] Remove unmatched vars in published

Free Pascal - Lazarus mailing list
Hi all!

Lazarus has some feature, to remove all unmatched variable names (on published of class, specially on TForm class and it's descendants) that don't have a control or component with the same name?

I'm working with big forms (process screens) and my coworkers are deleting some controls, but sometimes, Lazarus don't remove the variable. This behavior leads to some errors, like access violation, due access to a nil variable that still is referenced in code, but that is not created by the LFM reader (because it doesn't exist). If the variable is removed at the moment that the control is being deleted (or before save form) this erros will be filtered at compile time.



--
The best regards,

Fabio Luis Girardi
PascalSCADA Project
http://sourceforge.net/projects/pascalscada
http://www.pascalscada.com

--
_______________________________________________
Lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Remove unmatched vars in published

vojtech.cihak

Hi,

 

do you mean that you add control on the form (let's say Button1), then you remove it (in designer) and line "Button1: TButton;" remains in source editor?

 

V.

______________________________________________________________
> Od: "Fabio Luis Girardi via Lazarus" <[hidden email]>
> Komu: "Lazarus mailing list" <[hidden email]>
> Datum: 25.10.2018 15:09
> Předmět: [Lazarus] Remove unmatched vars in published
>

Hi all!
Lazarus has some feature, to remove all unmatched variable names (on published of class, specially on TForm class and it's descendants) that don't have a control or component with the same name?
I'm working with big forms (process screens) and my coworkers are deleting some controls, but sometimes, Lazarus don't remove the variable. This behavior leads to some errors, like access violation, due access to a nil variable that still is referenced in code, but that is not created by the LFM reader (because it doesn't exist). If the variable is removed at the moment that the control is being deleted (or before save form) this erros will be filtered at compile time.
--
The best regards,

Fabio Luis Girardi
PascalSCADA Project
http://sourceforge.net/projects/pascalscada
http://www.pascalscada.com


----------

--
_______________________________________________
Lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus

--
_______________________________________________
Lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Remove unmatched vars in published

Free Pascal - Lazarus mailing list
Yes, that's right. 

My coworkers reported that the same occurs when renaming controls/components. It's renamed at LFM file, but not in PAS file. No reported exception when deleting/renaming.


Em qui, 25 de out de 2018 às 11:07, Vojtěch Čihák <[hidden email]> escreveu:

Hi,

 

do you mean that you add control on the form (let's say Button1), then you remove it (in designer) and line "Button1: TButton;" remains in source editor?

 

V.

______________________________________________________________
> Od: "Fabio Luis Girardi via Lazarus" <[hidden email]>
> Komu: "Lazarus mailing list" <[hidden email]>
> Datum: 25.10.2018 15:09
> Předmět: [Lazarus] Remove unmatched vars in published
>

Hi all!
Lazarus has some feature, to remove all unmatched variable names (on published of class, specially on TForm class and it's descendants) that don't have a control or component with the same name?
I'm working with big forms (process screens) and my coworkers are deleting some controls, but sometimes, Lazarus don't remove the variable. This behavior leads to some errors, like access violation, due access to a nil variable that still is referenced in code, but that is not created by the LFM reader (because it doesn't exist). If the variable is removed at the moment that the control is being deleted (or before save form) this erros will be filtered at compile time.
--
The best regards,

Fabio Luis Girardi
PascalSCADA Project
http://sourceforge.net/projects/pascalscada
http://www.pascalscada.com


----------

--
_______________________________________________
Lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus


--
The best regards,

Fabio Luis Girardi
PascalSCADA Project
http://sourceforge.net/projects/pascalscada
http://www.pascalscada.com

--
_______________________________________________
Lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Remove unmatched vars in published

Free Pascal - Lazarus mailing list
Fabio Luis Girardi, if there is a systematic way to reproduce the
error using the latest Lazarus (trunk or 2.0RC1) then please report in
bug tracker.

Juha
--
_______________________________________________
Lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Remove unmatched vars in published

Free Pascal - Lazarus mailing list
Hi Juha!

I haven't a way to reproduce this, yet. Because of this I asked if Lazarus has way to remove unmatched instance class fields when saving the form/datamodule or that can be triggered manually.

When I found a way to reproduce this and if this is related with Lazarus, I'll fill a bug report.

Em Qui, 25 de out de 2018 11:59, Juha Manninen <[hidden email]> escreveu:
Fabio Luis Girardi, if there is a systematic way to reproduce the
error using the latest Lazarus (trunk or 2.0RC1) then please report in
bug tracker.

Juha

--
_______________________________________________
Lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Remove unmatched vars in published

Free Pascal - Lazarus mailing list
On 25/10/2018 19:09, Fabio Luis Girardi via Lazarus wrote:
> Hi Juha!
>
> I haven't a way to reproduce this, yet. Because of this I asked if
> Lazarus has way to remove unmatched instance class fields when saving
> the form/datamodule or that can be triggered manually.
>
> When I found a way to reproduce this and if this is related with
> Lazarus, I'll fill a bug report.
>
Afaik this can happen, if you have errors in the source code. Usually
the error has to be in front of the form declaration. So Codetools can
not parse the source to that point, and then the source can not be
updated. I am not sure, if that can happen if the error is in a used
unit. Again it would have to prevent codetools from parsing the unit
with the form declaration.

The problem with removing it later, is that the IDE can not know, if you
added any fields yourself.
--
_______________________________________________
Lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Remove unmatched vars in published

Free Pascal - Lazarus mailing list
Hi Martin!

Em qui, 25 de out de 2018 às 14:14, Martin Frb via Lazarus <[hidden email]> escreveu:
 

The problem with removing it later, is that the IDE can not know, if you
added any fields yourself.

When I add some field in a published section of a class, I avoid use the space where the IDE declares the form components/controls. I declare a new published section, something like this:

TForm1 = class(TForm)
  Button1:TButton;
  Button2:TButton; 
  Button3:TButton;
  Button4:TButton;
  //I dont declare published fields here.
private / protected / public
  ... some private / protected / public fields ...
published
  MyField:SomeType;
end;

But this is a question related with how each one handles their codes, which is not the point here.

What's I'm suggesting is, a feature, like "Source -> Refactoring -> Empty methods..." but with a option (Source editor options) to enable/disable the published cleanup when saving the form.




 

--
_______________________________________________
Lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus


--
The best regards,

Fabio Luis Girardi
PascalSCADA Project
http://sourceforge.net/projects/pascalscada
http://www.pascalscada.com

--
_______________________________________________
Lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus