Recent

Author Topic: [SOLVED] TSaveDialog wrong directory  (Read 4105 times)

apeoperaio

  • Sr. Member
  • ****
  • Posts: 272
[SOLVED] TSaveDialog wrong directory
« on: July 16, 2018, 12:33:41 pm »
I have an issue with TSaveDialog on OSX.
I have wrong path when using the folder opened by the TSaveDialog.
In order to reproduce place a button and a TSaveDialog on a form.
The use the code below:
Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls;
  9.  
  10. type
  11.  
  12.   { TForm1 }
  13.  
  14.   TForm1 = class(TForm)
  15.     Button1: TButton;
  16.     Label1: TLabel;
  17.     SaveDialog1: TSaveDialog;
  18.     procedure Button1Click(Sender: TObject);
  19.   private
  20.  
  21.   public
  22.  
  23.   end;
  24.  
  25. var
  26.   Form1: TForm1;
  27.  
  28. implementation
  29.  
  30. {$R *.lfm}
  31.  
  32. { TForm1 }
  33.  
  34. procedure TForm1.Button1Click(Sender: TObject);
  35. begin
  36.   SaveDialog1.FileName:= 'test.txt';
  37.   if SaveDialog1.Execute then
  38.     Label1.Caption:= SaveDialog1.FileName;
  39. end;
  40.  
  41. end.
  42.  

Click the button and navigate to Documents folder, click ok on the save dialog and you will get the right folder, click again on button1, the savedialog will propose you the Documents folder as default, just press Ok on the save dialog and you will get the following filename that is wrong:

test.txt/test.txt

I saw that there are some bug issues on the bug tracker on open and save dialogs on carbon and cocoa but they seems to be resolved but not on my fpc 3.0.4 las 1.8.4

Any hint?
« Last Edit: August 25, 2018, 03:29:01 pm by apeoperaio »

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: TSaveDialog wrong directory
« Reply #1 on: July 16, 2018, 01:56:00 pm »
I saw that there are some bug issues on the bug tracker on open and save dialogs on carbon and cocoa but they seems to be resolved but not on my fpc 3.0.4 las 1.8.4

All testing on Cocoa should be done with Lazarus trunk code from Subversion repository. Cocoa widgetset code in Lazarus 1.8.4 has not been updated since April 2017.

https://macpgmr.github.io/MacXPlatform/UsingCocoaFromTrunk.html

With Carbon, file a bug report, although I would focus on Cocoa since that's the future.

apeoperaio

  • Sr. Member
  • ****
  • Posts: 272
Re: TSaveDialog wrong directory
« Reply #2 on: July 16, 2018, 03:29:57 pm »
I will try to test using lazarus svn.
Cocoa is my target too.
So between lazarus 1.8.2 and lazarus 1.8.4 nothing changed on Cocoa?
Any timeline for a stable cocoa release?

Thank you.

MISV

  • Hero Member
  • *****
  • Posts: 772
Re: TSaveDialog wrong directory
« Reply #3 on: July 19, 2018, 11:53:32 pm »
I use fpcupdeluxe to get cocoa trunk - it much newer than 1.8.4

I only have a few serious issues left in a huge application. The bugs I can create a bug report for gets fixed quickly

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: TSaveDialog wrong directory
« Reply #4 on: August 21, 2018, 01:07:06 am »
Carbon had a persistent bug that it never remembered the last directory. I think it has been fixed in Cocoa, it seems to work for me, but please confirm.

You need to use the current trunk, I use SVN instead of  fpcupdeluxe, either should work.

The trunk is 1.9.0, but has daily updates.
« Last Edit: August 21, 2018, 01:14:30 am by VTwin »
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 12.1: Lazarus 2.2.6 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 2.2.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.2.6 (64 bit on VBox)

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: TSaveDialog wrong directory
« Reply #5 on: August 21, 2018, 01:21:56 am »
Regarding a stable Cocoa release, I am very impressed with the rapid progress. I have several 10000+ line applications which are in shooting distance of a Cocoa release.

I'll add that some workarounds I needed for Carbon I have had to undo for Cocoa, for example a few controls posted events when set in code. So far the Cocoa code looks better. 

The lesson is submit bug reports!
« Last Edit: August 21, 2018, 01:33:24 am by VTwin »
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 12.1: Lazarus 2.2.6 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 2.2.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.2.6 (64 bit on VBox)

apeoperaio

  • Sr. Member
  • ****
  • Posts: 272
Re: TSaveDialog wrong directory
« Reply #6 on: August 25, 2018, 03:28:43 pm »
Tested with last svn and it works!
Cocoa is looking better and better!

 

TinyPortal © 2005-2018