Discussion:
[Lazarus] Remove unmatched vars in published
Fabio Luis Girardi via Lazarus
2018-10-25 13:08:39 UTC
Permalink
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
Vojtěch Čihák via Lazarus
2018-10-25 14:07:40 UTC
Permalink
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" <***@lists.lazarus-ide.org>
> Komu: "Lazarus mailing list" <***@lists.lazarus-ide.org>
> 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://sourceforge.net/projects/pascalscada>
http://www.pascalscada.com <http://www.pascalscada.com>

----------

--
_______________________________________________
Lazarus mailing list
***@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus <https://lists.lazarus-ide.org/listinfo/lazarus>
Fabio Luis Girardi via Lazarus
2018-10-25 14:16:50 UTC
Permalink
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 <***@atlas.cz>
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" <***@lists.lazarus-ide.org>
> > Komu: "Lazarus mailing list" <***@lists.lazarus-ide.org>
> > 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
> ***@lists.lazarus-ide.org
> https://lists.lazarus-ide.org/listinfo/lazarus
>


--
The best regards,

Fabio Luis Girardi
PascalSCADA Project
http://sourceforge.net/projects/pascalscada
http://www.pascalscada.com
Juha Manninen via Lazarus
2018-10-25 14:59:09 UTC
Permalink
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
--
Fabio Luis Girardi via Lazarus
2018-10-25 17:09:52 UTC
Permalink
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 <***@gmail.com>
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
>
Martin Frb via Lazarus
2018-10-25 17:14:12 UTC
Permalink
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.
--
Fabio Luis Girardi via Lazarus
2018-10-25 17:42:32 UTC
Permalink
Hi Martin!

Em qui, 25 de out de 2018 às 14:14, Martin Frb via Lazarus <
***@lists.lazarus-ide.org> 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
> ***@lists.lazarus-ide.org
> https://lists.lazarus-ide.org/listinfo/lazarus
>


--
The best regards,

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