Recent

Author Topic: TSaveDialog bug?  (Read 5630 times)

Hansaplast

  • Hero Member
  • *****
  • Posts: 674
  • Tweaking4All.com
    • Tweaking4All
TSaveDialog bug?
« on: July 13, 2016, 03:05:58 pm »
I'm encountering a problem using TSaveDialog in Lazarus 1.6 / FPC 3.0.0 under MacOS X 10.11.6 (beta - but am encountering the same problem in non-beta 10.11).


Example project to reproduce:


Standard application with TSaveDialog and TButton on it.
OnClick for the button:


Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. begin
  3.   if SaveDialog1.Execute then ShowMessage(SaveDialog1.FileName);
  4. end;  


When executing this simple application and clicking on the button, the SaveDialog appears.
Standard it shows the directory "Desktop" (in my case).


When the user enters only the file name (not touching anything else in the dialog), for example 'test.txt' in the "Save As" field, and clicks the "Save" button, the filename results in "/test.txt" - the path is completely ignored.


Am I overlooking something here or should this be reported as a bug?

Hansaplast

  • Hero Member
  • *****
  • Posts: 674
  • Tweaking4All.com
    • Tweaking4All
Re: TSaveDialog bug?
« Reply #1 on: July 13, 2016, 03:15:17 pm »
Note:


When the user DOES select a directory, everything works as expected.
But since it by default shows a directory (Desktop in my example), a user would never think of reselecting the Desktop.


Setting InitialDir and/or Filename, before calling Execute, fails miserably as well (if the user does not manually select a directory).


Example:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. begin
  3.   SaveDialog1.InitialDir:='/Users/hans/Desktop';
  4.   SaveDialog1.FileName:='/Users/hans/Desktop/test2.txt';
  5.   if SaveDialog1.Execute then ShowMessage(SaveDialog1.FileName);
  6. end;  


If the user simply clicks "Save" then the filename will become: /Users/hans/Desktop/test2.txt/test2.txt (see screenshot)

lelebass

  • New Member
  • *
  • Posts: 41
Re: TSaveDialog bug?
« Reply #2 on: August 29, 2016, 06:30:42 pm »
Note:


When the user DOES select a directory, everything works as expected.
But since it by default shows a directory (Desktop in my example), a user would never think of reselecting the Desktop.


Setting InitialDir and/or Filename, before calling Execute, fails miserably as well (if the user does not manually select a directory).


Example:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. begin
  3.   SaveDialog1.InitialDir:='/Users/hans/Desktop';
  4.   SaveDialog1.FileName:='/Users/hans/Desktop/test2.txt';
  5.   if SaveDialog1.Execute then ShowMessage(SaveDialog1.FileName);
  6. end;  


If the user simply clicks "Save" then the filename will become: /Users/hans/Desktop/test2.txt/test2.txt (see screenshot)

I stumbled across the same problem in an application I am developing.
But at the same time, creating a simple application from blank, with a form and a TSaveDialog component seems to work as expected.
I am trying to understand if there are any differences between my app and the simple TSaveDialog test, but with no avail so far.

Daniele

lelebass

  • New Member
  • *
  • Posts: 41
Re: TSaveDialog bug?
« Reply #3 on: August 30, 2016, 09:34:12 am »
While testing TSaveDialog I come across a weird behavior of TOpenDialog under OS X El Capitan 10.11.6 with Lazarus 1.6.0.
 
I created a simple application with an TOpenDialog control. 
Executing the following code:

OpenDialog1.InitialDir:='/Users/daniele/Desktop/';
if OpenDialog1.Execute then ShowMessage(OpenDialog1.FileName);

I expected the OpenDialog to always show the InitialDir, but what happens is that the OpenDialog oscillates between InitialDir and Documents alternatively.

Daniele

lelebass

  • New Member
  • *
  • Posts: 41
Re: TSaveDialog bug?
« Reply #4 on: August 30, 2016, 01:39:40 pm »
While testing TSaveDialog I come across a weird behavior of TOpenDialog under OS X El Capitan 10.11.6 with Lazarus 1.6.0.
 
I created a simple application with an TOpenDialog control. 
Executing the following code:

OpenDialog1.InitialDir:='/Users/daniele/Desktop/';
if OpenDialog1.Execute then ShowMessage(OpenDialog1.FileName);

I expected the OpenDialog to always show the InitialDir, but what happens is that the OpenDialog oscillates between InitialDir and Documents alternatively.

Daniele

This seems not limited to Lazarus 1.6 but seems related to El Capitan. I noticed the same behavior in an application compiled on Mavericks and Lazarus 1.4.4. In El Capitan only the InitialDir is ignored and reverted to the user's /Documents/ folder.

Daniele

Bart

  • Hero Member
  • *****
  • Posts: 5290
    • Bart en Mariska's Webstek
Re: TSaveDialog bug?
« Reply #5 on: August 30, 2016, 03:06:36 pm »
Please open an issue about this on the bugtracker.

Bart

lelebass

  • New Member
  • *
  • Posts: 41
Re: TSaveDialog bug?
« Reply #6 on: August 30, 2016, 04:44:56 pm »
Please open an issue about this on the bugtracker.

Bart

Done.

Cheers,
Daniele

lelebass

  • New Member
  • *
  • Posts: 41
Re: TSaveDialog bug?
« Reply #7 on: October 20, 2016, 04:36:36 pm »
Please open an issue about this on the bugtracker.

Bart

Done.

Cheers,
Daniele

A patch which solves the TSaveDialog problem has been posted on the bugtracker:

http://bugs.freepascal.org/view.php?id=30533

Still some problems in TOpenDialog.

Ciao,
Daniele

 

TinyPortal © 2005-2018