Lazarus

Programming => General => Topic started by: pixelink on April 28, 2019, 02:11:15 am

Title: Why Does LAZ Keep Adding Blank Procedures??
Post by: pixelink on April 28, 2019, 02:11:15 am
How come every time I go into the event panel of a control and click the "..." button or double-click on a control, LAZ keeps adding blank procedures that I already have and are assigned to an object... its VERY FRUSTRATING

It Adds all this in just one event change.

Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormClose(Sender: TObject; var CloseAction: TCloseAction);
  2. begin
  3.  
  4. end;
  5.  
  6. procedure TForm1.FormCreate(Sender: TObject);
  7. begin
  8.  
  9. end;
  10.  
  11. procedure TForm1.MyCanvasMouseDown(Sender: TObject; Button: TMouseButton;
  12.   Shift: TShiftState; X, Y: Integer);
  13. begin
  14.  
  15. end;
  16.  
  17. procedure TForm1.MyCanvasMouseMove(Sender: TObject; Shift: TShiftState; X,
  18.   Y: Integer);
  19. begin
  20.  
  21. end;
  22.  
  23. procedure TForm1.MyCanvasMouseUp(Sender: TObject; Button: TMouseButton;
  24.   Shift: TShiftState; X, Y: Integer);
  25. begin
  26.  
  27. end;
  28.  
  29. procedure TForm1.MyCanvasPaint(Sender: TObject);
  30. begin
  31.  
  32. end;
  33.  
  34. procedure TForm1.Timer1Timer(Sender: TObject);
  35. begin
  36.  
  37. end;
  38.  
Title: Re: Why Does LAZ Keep Adding Blank Procedures??
Post by: pixelink on April 28, 2019, 02:24:43 am
Also, this seems to happen more if I try to change an event, but there are errors in my code.

Title: Re: Why Does LAZ Keep Adding Blank Procedures??
Post by: jamie on April 28, 2019, 03:03:51 am
that is how the object inspector works.

 You want an event you can do that and it will generate a blank method for you to start putting your code in.

 or you can do the drop down and select a compliant event that already exist and have it call that one instead.

 if you are assigning these events at runtime laz does not know that. Normally you assign non-published events
at runtime.

 Also, if you double click on the control it will create a new method of the OnClick.

 This is how things work, how else have you been doing it?

Title: Re: Why Does LAZ Keep Adding Blank Procedures??
Post by: pixelink on April 28, 2019, 03:09:13 am
You didn't read my post. Seems a lot of people don't.
As per stated above...

LAZ keeps adding blank procedures that I already have and are assigned to an object


Its's creating a 2nd set on top of the ones I already have.
This is NOT proper IDE behavior.
Title: Re: Why Does LAZ Keep Adding Blank Procedures??
Post by: lucamar on April 28, 2019, 03:09:46 am
Also, this seems to happen more if I try to change an event, but there are errors in my code.

Yes, in that case the code tools (or whatever is addding the event) gets a little lost while looking for the proper place to add the method implementation. Which is quite logical: It's difficult to follow the code if there are errors in it (lack or surplus of an end is the most common cause).


As for this:
LAZ keeps adding blank procedures that I already have and are assigned to an object

Its's creating a 2nd set on top of the ones I already have.

I have seen that behaviour one time and the reason was the same: I had deleted an end; by mistake, tried to add a new event and Lazarus (oh, so servicialy!) started adding all the methods that had become hidden by that mistake. Check your code for things like that.

If that's not the reason and you have all the event handlers correctly connected to their controls then you've discovered a bug ... which only afffects you?
Title: Re: Why Does LAZ Keep Adding Blank Procedures??
Post by: pixelink on April 28, 2019, 03:14:23 am
Also, this seems to happen more if I try to change an event, but there are errors in my code.

Yes, in that case the code tools (or whatever is adding the event) gets a little lost while looking for the proper place to add the method implementation. Which is quite logical: It's difficult to follow the code if there are errors in it (lack or surplus of an end is the most common cause).

Yeah, so why don't the developers code in that if there is an error....  do NOT add in blank procedures.
This is a feature flaw in the IDE... it needs to be re-thought through instead of me having to go through all my code and delete blank procedures making sure my already existing code is still in tack.

Title: Re: Why Does LAZ Keep Adding Blank Procedures??
Post by: jamie on April 28, 2019, 03:23:28 am
Just go into your configuration and have the IDE delete all blank events and don't work about it.

TOOLS:OPTIONS:EDITOR:Code Completion :remove empty methods

something like that.
Title: Re: Why Does LAZ Keep Adding Blank Procedures??
Post by: pixelink on April 28, 2019, 03:44:58 am
Just go into your configuration and have the IDE delete all blank events and don't work about it.

TOOLS:OPTIONS:EDITOR:Code Completion :remove empty methods

something like that.

Alright, found it.
Good tip... hope it helps.

But still, that is a quick-fix solution for something that should not be happening at all.
It needs to be re-thought through.
Never, experienced this with .NET
The debugging is not linked to working with controls at design time.

Debugging should only take place when, well, you want to run and debug.
That's my 2 cents for what its worth, nothing of course  :o
Title: Re: Why Does LAZ Keep Adding Blank Procedures??
Post by: lucamar on April 28, 2019, 04:15:38 am
Yes, in that case the code tools (or whatever is adding the event) gets a little lost while looking for the proper place to add the method implementation. Which is quite logical: It's difficult to follow the code if there are errors in it (lack or surplus of an end is the most common cause).
Yeah, so why don't the developers code in that if there is an error....  do NOT add in blank procedures.

