Recent

Author Topic: "F2": possible bug in IDE / LCL  (Read 722 times)

Nicole

  • Hero Member
  • *****
  • Posts: 1303
"F2": possible bug in IDE / LCL
« on: December 05, 2025, 10:04:55 am »
Do this:
- have a TPageControl, with a tabsheet
- find this TagSheet anywhere in your code, hit F2 for renaming
- rename it and say "rename all of them"
- run your code and experience an access violation
- go to the form tab at design time and find, - the tabsheet with the old name

workaround:
rename manually another time within the form / object inspector

This is true probably for a lot of components.
I had it before in a Radiogroup as well.

My Lazarus version is 4.0 and my operating system Win 7.
And: I cannot find the bug tracker as the sources are that puzzling to me. Further it would be great, if anybody here would confirm it as possible bug.

Thank you for all you genius here, who write this gorgeous Lazarus, which is with me every day.

jamie

  • Hero Member
  • *****
  • Posts: 7493
Re: "F2": possible bug in IDE / LCL
« Reply #1 on: December 05, 2025, 12:17:28 pm »
Try installing the 4.4?
The only true wisdom is knowing you know nothing

Nicole

  • Hero Member
  • *****
  • Posts: 1303
Re: "F2": possible bug in IDE / LCL
« Reply #2 on: December 05, 2025, 08:50:51 pm »
Will this work by sure? New versions are usually risky.

jamie

  • Hero Member
  • *****
  • Posts: 7493
Re: "F2": possible bug in IDE / LCL
« Reply #3 on: December 05, 2025, 10:22:08 pm »
I can't say for sure, I haven't seen any complaints that points your way?

I currently am using 4.2 and I did the F2 check and ran it through some steps and didn't see any issues.

I haven't had 4.0 on board for a while now but I don't remember that having that issue either.

Its also possible you have some addon in the IDE that could be causing it but I would backup your projects and install the 4.4

I wanted to add that once you install it, go to the TOOLS and do a complete rebuild of the IDE so all of your added controls will showup.

Jamie



Jamie
« Last Edit: December 05, 2025, 10:24:09 pm by jamie »
The only true wisdom is knowing you know nothing

speter

  • Sr. Member
  • ****
  • Posts: 480
Re: "F2": possible bug in IDE / LCL
« Reply #4 on: December 06, 2025, 12:09:58 am »
I can confirm, using Laz 4.4 and Windows 11, that the problem exists.
Note that i didn't experience the access violation, since I imediately renamed the component in the object inspector.

cheers
S.
« Last Edit: December 06, 2025, 12:11:58 am by speter »
I climbed mighty mountains, and saw that they were actually tiny foothills. :)

Nicole

  • Hero Member
  • *****
  • Posts: 1303
Re: "F2": possible bug in IDE / LCL
« Reply #5 on: December 06, 2025, 10:14:17 am »
@ speter, thank you for the warning.
Upgrading is so much work and that risky.

A pity! This renaming by F2 in every context clicked, would be that great.

The upgrade I never regret is from 3.8 to 4.0.
The working with the tabs for Code and Form is the only thing, Embarcadero did better before. With 4.0 the only difference is poor support by the E.'s clarks (compared to those great altruists here) and the very high price.

I am that thankful for Lazarus.


dseligo

  • Hero Member
  • *****
  • Posts: 1651
Re: "F2": possible bug in IDE / LCL
« Reply #6 on: December 06, 2025, 03:56:56 pm »
rename manually another time within the form / object inspector

F2 renames identifiers in the code, but not in the form (lfm files).

If you want to rename something that is on the form, use Object Inspector.
If you want to rename identifier only in the code, use F2 (or Source/Refactoring/Rename Identifier).

It would be nice, though, if Lazarus would warns us when we try to rename some form component with F2.

P.S.: And Lazarus 4.4 behaves the same, so upgrade won't help you with this.
« Last Edit: December 06, 2025, 03:59:21 pm by dseligo »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12023
  • Debugger - SynEdit - and more
    • wiki
Re: "F2": possible bug in IDE / LCL
« Reply #7 on: December 06, 2025, 04:06:11 pm »
If you want to rename identifier only in the code, use F2 (or Source/Refactoring/Rename Identifier).

It would be nice, though, if Lazarus would warns us when we try to rename some form component with F2.

Well "rename identifier" uses codetools. I.e., its a Pascal aware rename. (unlike "find/replace in files, which is brute force, but therefore can be faster).

My guess is, that "rename identifier" has about 70 to 80% of the info it needs to detect (and even act on) forms too. But, then, as usual, the last few percent always take the most work.

In other words, its a reasonable feature request, to make "rename identifier" aware of this. But I have no idea on how likely it is that anyone will pick up that task anytime soon.

Also there are 2 scenarios here:
1) You rename Button1 => then you start inside the form, and all it needs is detection, and redirect the action to whatever existing code runs when you would have done it via OI.
2) You rename TButton (or your own registered components). Then other many forms may have "Button1: TButton" => and that is a more complex story.

WooBean

  • Sr. Member
  • ****
  • Posts: 301
Re: "F2": possible bug in IDE / LCL
« Reply #8 on: December 06, 2025, 04:14:47 pm »
I have tried to do something in this direction. It is ready in trunk (4.99) but a bit hidden.

How to enable it - see https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/41507 .

Platforms: Win7/64, Linux Mint 22.1 Xia

 

TinyPortal © 2005-2018