Recent

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

wp

  • Hero Member
  • *****
  • Posts: 6661
Re: Why Does LAZ Keep Adding Blank Procedures??
« Reply #15 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?
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

pixelink

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

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

pixelink

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

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

VTwin

  • Hero Member
  • *****
  • Posts: 841
  • Former Turbo Pascal 3 user
Re: Why Does LAZ Keep Adding Blank Procedures??
« Reply #18 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.

« Last Edit: May 03, 2019, 03:44:22 am by VTwin »
“Talk is cheap. Show me the code.” -Linus Torvalds

macOS 10.13.6: Lazarus 2.0.7 fixes svn r62562 (64 bit Cocoa)
Ubuntu 18.04.3: Lazarus 2.0.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.0.6 (64 bit on VBox)
fpc 3.0.4

pixelink

  • Hero Member
  • *****
  • Posts: 1181
    • Pixelink Software
Re: Why Does LAZ Keep Adding Blank Procedures??
« Reply #19 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.
« Last Edit: May 03, 2019, 04:10:29 am by pixelink »
Can't Type - Forgetful - Had Stroke = Forgive this old man!

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

pixelink

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

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

pixelink

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

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

Handoko

  • Hero Member
  • *****
  • Posts: 3288
  • My goal: build my own game engine using Lazarus
Re: Why Does LAZ Keep Adding Blank Procedures??
« Reply #22 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.

wp

  • Hero Member
  • *****
  • Posts: 6661
Re: Why Does LAZ Keep Adding Blank Procedures??
« Reply #23 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
  • 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.
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

pixelink

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

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

pixelink

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

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

lucamar

  • Hero Member
  • *****
  • Posts: 2271
Re: Why Does LAZ Keep Adding Blank Procedures??
« Reply #26 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!!!
« Last Edit: May 03, 2019, 02:49:58 pm by lucamar »
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 2.0.4/2.0.6  - FPC 3.0.4 on:
(K|L)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

pixelink

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

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

lucamar

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

pixelink

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

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