Because, depending on the error, their code don't see it as an "error". When it does it ususally stops and shouts some to error. When it adds the code is because it has found what apparently is the good place ... even if to you it isn't.
Title: Re: Why Does LAZ Keep Adding Blank Procedures??
Post by: pixelink on May 01, 2019, 11:23:09 am
Yesterday, I tried to add an event, got error, adding 20 or so blank procedures. And by the way... enabling "remove Blank Procedures" in the option settings does not work for me.  Then it broke most of my event connections to my objects. I had to go back an re=connect about 15 controls to the procedures in the object inspector.

Ridiculous!!!
 :o
Title: Re: Why Does LAZ Keep Adding Blank Procedures??
Post by: JanRoza on May 01, 2019, 12:48:11 pm
Why is it you are the only one complaining about this, could it be others don't have these errors and empty procedures?
It's so easy to blame it all on the developers but maybe it's the way you use Lazarus.
I work with Lazarus for years now on a more or less daily basis and never experienced all the errors and shortcomings you are mentioning.
There must be a reason for that or is that a too simple view? No offence intended.
Title: Re: Why Does LAZ Keep Adding Blank Procedures??
Post by: pixelink on May 01, 2019, 01:20:20 pm
Why is it you are the only one complaining about this, could it be others don't have these errors and empty procedures?
It's so easy to blame it all on the developers but maybe it's the way you use Lazarus.
I work with Lazarus for years now on a more or less daily basis and never experienced all the errors and shortcomings you are mentioning.
There must be a reason for that or is that a too simple view? No offence intended.

Are you real...

Because I am trying to figue out why

C'mon man.
 ::)
Title: Re: Why Does LAZ Keep Adding Blank Procedures??
Post by: josh on May 01, 2019, 02:02:29 pm
Hi

I too get this on one of my projects, which also happens to be the one of the larger projects 10's of thousands of lines of code.

It is odd, in that if I open the project in Laz 1.3 with FPC 2.7.1 the behaviour does not happen.

This project has a lot of $IFDEF statemens; to cover various build mode for 32/64 bit Win, OSX etc as well as additional application features. It has approximately 14 Build Modes as standard.

I personaly think it has to do with this, as some of the build modes could actually create in itself a Blank Procedure Code Block ie simplified below.

Code: Pascal  [Select][+][-]
  1. Procedure form. SomeFunc:
  2. Begin
  3.   {$Ifdef darwin}
  4.     {$ifdef cpu32}
  5.     {$else}
  6.      .. some code for 64 bit darwin
  7.     {$endIf}
  8.   {$elsef}
  9.   ...... Some code for windows
  10.   {$endif}
  11. End;

I spent over a week examine the code, and everything has it correct begin end; as indicated in the ide with the vertical lines showing the begin end matches, i even went to each begin so as to highlght it to make sure its corresponding end was also hilighted.

If you have procedure blocks where no code is in; then I found added some code that does nothing, will help in reducing it.
When it first started, everytime I created a new event, it would create nearly 30 empty events that were in various parts of the main project file; so took ages to remove them, now it just creates one empty one; and ironically it is placed immediately before the actually code???

At the moment I use the old lazarus version for this project, and when I added any changes etc,, I will then open and compile in new Lazarus for FPC 3.2/3.0.4 .

Also doing a Tools Scan Source did help a few times.

I had created a post about this a while ago, but cannot find it now.

Title: Re: Why Does LAZ Keep Adding Blank Procedures??
Post by: lucamar on May 01, 2019, 10:18:07 pm
I tried (yesterday) for a little (couple hours) using drag&drop instead of copy/paste in a medium sized (around 1500 loc/unit, 20 units) and couldn't reproduce what you both are seeing.

Granted, it's a short test and had to leave it because productivity decreased savagely: it's not my natural way of working and  I kept dropping code all over the place except where it should go ;)

In short: No idea what's happening to you. Sorry.
Title: Re: Why Does LAZ Keep Adding Blank Procedures??
Post by: pixelink on May 02, 2019, 11:29:31 pm
UPDATE ON MY ISSUE

These are the steps I am doing that generates this IDE issue.

1) I go to Object Inspector for the object I want to add an event
2) I click the "..." button
3) If my code has error, it is doing all this....
   a) removes procedures
   b) disconnects all the events from some of my objects (both regular objects, but noticeably with menus and popup menus
      controls/procedures)

Today it was ALL of my menus and Popup menus that got disconnected.

I wish I could say I am doing something wrong, but if i am, can someone look at my steps to create an event and tell me what is wrong. I am doing what the IDE wants me to do to create an event.

Now, I guess what I have to do, is ..
1) Make sure I have no errors before trying to add an event
2) Make a backup copy before trying to create an event.

And NOTE: this only happens when there are errors in my code.

It may not be happening to some of you, but is happening to me.

And it is frustrating!
Title: Re: Why Does LAZ Keep Adding Blank Procedures??
Post by: wp on May 03, 2019, 01:01:05 am
Cannot reproduce with your steps (although I have seen this behavior some time ago). Please give EXACT steps including what you type, what you click, which exact errors etc. Also: which version, which OS, which bitness?
Title: Re: Why Does LAZ Keep Adding Blank Procedures??
Post by: pixelink on May 03, 2019, 02:29:56 am
As I stated earlier....

STEPS that produces error.

1) I go to Object Inspector for the object I want to add an event
2) I click the "..." button (I have typed nothing at this point) <-- ERROR Happens Here -->
3) ONLY if my code has errors, it does the following thingss....
   a) removes procedures
   b) disconnects all the events from some of my objects (both regular objects, but noticeably with menus and popup menus
      controls/procedures).

That's it.

