Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2018-10

Remove unmatched vars in published

7 messages · 4 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Fabio Luis Girardi

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 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20181025/37e26e60/attachment.html>

Reply by email

Vojtěch Čihák

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.

Reply by email

Fabio Luis Girardi
to Vojtěch Čihák

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.

Vojtěch Čihák wrote 46 lines
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" > Komu: "Lazarus mailing list" > 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 https://lists.lazarus-ide.org/listinfo/lazarus
The best regards, Fabio Luis Girardi PascalSCADA Project http://sourceforge.net/projects/pascalscada http://www.pascalscada.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20181025/550a46d7/attachment.html>

Reply by email

Fabio Luis Girardi
to Juha Manninen

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.

Juha Manninen wrote 6 lines
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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20181025/14de2bb0/attachment.html>

Reply by email

Martin Frb
to Fabio Luis Girardi
Fabio Luis Girardi wrote 9 lines
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.

Reply by email

Fabio Luis Girardi
to Martin Frb

Hi Martin!

Em qui, 25 de out de 2018 às 14:14, Martin Frb via Lazarus <

Show quoted text 8 lines
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 > > https://lists.lazarus-ide.org/listinfo/lazarus > -- The best regards, Fabio Luis Girardi PascalSCADA Project http://sourceforge.net/projects/pascalscada http://www.pascalscada.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20181025/b960695b/attachment.html>

Reply by email