Recent

Author Topic: Why Does LAZ Keep Adding Blank Procedures??  (Read 5075 times)

pixelink

  • Hero Member
  • *****
  • Posts: 1243
    • Pixelink Software
Why Does LAZ Keep Adding Blank Procedures??
« 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.  
« Last Edit: April 28, 2019, 02:12:57 am by pixelink »
Can't Type - Forgetful - Had Stroke = Forgive this old man!

Pixelink Media
LAZ 2.08 •  VSSTUDIO(.Net) 2019 • Win10 • 16G RAM • Nivida GForce RTX 2060

pixelink

  • Hero Member
  • *****
  • Posts: 1243
    • Pixelink Software
Re: Why Does LAZ Keep Adding Blank Procedures??
« Reply #1 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.

Can't Type - Forgetful - Had Stroke = Forgive this old man!

Pixelink Media
LAZ 2.08 •  VSSTUDIO(.Net) 2019 • Win10 • 16G RAM • Nivida GForce RTX 2060

jamie

  • Hero Member
  • *****
  • Posts: 3542
Re: Why Does LAZ Keep Adding Blank Procedures??
« Reply #2 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?

The only true wisdom is knowing you know nothing

pixelink

  • Hero Member
  • *****
  • Posts: 1243
    • Pixelink Software
Re: Why Does LAZ Keep Adding Blank Procedures??
« Reply #3 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.
Can't Type - Forgetful - Had Stroke = Forgive this old man!

Pixelink Media
LAZ 2.08 •  VSSTUDIO(.Net) 2019 • Win10 • 16G RAM • Nivida GForce RTX 2060

lucamar

  • Hero Member
  • *****
  • Posts: 3030
Re: Why Does LAZ Keep Adding Blank Procedures??
« Reply #4 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?
« Last Edit: April 28, 2019, 03:16:26 am by lucamar »
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 2.0.8/FPC 3.0.4 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

pixelink

  • Hero Member
  • *****
  • Posts: 1243
    • Pixelink Software
Re: Why Does LAZ Keep Adding Blank Procedures??
« Reply #5 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.

Can't Type - Forgetful - Had Stroke = Forgive this old man!

Pixelink Media
LAZ 2.08 •  VSSTUDIO(.Net) 2019 • Win10 • 16G RAM • Nivida GForce RTX 2060

jamie

  • Hero Member
  • *****
  • Posts: 3542
Re: Why Does LAZ Keep Adding Blank Procedures??
« Reply #6 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.
« Last Edit: April 28, 2019, 03:29:45 am by jamie »
The only true wisdom is knowing you know nothing

pixelink

  • Hero Member
  • *****
  • Posts: 1243
    • Pixelink Software
Re: Why Does LAZ Keep Adding Blank Procedures??
« Reply #7 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
Can't Type - Forgetful - Had Stroke = Forgive this old man!

Pixelink Media
LAZ 2.08 •  VSSTUDIO(.Net) 2019 • Win10 • 16G RAM • Nivida GForce RTX 2060

lucamar

  • Hero Member
  • *****
  • Posts: 3030
Re: Why Does LAZ Keep Adding Blank Procedures??
« Reply #8 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.
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 2.0.8/FPC 3.0.4 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

pixelink

  • Hero Member
  • *****
  • Posts: 1243
    • Pixelink Software
Re: Why Does LAZ Keep Adding Blank Procedures??
« Reply #9 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
Can't Type - Forgetful - Had Stroke = Forgive this old man!

Pixelink Media
LAZ 2.08 •  VSSTUDIO(.Net) 2019 • Win10 • 16G RAM • Nivida GForce RTX 2060

JanRoza

  • Hero Member
  • *****
  • Posts: 585
    • http://www.silentwings.nl
Re: Why Does LAZ Keep Adding Blank Procedures??
« Reply #10 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.
OS: Windows 10 (64 bit) / Linux Mint (64 bit)
Laz: Lazarus 2.0.10 FPC 3.2.0
       CodeTyphon 7.2 FPC 3.3.1

pixelink

  • Hero Member
  • *****
  • Posts: 1243
    • Pixelink Software
Re: Why Does LAZ Keep Adding Blank Procedures??
« Reply #11 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.
 ::)
« Last Edit: May 01, 2019, 01:28:01 pm by pixelink »
Can't Type - Forgetful - Had Stroke = Forgive this old man!

Pixelink Media
LAZ 2.08 •  VSSTUDIO(.Net) 2019 • Win10 • 16G RAM • Nivida GForce RTX 2060

josh

  • Hero Member
  • *****
  • Posts: 788
Re: Why Does LAZ Keep Adding Blank Procedures??
« Reply #12 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.

Development Installation Lazarus 1.3, FPC 2.7.1,Windows 7/8 32/64, OSX, *nix

Test Environment Lazarus & FPC Trunk on Windows and OSX (Cocoa Mainly on OSX). Testing also Crosscompile windows to OSX.. 
Any posts made from 2015 will be based on Lazarus Trunk.

lucamar

  • Hero Member
  • *****
  • Posts: 3030
Re: Why Does LAZ Keep Adding Blank Procedures??
« Reply #13 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.
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 2.0.8/FPC 3.0.4 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

pixelink

  • Hero Member
  • *****
  • Posts: 1243
    • Pixelink Software
Re: Why Does LAZ Keep Adding Blank Procedures??
« Reply #14 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!
« Last Edit: May 02, 2019, 11:34:19 pm by pixelink »
Can't Type - Forgetful - Had Stroke = Forgive this old man!

Pixelink Media
LAZ 2.08 •  VSSTUDIO(.Net) 2019 • Win10 • 16G RAM • Nivida GForce RTX 2060

 

TinyPortal © 2005-2018