I have LAZ 2.0 on Windows 7 64x
Title: Re: Why Does LAZ Keep Adding Blank Procedures??
Post by: pixelink on May 03, 2019, 02:34:19 am
Cannot reproduce with your steps (although I have seen this behavior some time ago). Please give EXACT steps including what you type, what you click, which exact errors etc. Also: which version, which OS, which bitness?

When I say errors, usually if I have a character in the wrong place or forget to have ";" in the right place.
The error message only says, go back an fix errors. And of course I may get the usual, "expected ;, else found"
Title: Re: Why Does LAZ Keep Adding Blank Procedures??
Post by: VTwin on May 03, 2019, 03:09:59 am
As I stated earlier....

STEPS that produces error.

1) I go to Object Inspector for the object I want to add an event
2) I click the "..." button (I have typed nothing at this point) <-- ERROR Happens Here -->
3) ONLY if my code has errors, it does the following thingss....
   a) removes procedures
   b) disconnects all the events from some of my objects (both regular objects, but noticeably with menus and popup menus
      controls/procedures).

That's it.

I have LAZ 2.0 on Windows 7 64x

In step 2 you say "I have typed nothing at this point", but in step 3 you say "if my code has errors". I do not follow how, if you have not typed anything, you have errors.

I have never encountered this behavior. Can you post a simple project that exhibits it?

EDIT: In retrospect I may have, but I am careful to compile to find errors before adding events. In any case, folks here are interested in isolating the problem you describe, but need a simple example.

Title: Re: Why Does LAZ Keep Adding Blank Procedures??
Post by: pixelink on May 03, 2019, 04:05:20 am
As I stated earlier....

STEPS that produces error.

1) I go to Object Inspector for the object I want to add an event
2) I click the "..." button (I have typed nothing at this point) <-- ERROR Happens Here -->
3) ONLY if my code has errors, it does the following thingss....
   a) removes procedures
   b) disconnects all the events from some of my objects (both regular objects, but noticeably with menus and popup menus
      controls/procedures).

That's it.

I have LAZ 2.0 on Windows 7 64x

In step 2 you say "I have typed nothing at this point", but in step 3 you say "if my code has errors". I do not follow how, if you have not typed anything, you have errors.

I have never encountered this behavior. Can you post a simple project that exhibits it?

EDIT: In retrospect I may have, but I am careful to compile to find errors before adding events. In any case, folks here are interested in isolating the problem you describe, but need a simple example.

What I mean by that is the code was already there, even if it is wrong, then I go to add an event.

Typing the code doesn't actually DIRECTLY make the error. It causes the error INDIRECTLY... because the IDE checks for errors when you create an event. So, its the IDE that is causing the proble. Even though I need to check for errors before I add an event now.

The typed text was already going to be an error, If I tried to run the app. That was my initial point. Debugging should ONLY happen when I actually try to run the app, not when i am making design time adjustments to the GUI or adding events.

.NET never did this when i used it.
If my code was wrong in .net, adding a private/public sub/function was never checked for errors at that point.
That was left to the debugger when I tested the app.

Never seen or heard an IDE do this.
Title: Re: Why Does LAZ Keep Adding Blank Procedures??
Post by: pixelink on May 03, 2019, 04:18:08 am

I have never encountered this behavior. Can you post a simple project that exhibits it?

EDIT: In retrospect I may have, but I am careful to compile to find errors before adding events. In any case, folks here are interested in isolating the problem you describe, but need a simple example.

There is no code to provide this all happens from the IDE, it is something that happens when you click the "..." button
and you have code errors, and the code errors can be anything, misplaced character, missing begin-end... etc etc.

Again... even though there are code errors (simple character misplacement), it isn't the code that is wiping out my procedures, it is the object inspector that creates Events (procedures) when you either double-click a control or click the "..." button.
Title: Re: Why Does LAZ Keep Adding Blank Procedures??
Post by: pixelink on May 03, 2019, 04:23:03 am
Just so everyone is clear... this is the screen and button I am talking about.
The Major break happens when I click the "..." button (red square) on screenshot below.
Title: Re: Why Does LAZ Keep Adding Blank Procedures??
Post by: Handoko on May 03, 2019, 05:00:38 am
I cannot reproduce the issue, tested on Lazarus 2.0.2 on Ubuntu Mate.

Maybe you can try different versions of Lazarus, it could be a bug in the version you're using.
Title: Re: Why Does LAZ Keep Adding Blank Procedures??
Post by: wp on May 03, 2019, 10:36:16 am
Cannot reproduce with your steps (although I have seen this behavior some time ago). Please give EXACT steps including what you type, what you click, which exact errors etc. Also: which version, which OS, which bitness?

When I say errors, usually if I have a character in the wrong place or forget to have ";" in the right place.
The error message only says, go back an fix errors. And of course I may get the usual, "expected ;, else found"
Still not clear what you are doing EXACTLY.

I am doing this
Title: Re: Why Does LAZ Keep Adding Blank Procedures??
Post by: pixelink on May 03, 2019, 02:15:49 pm
Cannot reproduce with your steps (although I have seen this behavior some time ago). Please give EXACT steps including what you type, what you click, which exact errors etc. Also: which version, which OS, which bitness?

When I say errors, usually if I have a character in the wrong place or forget to have ";" in the right place.
The error message only says, go back an fix errors. And of course I may get the usual, "expected ;, else found"
Still not clear what you are doing EXACTLY.

