Recent

Author Topic: Bug in Lazarus IDE (reloading changed files from disk)  (Read 2453 times)

Manlio

  • Full Member
  • ***
  • Posts: 162
  • Pascal dev
Bug in Lazarus IDE (reloading changed files from disk)
« on: August 30, 2020, 11:30:26 pm »
Dear community, I think I found this IDE bug, on both MacOS (2.0.10, fpc 3.2.0) and Window (2.0.6, fpc 3.0.4).

(I don't know where to post the info, and I hope this place is not too wrong...)

In short: the IDE doesn't reload a form that has changed on the disk, even after the user tells it to do so.

To reproduce the bug:

1. Have Unit1 with a form and a button and some code, open in the IDE.

2. Do a Subversion Update, in which Unit1 code has changed -- BOTH in the unit1.pas and in unit1.lfm. Let's say that a new button has been added to the form.

(Alternatively, manually change both .pas and .lfm files, in a text editor, while the IDE is also open)

3. When you go back to the IDE, you will receive the warning that the file on disk has changed, and you will be prompted to reload it. So far, so good.

4. Choose to reload the changed files from disk. This is where the bug takes place:
The unit1.pas file with the new code is indeed reloaded, but the form, from unit1.lfm, is NOT reloaded. You still see the old form with 1 button.

5. The work-around for this bug is to close unit1 immediately from the IDE, and then reopen it. Now the new new form, with two buttons, will be loaded.

6. Note: if you don't immediately close and reopen unit1 manually, if the form is changed in any way, e.g. the position on the screen, or components changed, then this change will overwrite any changes received with the Update -- indeed you will never even see the changes in the form that should have been reloaded with unit1 after the Update.

The solution, obviously, is that after prompting the user to reload the changed files, both the source code (.pas) and the form file (lfm) should be reloaded, and not only the .pas file

Thanks!
manlio mazzon gmail

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Bug in Lazarus IDE (reloading changed files from disk)
« Reply #1 on: August 30, 2020, 11:47:37 pm »
(I don't know where to post the info, and I hope this place is not too wrong...)
Please see this page on how to create bug reports. I hope it helps

Manlio

  • Full Member
  • ***
  • Posts: 162
  • Pascal dev
Re: Bug in Lazarus IDE (reloading changed files from disk)
« Reply #2 on: September 05, 2020, 01:12:45 pm »
Please see this page on how to create bug reports. I hope it helps

Yes it helped, thank you, I submitted the bug report there, this is the URL:

https://bugs.freepascal.org/view.php?id=37668
manlio mazzon gmail

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4458
  • I like bugs.
Re: Bug in Lazarus IDE (reloading changed files from disk)
« Reply #3 on: October 22, 2020, 03:57:22 pm »
Please test with trunk r64048.
At the same go I improved the DiskDiffsDialog. Now it has a warning if files have changed both locally and externally.

Then a newbie question :
There is a warning icon and text in the dialog. I used a SpeedButton for the image and found IDEImages.AssignImage() to set the icon.
I only need to show an icon, thus a button is not actually needed. TPicture would sound like a logical component but it has no ImageIndex or -List. A picture must be loaded there.
How to improve it? How to handle Hi-DPI scaling?
I know there are graphics oriented people here, thus I ask. I attach a screenshot of the improved window.
« Last Edit: October 22, 2020, 10:30:17 pm by JuhaManninen »
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

wp

  • Hero Member
  • *****
  • Posts: 11833
Re: Bug in Lazarus IDE (reloading changed files from disk)
« Reply #4 on: October 22, 2020, 10:28:35 pm »
I would not use a TImage, too much unused overhead. I'd use a simple TPaintbox with this OnPaint handler:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.PaintBox1Paint(Sender: TObject);
  2. const
  3.   IMAGE_INDEX = 0;
  4.   IMAGE_WIDTH_AT_96PPI = 24;
  5. var
  6.   ppi: Integer;
  7. begin
  8.   ppi := Font.PixelsPerInch;
  9.   ImageList1.DrawForPPI(TPaintbox(Sender).Canvas, IMAGE_INDEX, 0, 0, IMAGE_WIDTH_AT_96PPI, ppi, GetCanvasScaleFactor);
  10. end;
It draws the image at index 0 of the imagelist onto the paintbox canvas. The base image size (at 96ppt) in the imagelist is assumed to be 24x24 (ImageList.Width = 24); the image list must contain the other resolutions needed, usually 150 % (--> 36x36) and 200% (--> 48x48 ppi); its Scaled property must be set to true -- I think the IDEImages do all this. The size of the paintbox (if designed on 96 ppi) is 24x24, too. LCLScaling increases the paintbox if needed and makes the ImageList select the image size fitting best.

(You could also paint onto the form's canvas directly, but then you would need to calculate the size of the scale image yourself.

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4458
  • I like bugs.
Re: Bug in Lazarus IDE (reloading changed files from disk)
« Reply #5 on: October 22, 2020, 11:06:44 pm »
Thanks wp but should I really create an extra ImageList?
I use IDEImages as :
Code: Pascal  [Select][+][-]
  1. IDEImages.AssignImage(WarnSpeedButton, 'state_warning');
and it has no DrawForPPI() method.
IDEImages.AssignImage() has an extra hidden parameter "ImageSize: Integer = 16". I expect the SpeedButton + image to scale automatically for HiDPI. It should anyway.
Note, 'state_warning' is already there and used elsewhere in the IDE. It has higher resolutions for HiDPI.

The icon was easy to add using a SpeedButton. There is a visual button-press effect when clicked but nothing else.
I will leave that for now. I must gather energy before studying more code anyway.
Others are free to improve it of course, either by a patch or by direct commit (those who have access).
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

wp

  • Hero Member
  • *****
  • Posts: 11833
Re: Bug in Lazarus IDE (reloading changed files from disk)
« Reply #6 on: October 23, 2020, 01:27:01 am »
Looking at TIDEImages in components/ideintf, you can see that it has properties Images_12, Images_16 and Images_24 - they are type TLCLGlyphs which inherit from TCustomImageList - like TImageList. Therefore you should be able to use my example when you replace "ImageList1" by "IDEImages.Images_16"; the image index can be queried from GetImageIndex.

I commited this (r64058):

Code: Text  [Select][+][-]
  1. procedure TDiskDiffsDlg.WarnImagePaint(Sender: TObject);
  2. var
  3.   ppi: Integer;
  4.   imgIndex: Integer;
  5.   paintbx: TPaintBox;
  6. begin
  7.   paintbx := Sender as TPaintbox;
  8.   ppi := Font.PixelsPerInch;
  9.   imgIndex := IDEImages.GetImageIndex('state_warning');
  10.   IDEImages.Images_16.DrawForPPI(paintbx.Canvas, 0, 0, imgIndex, 16, ppi, GetCanvasScaleFactor);
  11. end;

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4458
  • I like bugs.
Re: Bug in Lazarus IDE (reloading changed files from disk)
« Reply #7 on: October 23, 2020, 10:39:45 am »
Thanks wp.
Apparently it handles the HiDPI scaling. It looks a little misleading at first because is says Images_16 hinting for 16pix resolution.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

wp

  • Hero Member
  • *****
  • Posts: 11833
Re: Bug in Lazarus IDE (reloading changed files from disk)
« Reply #8 on: October 23, 2020, 11:29:42 am »
The "_16" refers to the "base" resolution, i.e. the resolution at 96ppi. All images will be scaled automatically.

The three image lists contain different images needed by the IDE. The 12-px image list contains the images shown in the message window, the 16-px image list the standard menu and toolbar icons, and the 24-px image list the palette icons.

 

TinyPortal © 2005-2018