Recent

Author Topic: Issue with Win32 TSaveDialog.DefaultExt  (Read 7222 times)

AlexTP

  • Hero Member
  • *****
  • Posts: 2557
    • UVviewsoft
Issue with Win32 TSaveDialog.DefaultExt
« on: August 18, 2023, 03:46:16 pm »
Issue not exists on gtk2 on Linux. Make the simple program with Button.OnClick
Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. begin
  3.   SaveDialog1.InitialDir:= ExtractFileDir(Application.ExeName);
  4.   SaveDialog1.Options:= [ofOverwritePrompt,ofPathMustExist,ofEnableSizing,ofDontAddToRecent,ofViewDetail];
  5.   SaveDialog1.Filter:= 'YAML|*.yml;*.yaml|All files|*';
  6.   //bug exists only if '*' is after 'All files|'
  7.   SaveDialog1.DefaultExt:= 'yml';
  8.   SaveDialog1.FileName:= '';
  9.   if SaveDialog1.Execute then
  10.     caption:= 'chosen: '+ExtractFileName(SaveDialog1.FileName)
  11.   else
  12.     caption:= 'cancel';
  13. end;
  14.  

- run the demo, press the btn
- choose 2nd filter - ie 'All files'
- enter filename 'n.lua', OK
--> resulting filename is 'n.lua.yml' with bad tail.

If i replace '*' mask with '*.*', no bug.


« Last Edit: August 18, 2023, 06:41:22 pm by AlexTP »

Bart

  • Hero Member
  • *****
  • Posts: 5552
    • Bart en Mariska's Webstek
Re: Issue with Win32 TSaveDialog.DefaultExt
« Reply #1 on: August 18, 2023, 05:12:55 pm »
I cannot reproduce: Lazarus 3.99 (rev main_3_99-437-g5fbeef0e07) FPC 3.2.2 i386-win32-win32/win64

Used "Pascal|*.pas;*.pp;*.p|All files|*" as filter.
Executed the dialog.
Selected the All files filter.
Typed: abacadabra -> abacadabra.pp
Typed: abacadabra.txt -> abacadabra.txt

Bart

ASerge

  • Hero Member
  • *****
  • Posts: 2401
Re: Issue with Win32 TSaveDialog.DefaultExt
« Reply #2 on: August 18, 2023, 05:31:55 pm »
I cannot reproduce: Lazarus 3.99 (rev main_3_99-437-g5fbeef0e07) FPC 3.2.2 i386-win32-win32/win64

Used "Pascal|*.pas;*.pp;*.p|All files|*" as filter.
Executed the dialog.
Selected the All files filter.
Typed: abacadabra -> abacadabra.pp
Typed: abacadabra.txt -> abacadabra.txt

Bart

Also not reproduced. lazarus 3.0RC1. Windows 7.

AlexTP

  • Hero Member
  • *****
  • Posts: 2557
    • UVviewsoft
Re: Issue with Win32 TSaveDialog.DefaultExt
« Reply #3 on: August 18, 2023, 06:09:18 pm »
Sample project in zip.

- run, press button, enter "n.lua", press Enter.
- caption shows 'n.lua.yml'

wp

  • Hero Member
  • *****
  • Posts: 12757
Re: Issue with Win32 TSaveDialog.DefaultExt
« Reply #4 on: August 18, 2023, 06:31:21 pm »
- run the demo, press the btn
- choose 2nd filter - ie 'All files'
- enter filename 'n.lua', OK
--> resulting filename is 'n.lua.yml' with bad tail.
Running your test application on Manjaro Linux/gtk2 --> Resulting filename is 'n.lua' after these steps. (Laz/main + fpc 3.2.2)

AlexTP

  • Hero Member
  • *****
  • Posts: 2557
    • UVviewsoft
Re: Issue with Win32 TSaveDialog.DefaultExt
« Reply #5 on: August 18, 2023, 06:38:09 pm »
@wp, Manjaro Lunux is already good, as I wrote I see bug only on win32.