I am doing this
  • Open Laz 2.0/32bit on Win 10/64 bit
  • Save new project
  • Add a button and OnClick handler, "ShowMessage('Test')"
  • Save again, then compile and run.
  • Add another button
  • Go to the source editor and insert a '{' before the final end (the one followed by a period). This makes the source invalid.
  • Make sure that the second button is selected and click on the '...' of its OnClick event.
  • The IDE reports something like this: "Cannot create new method. Please fix the error shown in the message window which is normally below the source editor." No empty procedure is added, the OnClick event of the first button is still attached to the button. This is normal behavior.
  • I repeat the same with Laz 2.02/64 bit (I don't have Laz 2.0.0/64 bit), same observation.

You are replicating what happens to me. Don't know why you don't get the errors, but I do.
It's a mystery for sure  :)
Title: Re: Why Does LAZ Keep Adding Blank Procedures??
Post by: pixelink on May 03, 2019, 02:18:57 pm
I cannot reproduce the issue, tested on Lazarus 2.0.2 on Ubuntu Mate.

Maybe you can try different versions of Lazarus, it could be a bug in the version you're using.

Well, now come to think of it... this NEVER happened to me in LAZ 1.8.

But, i don't want to go back a version.

Is there any newer version yet?
And even if there was, who is to say that this won't happen in another version higher.
Especially if the upgrade came from 2.0 source code.
Title: Re: Why Does LAZ Keep Adding Blank Procedures??
Post by: lucamar on May 03, 2019, 02:42:17 pm
I managed to reproduce it ... I think.

In the source, go to any event handler and add an extra end a couple lines or so before the normal end. That leaves some code dangling out there without procedure header or begin or anything else but the end. Then go to the object inspector and try to add another event. This is the result (in this case I added an end just before the OnActivate := Nil;)
Code: Pascal  [Select][+][-]
  1. procedure TMainForm.FormActivate(Sender: TObject);
  2. { Acts only once, on start-up}
  3. begin
  4.   FInitRect := BoundsRect;//TRect.Create(Left, Top, Width, Height);
  5.   //AdjustWindow;
  6.   if FileList.Count > 0 then begin
  7.     AdjustScroll; {@add 20190503}
  8.     if FileList.Count = 1 then
  9.       btPlay.Click;{@add 20190430 - start playing if just one file}
  10.   end;
  11.   end; {<<<<< Extra end added here}
  12.  
  13. procedure TMainForm.FormDropFiles(Sender: TObject;
  14.   const FileNames: array of String);
  15. begin
  16.  
  17. end;
  18.  
  19. procedure TMainForm.FormCloseQuery(Sender: TObject; var CanClose: boolean);
  20. begin
  21.  
  22. end;
  23.  
  24. procedure TMainForm.ListShowHint(Sender: TObject; HintInfo: PHintInfo);
  25. begin
  26.  
  27. end;
  28.  
  29. procedure TMainForm.ListDblClick(Sender: TObject);
  30. begin
  31.  
  32. end;
  33.  
  34. procedure TMainForm.ListKeyDown(Sender: TObject; var Key: Word;
  35.   Shift: TShiftState);
  36. begin
  37.  
  38. end;
  39.  
  40. procedure TMainForm.btPlayClick(Sender: TObject);
  41. begin
  42.  
  43. end;
  44.  
  45. procedure TMainForm.btNextClick(Sender: TObject);
  46. begin
  47.  
  48. end;
  49.  
  50. procedure TMainForm.btPrevClick(Sender: TObject);
  51. begin
  52.  
  53. end;
  54.  
  55. procedure TMainForm.btStopClick(Sender: TObject);
  56. begin
  57.  
  58. end;
  59.  
  60. procedure TMainForm.btQuitClick(Sender: TObject);
  61. begin
  62.  
  63. end;
  64.  
  65. procedure TMainForm.btAdjustClick(Sender: TObject);
  66. begin
  67.  
  68. end;
  69.  
  70. procedure TMainForm.acFileBeforeExec(Sender: TObject);
  71. begin
  72.  
  73. end;
  74.  
  75. procedure TMainForm.acFileOpenAccept(Sender: TObject);
  76. begin
  77.  
  78. end;
  79.  
  80. procedure TMainForm.acFileSaveExecute(Sender: TObject);
  81. begin
  82.  
  83. end;
  84.  
  85. procedure TMainForm.ProcessTerminate(Sender: TObject);
  86. begin
  87.  
  88. end;
  89.  
  90. procedure TMainForm.FileListClick(Sender: TObject);
  91. begin
  92.  
  93. end;
  94.  
  95.   OnActivate := Nil;
  96. end;

Those empty methods are all the methods declared after the one which has the error, and they are repeated. The old methods, with the imolemented code, etc. are still there, after the erroneous extra lines.

Note also that the IDE gives you an error but, nevertheless, inserts all those empty methods.

So ... problem reproduced - mission: accomplished! :)

ETA: Forgot to add -
If you try this at home remember to backup the project you'lll be playing with before starting to play!!!
Title: Re: Why Does LAZ Keep Adding Blank Procedures??
Post by: pixelink on May 03, 2019, 04:29:29 pm
@LUCAMAR

Well, that is good news... I know I am not crazy. Getting older with a foggy brain (from stroke)... OH YEAH, that's me.

I agree with taking the precautions you stated.

I now have to do this all the time.

1) Every major part I add to my app (setting window, db, buttons, whatever) ... I make a backup immediately.
2) Now, I run/debug my code before adding another event/procedure to anything.
3) Now, if I get that error because i forgot to make sure code is all good.
I just don't save the project so I don't have to clean it up afterwards.

This saves the frustration of going back an trying to clean up, but I create more work for myself in the long run.

Onward We go!!!!!
Title: Re: Why Does LAZ Keep Adding Blank Procedures??
Post by: lucamar on May 03, 2019, 04:43:50 pm
Do note that there is a "File->Revert" item in the main menu, so if you save the unit you're working on before adding new events you could in theory go back to the saved version as soon as you become aware of problems.

