Recent

Author Topic: can't close windows after saving to pdf from a preview  (Read 918 times)

tintinux

  • Sr. Member
  • ****
  • Posts: 304
    • Gestinux
can't close windows after saving to pdf from a preview
« on: March 08, 2019, 08:37:22 am »
Hi

With all recent stable releases (1.8.4, 2.0.0), but only on Linux, when I preview a report and then use the button to save it, the save dialog is displayed, the report is correctly saved, but after that the preview Windows goes behind the others and I can't close it and it's parent. I must kill the application.

Setting the preview as modal or not has no effect.

I have searched in the source (LR_Preview.pas) and found that it looks like it is caused by the save dialog.

If I remove the call to the save dialog and replace the filename by a constant like this :

Code: Pascal  [Select]
  1.     {
  2.     SaveDialog.FilterIndex := Index;
  3.     if SaveDialog.Execute then
  4.     begin
  5.       Index := SaveDialog.FilterIndex - 1;
  6.       if fExtList.Objects[Index]=nil then
  7.         SaveToFile(SaveDialog.Filename) // using .frp
  8.       else
  9.       begin
  10.         Index := PtrInt(fExtList.Objects[Index])-1;
  11.         ExportToWithFilterIndex(Index, SaveDialog.FileName);
  12.     }
  13.         ExportToWithFilterIndex(0, '/tmp/test.pdf');
  14.     {
  15.       end;
  16.     end;
  17.     }
 

I have no more problem, the preview remains on foreground and can be closed, as the other windows.

Has anyone found this issue or any idea to solve this ?

Thanks





Initiator of gestinux, open-source, multi-database and multilingual accounting and billing software made with LAZARUS.

You can help to develop, to make and improve translations, and to provide examples of legal charts and reports from more countries.

GetMem

  • Hero Member
  • *****
  • Posts: 3510
Re: can't close windows after saving to pdf from a preview
« Reply #1 on: March 08, 2019, 08:45:43 am »
What happens if you set the preview window's formstyle to fsStayOnTop(alternatively fsSystemStayOnTop) just before you show the save dialog? You can chage it back to fsNormal after the report is saved.
 

tintinux

  • Sr. Member
  • ****
  • Posts: 304
    • Gestinux
Re: can't close windows after saving to pdf from a preview
« Reply #2 on: March 12, 2019, 09:44:04 pm »
Hi

This ? 

Code: Pascal  [Select]
  1. procedure TfrPreviewForm.SaveBtnClick(Sender: TObject);
  2. var
  3.   i, Index: Integer;
  4.   FilterStr: string;
  5.   FilterInfo: TExportFilterItem;
  6.   FExtList:TStringList;
  7.   OldStyle:TFormStyle;
  8. begin
  9.   if EMFPages = nil then Exit;
  10.   FExtList:=TStringList.Create;
  11.   try
  12.     Index := 1;
  13.     if not (roHideDefaultFilter in TfrReport(Doc).Options) then
  14.     begin
  15.       FExtList.Add('*.frp');
  16.       FilterStr := sRepFile + ' (*.frp)|*.frp';
  17.     end else
  18.       FilterStr := '';
  19.  
  20.     for i := 0 to ExportFilters.Count - 1 do
  21.     begin
  22.       FilterInfo := ExportFilters[i];
  23.       if FilterInfo.Enabled then
  24.       begin
  25.         FExtList.AddObject(FilterInfo.FilterExt, TObject(PtrInt(i+1)));
  26.         if FilterStr <> '' then
  27.           FilterStr := FilterStr + '|';
  28.         FilterStr := FilterStr + FilterInfo.FilterDesc + '|' + FilterInfo.FilterExt;
  29.       end;
  30.     end;
  31.     OldStyle := FormStyle;
  32.     FormStyle := fsStayOnTop;
  33.     try
  34.       SaveDialog.Filter := FilterStr;
  35.       SaveDialog.FilterIndex := Index;
  36.       if SaveDialog.Execute then
  37.       begin
  38.         Index := SaveDialog.FilterIndex - 1;
  39.         if fExtList.Objects[Index]=nil then
  40.           SaveToFile(SaveDialog.Filename) // using .frp
  41.         else
  42.         begin
  43.           Index := PtrInt(fExtList.Objects[Index])-1;
  44.           ExportToWithFilterIndex(Index, SaveDialog.FileName);
  45.         end;
  46.       end;
  47.     finally
  48.        FormStyle := OldStyle;
  49.     end;
  50.   finally
  51.     FExtList.Free;
  52.     ScrollBox1.Invalidate;
  53.   end;
  54. end;      
   

It doesn't change anything...
With fsSystemStayOnTop it is worse : the SaveDialog doesn't show and the application hangs.

Regards
Tintinux

Initiator of gestinux, open-source, multi-database and multilingual accounting and billing software made with LAZARUS.

You can help to develop, to make and improve translations, and to provide examples of legal charts and reports from more countries.