BlueIcaro

  • Hero Member
  • *****
  • Posts: 818
    • Blog personal
Re: Issue with Win32 TSaveDialog.DefaultExt
« Reply #6 on: August 18, 2023, 06:56:57 pm »
Hi, may be because all files in Windows is *.*
/blueIcaro

wp

  • Hero Member
  • *****
  • Posts: 12757
Re: Issue with Win32 TSaveDialog.DefaultExt
« Reply #7 on: August 18, 2023, 08:26:14 pm »
@wp, Manjaro Lunux is already good, as I wrote I see bug only on win32.
Sorry - saw "gtk2 on Linux" and stopped reading since I had used gtk2 for another issue before...

Repeated with Windows 11, Laz/main+fpc3.2.2, Laz 2.2.6/fpc3.2.2, Laz 2.0.12/fpc3.2.0 --> in each case the Caption displays "chosen: n.lua" --> cannot reproduce.

I know that there was some work with masks some time ago. Do you use Laz/main? Maybe it is of that time period? Update to the recent commit.
« Last Edit: August 18, 2023, 08:27:54 pm by wp »

AlexTP

  • Hero Member
  • *****
  • Posts: 2557
    • UVviewsoft
Re: Issue with Win32 TSaveDialog.DefaultExt
« Reply #8 on: August 18, 2023, 08:34:41 pm »
I use Laz/main, ie today's Git version.
And FPC 3.2-fixes branch.

wp

  • Hero Member
  • *****
  • Posts: 12757
Re: Issue with Win32 TSaveDialog.DefaultExt
« Reply #9 on: August 18, 2023, 08:44:44 pm »
You are right: Using Laz/main + FPC/fixes or Laz/main + FPC/main I can confirm the issue. Please report it to the FPC project bug tracker. Maybe you can find a way to simplify the project and remove the dependence on Lazarus - FPC devs often do not like to see Lazarus in a bug report. Well, here with no issue in the combination Laz/main + FPC 3.2.2 is clear that FPC is the culprit, though. If you cannot simplify the report clearly specify that the issue appears only when FPC/main (or fixes) is used.

AlexTP

  • Hero Member
  • *****
  • Posts: 2557
    • UVviewsoft

dseligo

  • Hero Member
  • *****
  • Posts: 1496
Re: Issue with Win32 TSaveDialog.DefaultExt
« Reply #11 on: August 19, 2023, 11:55:03 am »
I confirm it in Windows 11, with:
Lazarus 2.2.6 (rev lazarus_2_2_6) FPC 3.2.2 x86_64-win64-win32/win64
Lazarus 3.99 (rev 15989485bf) FPC 3.3.1 x86_64-win64-win32/win64

BrunoK

  • Hero Member
  • *****
  • Posts: 696
  • Retired programmer
Re: Issue with Win32 TSaveDialog.DefaultExt
« Reply #12 on: August 19, 2023, 12:17:44 pm »
Retract : [Windows :try adding ofExtensionDifferent to options.]
Didn't understand what is expected.
« Last Edit: August 19, 2023, 12:54:02 pm by BrunoK »

Bart

  • Hero Member
  • *****
  • Posts: 5552
    • Bart en Mariska's Webstek
Re: Issue with Win32 TSaveDialog.DefaultExt
« Reply #13 on: August 19, 2023, 12:34:28 pm »
The logic behind alls this is methods:
- procedure TOpenDialog.CheckFile
- function GetExtensionFromFilterAtIndex
- function ExtractFilterValues

@Alexey: can you confirm that the FileName parameter in CheckFile is the file without any extension?

Bart

wp

  • Hero Member
  • *****
  • Posts: 12757
Re: Issue with Win32 TSaveDialog.DefaultExt
« Reply #14 on: August 19, 2023, 12:38:56 pm »
I can't believe it: Checked Laz/main + fpc 3.2.2 again - and now it is confirming the issue, yesterday it did not. What's going on here?

 

TinyPortal © 2005-2018