Just remember to push Ctrl+S in the editor before passing to the object inspector and you're all set. :)
Title: Re: Why Does LAZ Keep Adding Blank Procedures??
Post by: pixelink on May 03, 2019, 04:52:02 pm
Do note that there is a "File->Revert" item in the main menu, so if you save the unit you're working on before adding new events you could in theory go back to the saved version as soon as you become aware of problems.

Just remember to push Ctrl+S in the editor before passing to the object inspector and you're all set. :)

Good to know. Thanks
Title: Re: Why Does LAZ Keep Adding Blank Procedures??
Post by: wp on May 03, 2019, 05:35:25 pm
I could not reproduce lucamar's steps at first, but while playing I came to this project which reproduces the issue to some degree:
Title: Re: Why Does LAZ Keep Adding Blank Procedures??
Post by: ASerge on May 03, 2019, 06:27:14 pm
I could not reproduce lucamar's steps at first, but while playing I came to this project which reproduces the issue to some degree:
...So, maybe this is not exactly your observation; but IIRC there are options somewhere which inhibit having text after the final "end.".[/li][/list]
Or even easier:
1. Create a new project (application)
2. Create a new event handler. For example OnCreate. Write any code (Exit, for example).
3. Write 'end.' above the event handler.
4. Create another event handler. For example OnShow. A new empty handler for OnCreate will also be added.
In my opinion, this is normal. Because the text after 'end.' ignored, but the class interface specifies the OnCreate handler, so it is created.
Title: Re: Why Does LAZ Keep Adding Blank Procedures??
Post by: lucamar on May 03, 2019, 07:43:37 pm
I could not reproduce lucamar's steps at first, but while playing I came to this project which reproduces the issue to some degree: [...snip...]

