Recent

Author Topic: Lazarus keep overwriting the changes I make to source code  (Read 838 times)

udihamudi

  • New Member
  • *
  • Posts: 12
Lazarus keep overwriting the changes I make to source code
« on: September 26, 2022, 03:45:03 pm »
Hi, not sure what is happening I am new to this IDE, but each time I compile the changes I made to the source code are gone and the original file is showing, any way around this?

Thanks!

Arioch

  • Sr. Member
  • ****
  • Posts: 421
Re: Lazarus keep overwriting the changes I make to source code
« Reply #1 on: September 26, 2022, 03:50:16 pm »
what exactly you name "source file"

there are files auto-generated, and there are files for you to edit

udihamudi

  • New Member
  • *
  • Posts: 12
Re: Lazarus keep overwriting the changes I make to source code
« Reply #2 on: September 26, 2022, 05:04:51 pm »
I just edit one of the source lfm files and make some changes, save the file, once I recompile it reverts all the changes. Like it's holding some backup or cashed file somewhere and reverting to it(?)

Thanks!

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2054
  • Fifty shades of code.
    • Delphi & FreePascal
Re: Lazarus keep overwriting the changes I make to source code
« Reply #3 on: September 26, 2022, 05:22:19 pm »
What you mean with "edit lfm" ?? Please describe what you do
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

rvk

  • Hero Member
  • *****
  • Posts: 6163
Re: Lazarus keep overwriting the changes I make to source code
« Reply #4 on: September 26, 2022, 05:23:35 pm »
I just edit one of the source lfm files and make some changes, save the file, once I recompile it reverts all the changes. Like it's holding some backup or cashed file somewhere and reverting to it(?)
With what editor do you make these changes?
If it's outside Lazarus then Lazarus will rewrite the open form over your edited file again.
So make sure the form is closed in Lazarus when editing a lfm file outside the IDE
OR use right+click form and choose View source (lfm) in the IDE itself so you can make the changes there.

udihamudi

  • New Member
  • *
  • Posts: 12
Re: Lazarus keep overwriting the changes I make to source code
« Reply #5 on: September 26, 2022, 05:44:21 pm »
I have this piece of code, I am changing it to the below adding zzzz -
             17
              'Vietnamese'
              2
              18
              'Chinese'
              2
              19
              'Traditional Chinesezzzzzzz'
            )
          end                                                       


Saving to both /sources and /sources/backup, all within the Lazarus IDE, then I recompile and it reverts to   'Traditional Chinese', where is it getting it from??? I searched through the /sources directory and no   'Traditional Chines' in any file, not even in any binary file.. ohhh I am lost

Thanks,


MarkMLl

  • Hero Member
  • *****
  • Posts: 6683
Re: Lazarus keep overwriting the changes I make to source code
« Reply #6 on: September 26, 2022, 05:47:57 pm »
I have this piece of code, I am changing it to the below adding zzzz -
             17
              'Vietnamese'
              2
              18
              'Chinese'
              2
              19
              'Traditional Chinesezzzzzzz'
            )
          end                                                       


Saving to both /sources and /sources/backup, all within the Lazarus IDE, then I recompile and it reverts to   'Traditional Chinese', where is it getting it from??? I searched through the /sources directory and no   'Traditional Chines' in any file, not even in any binary file.. ohhh I am lost

Well DON'T then. The .lfm file should be regarded as having a private format, and should be manipulated only by the object inspector of the IDE: NEVER by editing it directly.

I'm sorry if that sounds hostile, but the reason something's happening that you don't understand is because you're abusing the IDE.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

Arioch

  • Sr. Member
  • ****
  • Posts: 421
Re: Lazarus keep overwriting the changes I make to source code
« Reply #7 on: September 26, 2022, 05:53:11 pm »
Frankly, Delphi IDE lets you do it, and it is the most convenient way of achieveing fine editing, like changing a control from TLabel to TStaticText, moving set of controls to different parent and similar things.

Delphi, however, explicitly has two ways of rendering a for, either designer or source

Lazarus chosen a different way, to have both designer and editable source, and when i edit the LFM file - it is open editable, so why not? - LAzarus starts throwing warnings about "file changed on disk" and whatever i choose firther - it misbehaves.

This is really limiting and confusing. If Lazarus can't stand editing LFM of live form - it should had set it read-only.
« Last Edit: September 26, 2022, 06:00:09 pm by Arioch »

Arioch

  • Sr. Member
  • ****
  • Posts: 421
Re: Lazarus keep overwriting the changes I make to source code
« Reply #8 on: September 26, 2022, 05:58:08 pm »
So make sure the form is closed in Lazarus when editing a lfm file outside the IDE

Funny thing is, i used to do it with closed Lazarus, and then on re-start it still discarded all my changes!

Like it's holding some backup or cashed file somewhere and reverting to it(?)

In the end i found and deleted some "compiled resources" file and since then Lazarus stopped reverting my edits of LFM, but i had a similaryl sounding one.

OR use right+click form and choose View source (lfm) in the IDE itself so you can make the changes there.

Don't!

Yes, editing is allowed, but start editing - and mid-way, before you finish it, Project autosync or something kicks in, prompts you to re-load changed files from disk, and then either your changes are removed, or IDE dies with infinite "property not found" loop.

MarkMLl

  • Hero Member
  • *****
  • Posts: 6683
Re: Lazarus keep overwriting the changes I make to source code
« Reply #9 on: September 26, 2022, 06:36:11 pm »
I've not seen the Lazarus IDE open a form as text by default, although I think it might reopen one if the IDE was exited. There's a right-click operation to get the text represenation, but that immediately closes the form designer... try to edit a .lfm while the form designer's open and what happens's anybody's guess.

In 15+ years of using Lazarus, I do recall going directly into the .lfm text representation when the LCL changed its representation of a couple of controls (tabbed notebooks and SynEdit spring to mind) in order to remove design-time references to elements that varied in different versions. However, the time I've had to use it most often is when I've edited a frame /after/ it's been placed on a form, which has had the result that spurious component properties later had to be removed from the form since they were masking things that had reasonable starting values in the frame definition.

And those, I'm afraid, are hardly things I'd expect a beginner to be doing.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

MarkMLl

  • Hero Member
  • *****
  • Posts: 6683
Re: Lazarus keep overwriting the changes I make to source code
« Reply #10 on: September 26, 2022, 06:48:45 pm »
Frankly, Delphi IDE lets you do it, and it is the most convenient way of achieveing fine editing, like changing a control from TLabel to TStaticText, moving set of controls to different parent and similar things.

There's right-button operations for both of those.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

udihamudi

  • New Member
  • *
  • Posts: 12
Re: Lazarus keep overwriting the changes I make to source code
« Reply #11 on: September 26, 2022, 08:32:44 pm »
Sorry I am newbie I wasn't aware of the inspector etc., took a while to find how to open it  :) now I did everything via the inspector and looks ok.

Thanks!

MarkMLl

  • Hero Member
  • *****
  • Posts: 6683
Re: Lazarus keep overwriting the changes I make to source code
« Reply #12 on: September 26, 2022, 08:45:00 pm »
Glad you're getting the hang of things :-)

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

 

TinyPortal © 2005-2018