Recent

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

wp

  • Hero Member
  • *****
  • Posts: 11854
Re: Why Does LAZ Keep Adding Blank Procedures??
« Reply #30 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:
  • load the attached project
  • Uncomment the line "end." after the Button1Click method
  • Click on '...' of the OnClick event of Button2 (or any other event).
  • Empty FormShow and FormCreated handlers will be added.
  • However, looking carefully, the original FormShow and FormCreated handlers are still present, after the "end." So, maybe this is not exactly your observation; but IIRC there are options somewhere which inhibit having text after the final "end.".

ASerge

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

    lucamar

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

    wp

    • Hero Member
    • *****
    • Posts: 11854
    Re: Why Does LAZ Keep Adding Blank Procedures??
    « Reply #33 on: May 03, 2019, 08:09:06 pm »
    No, it does not add empty methods for me.

    lucamar

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

    JuhaManninen

    • Global Moderator
    • Hero Member
    • *****
    • Posts: 4459
    • I like bugs.
    Re: Why Does LAZ Keep Adding Blank Procedures??
    « Reply #35 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.
    Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

    gsa

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

    wp

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

    JuhaManninen

    • Global Moderator
    • Hero Member
    • *****
    • Posts: 4459
    • I like bugs.
    Re: Why Does LAZ Keep Adding Blank Procedures??
    « Reply #38 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.
    Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

    jamie

    • Hero Member
    • *****
    • Posts: 6090
    Re: Why Does LAZ Keep Adding Blank Procedures??
    « Reply #39 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.
    The only true wisdom is knowing you know nothing

    pixelink

    • Hero Member
    • *****
    • Posts: 1260
    Re: Why Does LAZ Keep Adding Blank Procedures??
    « Reply #40 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.  
    Can't Type - Forgetful - Had Stroke = Forgive this old man!
    LAZ 2.2.0 •  VSSTUDIO(.Net) 2022 • Win10 • 16G RAM • Nvida GForce RTX 2060

    jamie

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

    The only true wisdom is knowing you know nothing

    pixelink

    • Hero Member
    • *****
    • Posts: 1260
    Re: Why Does LAZ Keep Adding Blank Procedures??
    « Reply #42 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.
    Can't Type - Forgetful - Had Stroke = Forgive this old man!
    LAZ 2.2.0 •  VSSTUDIO(.Net) 2022 • Win10 • 16G RAM • Nvida GForce RTX 2060

    jamie

    • Hero Member
    • *****
    • Posts: 6090
    Re: Why Does LAZ Keep Adding Blank Procedures??
    « Reply #43 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
    The only true wisdom is knowing you know nothing

    imekon

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

     

    TinyPortal © 2005-2018