Easy, in your on project add this:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. begin
  3.   ShowMessage('Test');
  4.   if Button1.Tag = 0 then begin
  5.     Button1.Tag := 1;
  6.   end;
  7.   {end; // Uncomment and double click on Button2 }
  8.   Button1.Caption := Button1.Name + ' - Tagged: '+IntToStr(Button1.Tag);
  9. end;

As it says, uncomment, double click or whatever to create a new event handler and watch the fire catch :D

Yeah, I know, stupid code; just to make the point. The thing is that it's relatively easy to do something similar: say while refactoring some long or nested ifs or moving code from one place to another, you can inadvertently leave a dangling "end" somewhere. Or some similar thing.

To make it more "funny", it doesn't happen always. If you "repare" and try to repeat the trick, the IDE catchs you and chides you with that "resolve the problem you created!" message. :)
Title: Re: Why Does LAZ Keep Adding Blank Procedures??
Post by: wp on May 03, 2019, 08:09:06 pm
No, it does not add empty methods for me.
Title: Re: Why Does LAZ Keep Adding Blank Procedures??
Post by: lucamar on May 03, 2019, 11:09:45 pm
No, it does not add empty methods for me.

Yeah, neither does always for me. A heisenbug?
Title: Re: Why Does LAZ Keep Adding Blank Procedures??
Post by: JuhaManninen on May 04, 2019, 09:09:29 am
Yeah, neither does always for me. A heisenbug?
Here also I get a valid error message: "Unable to create new method. ..."
Nothing was added.
If you find a way to systematically reproduce this "heisenbug" then please report.
Title: Re: Why Does LAZ Keep Adding Blank Procedures??
Post by: gsa on May 04, 2019, 10:23:17 am
The following steps allways reproduce that strange behavior on my systems (Lazarus fixes 2_0, Windows 10 + openSUSE Leap 15):

- create a new Appliction
- create an OnCreate event handler by clicking the ... button
- move the cursor to the line before the fresh created procedure
- press enter four times
- move the cursor up four lines
- type "end."
- move the cursor to the line above that "end."
- press enter two times
- move the curso up two lines
- create an OnActivate event handler by clicking the ... button

After that you have duplicate empty procedures.
Title: Re: Why Does LAZ Keep Adding Blank Procedures??
Post by: wp on May 04, 2019, 11:52:25 am
So this is again the "end." trick, i.e. the final "end." is placed above existing code which is already referred to in the interface; since the implementation of these routines is no longer found the IDE adds dummy procedures. The behavior is kind of logical, but the situation would be clearer if there were an option to turn it off. Or maybe there is one? I scanned the options in "Tools" > "Options" > "CodeTools" and did not find anything related (but this does not mean anything...).
Title: Re: Why Does LAZ Keep Adding Blank Procedures??
Post by: JuhaManninen on May 04, 2019, 01:14:27 pm
As wp wrote.
Pascal source ends with "end." Anything that follows is ignored by the compiler. The IDE behaves as expected.
Title: Re: Why Does LAZ Keep Adding Blank Procedures??
Post by: jamie on May 04, 2019, 03:22:38 pm
I have to say that I do have a project that I converted over from an OLD D1 target that does duplicate empty methods
when ever using the OI to generate a new method unrelated to the one that gets duplicated.

 So each time I would go and compile after the fact I would get a duplicated error.

 I used the feature of the IDE to remove empty methods to solve that issue..

 Its a rather large cluttered project, something I found on the internet involving PostScript file rendering and has the
original code in sub folders..

 I would be happy to zip the complete project up if any one would like to play with it.

 P.S.
  Its not completed btw, there were some items I didn't finish but workable for a test.
Title: Re: Why Does LAZ Keep Adding Blank Procedures??
Post by: pixelink on August 18, 2019, 06:46:06 pm
Has this bug been fixed yet?

I had an IDE error, not my error or fault

It added all these blank procedures. Even duplicating ones I already have.

Code: Pascal  [Select][+][-]
  1. procedure TForm1.mnuDesignClick(Sender: TObject);
  2. begin
  3.  
  4. end;
  5.  
  6. procedure TForm1.mnuExportImgClick(Sender: TObject);
  7. begin
  8.  
  9. end;
  10.  
  11. procedure TForm1.mnuHelpPgClick(Sender: TObject);
  12. begin
  13.  
  14. end;
  15.  
  16. procedure TForm1.mnuHomeClick(Sender: TObject);
  17. begin
  18.  
  19. end;  
  20.  
  21. procedure TForm1.PinkShirtDblClick(Sender: TObject);
  22. begin
  23.  
  24. end;
  25.  
  26. procedure TForm1.PlainDblClick(Sender: TObject);
  27. begin
  28.  
  29. end;
  30.  
  31. procedure TForm1.opt1Change(Sender: TObject);
  32. begin
  33.  
  34. end;
  35.  
  36. procedure TForm1.opt2Change(Sender: TObject);
  37. begin
  38.  
  39. end;
  40.  
  41. procedure TForm1.opt3Change(Sender: TObject);
  42. begin
  43.  
  44. end;
  45.  
  46. procedure TForm1.opt4Change(Sender: TObject);
  47. begin
  48.  
  49. end;
  50.  
  51. procedure TForm1.opt5Change(Sender: TObject);
  52. begin
  53.  
  54. end;
  55.  
  56. procedure TForm1.LightToneDblClick(Sender: TObject);
  57. begin
  58.  
  59. end;
  60.  
  61. procedure TForm1.MidToneDblClick(Sender: TObject);
  62. begin
  63.  
  64. end;
  65.  
  66. procedure TForm1.DarkToneDblClick(Sender: TObject);
  67. begin
  68.  
  69. end;
  70.  
  71. procedure TForm1.Panel16Click(Sender: TObject);
  72. begin
  73.  
  74. end;
  75.  
  76. procedure TForm1.PurpleLipstickDblClick(Sender: TObject);
  77. begin
  78.  
  79. end;
  80.  
  81. procedure TForm1.RedLipstickDblClick(Sender: TObject);
  82. begin
  83.  
  84. end;
  85.  
  86.  
  87. procedure TForm1.WhiteShirtDblClick(Sender: TObject);
  88. begin
  89.  
  90. end;
  91.  
  92. procedure TForm1.WhiteToneDblClick(Sender: TObject);
  93. begin
  94.  
  95. end;
  96.  
  97. procedure TForm1.BlueBlouseDblClick(Sender: TObject);
  98. begin
  99.  
  100. end;
  101.  
  102. procedure TForm1.BlueShirtDblClick(Sender: TObject);
  103. begin
  104.  
  105. end;
  106.  
  107. procedure TForm1.btnDesignClick(Sender: TObject);
  108. begin
  109.  
  110. end;
  111.  
  112. procedure TForm1.btnDesignExportClick(Sender: TObject);
  113. begin
  114.  
  115. end;
  116.  
  117. procedure TForm1.btnExportClick(Sender: TObject);
  118. begin
  119.  
  120. end;
  121.  
  122. procedure TForm1.btnHelpClick(Sender: TObject);
  123. begin
  124.  
  125. end;
  126.  
  127. procedure TForm1.btnHomeClick(Sender: TObject);
  128. begin
  129.  
  130. end;  
  131.  
  132. procedure TForm1.Button10Click(Sender: TObject);
  133. begin
  134.  
  135. end;
  136.  
  137. procedure TForm1.Button11Click(Sender: TObject);
  138. begin
  139.  
  140. end;
  141.  
  142. procedure TForm1.Button12Click(Sender: TObject);
  143. begin
  144.  
  145. end;
  146.  
  147. procedure TForm1.Button13Click(Sender: TObject);
  148. begin
  149.  
  150. end;
  151.  
  152. procedure TForm1.Button14Click(Sender: TObject);
  153. begin
  154.  
  155. end;
  156.  
  157. procedure TForm1.Button15Click(Sender: TObject);
  158. begin
  159.  
  160. end;
  161.  
  162.  
  163. procedure TForm1.Button16Click(Sender: TObject);
  164. begin
  165.  
  166. end;
  167.  
  168. procedure TForm1.Button17Click(Sender: TObject);
  169. begin
  170.  
  171. end;
  172.  
  173. procedure TForm1.Button18Click(Sender: TObject);
  174. begin
  175.  
  176. end;
  177.  
  178. procedure TForm1.Button19Click(Sender: TObject);
  179. begin
  180.  
  181. end;
  182.  
  183. procedure TForm1.Button1Click(Sender: TObject);
  184. begin
  185.  
  186. end;
  187.  
  188. procedure TForm1.Button20Click(Sender: TObject);
  189. begin
  190.  
  191. end;
  192.  
  193. procedure TForm1.Button21Click(Sender: TObject);
  194. begin
  195.  
  196. end;
  197.  
  198. procedure TForm1.Button22Click(Sender: TObject);
  199. begin
  200.  
  201. end;
  202.  
  203. procedure TForm1.Button23Click(Sender: TObject);
  204. begin
  205.  
  206. end;
  207.  
  208. procedure TForm1.Button24Click(Sender: TObject);
  209. begin
  210.  
  211. end;
  212.  
  213. procedure TForm1.Button25Click(Sender: TObject);
  214. begin
  215.  
  216. end;
  217.  
  218. procedure TForm1.Button26Click(Sender: TObject);
  219. begin
  220.  
  221. end;
  222.  
  223. procedure TForm1.Button2Click(Sender: TObject);
  224. begin
  225.  
  226. end;
  227.  
  228. procedure TForm1.btnDesignApplyClick(Sender: TObject);
  229. begin
  230.  
  231. end;
  232.  
  233. procedure TForm1.Button3Click(Sender: TObject);
  234. begin
  235.  
  236. end;
  237.  
  238. procedure TForm1.Button4Click(Sender: TObject);
  239. begin
  240.  
  241. end;
  242.  
  243. procedure TForm1.Button5Click(Sender: TObject);
  244. begin
  245.  
  246. end;
  247.  
  248. procedure TForm1.Button6Click(Sender: TObject);
  249. begin
  250.  
  251. end;
  252.  
  253. procedure TForm1.Button7Click(Sender: TObject);
  254. begin
  255.  
  256. end;
  257.  
  258. procedure TForm1.Button8Click(Sender: TObject);
  259. begin
  260.  
  261. end;
  262.  
  263. procedure TForm1.Button9Click(Sender: TObject);
  264. begin
  265.  
  266. end;
  267.  
  268. procedure TForm1.DarkBrownLipstickDblClick(Sender: TObject);
  269. begin
  270.  
  271. end;
  272.  
  273. procedure TForm1.DarkGrayShirtDblClick(Sender: TObject);
  274. begin
  275.  
  276. end;
  277.  
  278. procedure TForm1.btnDesignClick(Sender: TObject);
  279. begin
  280.  
  281. end;
  282.  
  283. procedure TForm1.btnDesignExportClick(Sender: TObject);
  284. begin
  285.  
  286. end;
  287.  
  288. procedure TForm1.btnExportClick(Sender: TObject);
  289. begin
  290.  
  291. end;
  292.  
  293. procedure TForm1.btnHelpClick(Sender: TObject);
  294. begin
  295.  
  296. end;
  297.  
  298. procedure TForm1.btnHomeClick(Sender: TObject);
  299. begin
  300.  
  301. end;
  302.  
  303. procedure TForm1.Button10Click(Sender: TObject);
  304. begin
  305.  
  306. end;
  307.  
  308. procedure TForm1.Button11Click(Sender: TObject);
  309. begin
  310.  
  311. end;
  312.  
  313. procedure TForm1.Button12Click(Sender: TObject);
  314. begin
  315.  
  316. end;
  317.  
  318. procedure TForm1.Button13Click(Sender: TObject);
  319. begin
  320.  
  321. end;
  322.  
  323. procedure TForm1.Button14Click(Sender: TObject);
  324. begin
  325.  
  326. end;
  327.  
  328. procedure TForm1.Button15Click(Sender: TObject);
  329. begin
  330.  
  331. end;
  332.  
  333. procedure TForm1.Button16Click(Sender: TObject);
  334. begin
  335.  
  336. end;
  337.  
  338. procedure TForm1.Button17Click(Sender: TObject);
  339. begin
  340.  
  341. end;
  342.  
  343. procedure TForm1.Button18Click(Sender: TObject);
  344. begin
  345.  
  346. end;
  347.  
  348. procedure TForm1.Button19Click(Sender: TObject);
  349. begin
  350.  
  351. end;
  352.  
  353. procedure TForm1.Button1Click(Sender: TObject);
  354. begin
  355.  
  356. end;
  357.  
  358. procedure TForm1.Button20Click(Sender: TObject);
  359. begin
  360.  
  361. end;
  362.  
  363. procedure TForm1.Button21Click(Sender: TObject);
  364. begin
  365.  
  366. end;
  367.  
  368. procedure TForm1.Button22Click(Sender: TObject);
  369. begin
  370.  
  371. end;
  372.  
  373. procedure TForm1.Button23Click(Sender: TObject);
  374. begin
  375.  
  376. end;
  377.  
  378. procedure TForm1.Button24Click(Sender: TObject);
  379. begin
  380.  
  381. end;
  382.  
  383. procedure TForm1.Button25Click(Sender: TObject);
  384. begin
  385.  
  386. end;
  387.  
  388. procedure TForm1.Button26Click(Sender: TObject);
  389. begin
  390.  
  391. end;
  392.  
  393. procedure TForm1.Button2Click(Sender: TObject);
  394. begin
  395.  
  396. end;
  397.  
  398. procedure TForm1.btnDesignApplyClick(Sender: TObject);
  399. begin
  400.  
  401. end;
  402.  
  403. procedure TForm1.Button3Click(Sender: TObject);
  404. begin
  405.  
  406. end;
  407.  
  408. procedure TForm1.Button4Click(Sender: TObject);
  409. begin
  410.  
  411. end;
  412.  
  413. procedure TForm1.Button5Click(Sender: TObject);
  414. begin
  415.  
  416. end;
  417.  
  418. procedure TForm1.Button6Click(Sender: TObject);
  419. begin
  420.  
  421. end;
  422.  
  423. procedure TForm1.Button7Click(Sender: TObject);
  424. begin
  425.  
  426. end;
  427.  
  428. procedure TForm1.Button8Click(Sender: TObject);
  429. begin
  430.  
  431. end;
  432.  
  433. procedure TForm1.Button9Click(Sender: TObject);
  434. begin
  435.  
  436. end;  
  437.  
  438. procedure TForm1.DarkGrayShirtDblClick(Sender: TObject);
  439. begin
  440.  
  441. end;
  442.  
  443. procedure TForm1.Panel16Click(Sender: TObject);
  444. begin
  445.  
  446. end;
  447.  
  448.                
  449.  
  450.  
  451.  
Title: Re: Why Does LAZ Keep Adding Blank Procedures??
Post by: jamie on August 18, 2019, 06:58:57 pm
I've found if you have a pending compile error in the view window or some code snippet where by the code tools are messed up, the IDE seems not to do as it should.

 Maybe a popup should warn the user of errors in the source before attempting to do such things.

 I do have a project that if I add a method there are two other methods that always gets added although they already exists.

 So using the IDE option to remove empty methods works for me for now.

 Btw, 2.0.4 Is out but I guess that isn't no excuse because the other day I decided to rename a control while there was a source error and it really messed things up because after that the compiler couldn't find the newly renamed control. I noticed in the class it never got renamed so I manually renamed it. After that, it compiled and link but, the control was not getting created on startup, it was NIL. After some messing around I got it working again but this was all due to the fact that I didn't first fix the source error.

Title: Re: Why Does LAZ Keep Adding Blank Procedures??
Post by: pixelink on August 18, 2019, 08:10:27 pm
I've found if you have a pending compile error in the view window or some code snippet where by the code tools are messed up, the IDE seems not to do as it should.

 Maybe a popup should warn the user of errors in the source before attempting to do such things.

 I do have a project that if I add a method there are two other methods that always gets added although they already exists.

 So using the IDE option to remove empty methods works for me for now.

 Btw, 2.0.4 Is out but I guess that isn't no excuse because the other day I decided to rename a control while there was a source error and it really messed things up because after that the compiler couldn't find the newly renamed control. I noticed in the class it never got renamed so I manually renamed it. After that, it compiled and link but, the control was not getting created on startup, it was NIL. After some messing around I got it working again but this was all due to the fact that I didn't first fix the source error.

I tried that and it doesn't always work.

If you back through the entire thread, you will see that is is a confirmed bug.
Title: Re: Why Does LAZ Keep Adding Blank Procedures??
Post by: jamie on August 18, 2019, 11:25:19 pm
I understand, but on my end it doesn't always do this. It really depends on the project.

 The one project I have I can get it to duplicate two methods every time if I don't turn the feature on for the code tools to remove empty methods.

 Its a completed long message of code I converted from an old Delphi 1 app and from a different language. Its not complete and I kind of put the project on the back burner..
 
 The only thing I can come up with is there are some message handler methods in the class and the two methods that duplicate are around those.

 So maybe the scanner has issues getting over those and assumes the methods don't exist and makes new one's
Title: Re: Why Does LAZ Keep Adding Blank Procedures??
Post by: imekon on August 19, 2019, 04:06:29 pm
I got this - functions started duplicating. I fixed it by shutting down Lazarus and restarting, issue went away. No idea why it started happening.
Title: Re: Why Does LAZ Keep Adding Blank Procedures??
Post by: mas steindorff on August 20, 2019, 01:45:08 am
I got this - functions started duplicating. I fixed it by shutting down Lazarus and restarting, issue went away. No idea why it started happening.
same for me.  I've used Lazarus for many years, and have started to see this error only since my upgrade to 2.0.0.  I also have not found what triggers it but I "feel"  it has something to do with the class completion settings. it started a few days after I set "insert method implementations" -> last.  the project that triggers it is large and I'm not allowed to make it pubic so I'm playing around on some other projects to try and reproduce the bug.
one point, The project compiles (clean & build) just fine before the bug bites.  it is when I add a method via the object editor that causes the reintroduction of 4 to 8 procedures.

is 2.0.0 already too old to help track this bug?
Title: Re: Why Does LAZ Keep Adding Blank Procedures??
Post by: jamie on August 20, 2019, 03:32:18 am
Does the class within the source file contain  message handlers methods ?
Title: Re: Why Does LAZ Keep Adding Blank Procedures??
Post by: mas steindorff on August 20, 2019, 04:21:19 am
if OnClick methods are message handlers, then Yes, the new procedures being added match the class (form) and names to a T.  all I've needed to do to fix the error is to delete the new procedures with a block highlight and hit the delete key.  I don't do anything in the top of the unit where the procedures are declared.  otherwise I'm not using and other messaging object in that form.
Title: Re: Why Does LAZ Keep Adding Blank Procedures??
Post by: mas steindorff on January 24, 2020, 07:10:08 am
This bug has spread  to several computers  and co-workers.   Any one have a fix?
Title: Re: Why Does LAZ Keep Adding Blank Procedures??
Post by: jamie on January 24, 2020, 10:43:50 pm
No, Message handlers are those you add that receives and acts an a specific message you define..

For example..

   Procedure AmesageHandler(Var Msg :TMessage); Message LM_USER+?;

etc
 My point is I have a couple of apps that have those in it and I have found the IDE to misbehave
on that issue... It might be something else in the app doing it but that is all I can come up with at the moment..

 Just set your IDE options to remove unused methods.
Title: Re: Why Does LAZ Keep Adding Blank Procedures??
Post by: Mr.Madguy on January 25, 2020, 08:00:58 am
Thing, I like about Lazarus and miss in Delphi: it warns me about unused unit in uses.
Thing, I like about Delphi and miss in Lazarus: it automatically deletes all empty events.
Title: Re: Why Does LAZ Keep Adding Blank Procedures??
Post by: HeavyUser on January 25, 2020, 09:16:23 am
Thing, I like about Delphi and miss in Lazarus: it automatically deletes all empty events.
Not enabled by default but present in lazarus see attached options screenshot
Title: Re: Why Does LAZ Keep Adding Blank Procedures??
Post by: mas steindorff on January 26, 2020, 01:29:46 am
No, Message handlers are those you add that receives and acts an a specific message you define..
...
   Procedure AmesageHandler(Var Msg :TMessage); Message LM_USER+?;
yes, I have created "message handlers" in several of the units I have written.  I use them as call back functions.
I'll give this a try to see if it fixes the Lazarus IDE
Thanks
TinyPortal © 2005-2018