Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2012-07

savedialog issue

8 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Andrea Mauri

Dear all,
I encountered a strange behaviour of TSaveDialog.
I have a big project, inside of it many TSaveDialogs. Recently I found that sometimes the dialogs are not shown. I didn't find any explanation on this behaviour, here what I understood: TSaveDialog is shown on execute all the times except when I got exceptions (out of memory exceptions that are managed using try finally or try except).
I tried to go inside the execute, since when I call execute it gives me back False without showing the dialog.
In
function TCommonDialog.DoExecute : boolean;
FUserChoice is assigned 2 (mrCancel).

I don't know why. I would like to know where/what I have to check in order to understand this behaviour.
Anyone can help? Any suggestion?

I use:
Lazarus 0.9.31 r37846M FPC 2.6.0 i386-win32-win32/win64

Best regards,
Andrea Mauri

Reply by email

Martin
to Andrea Mauri
Andrea Mauri wrote 11 lines
In function TCommonDialog.DoExecute : boolean; FUserChoice is assigned 2 (mrCancel). I don't know why. I would like to know where/what I have to check in order to understand this behaviour. Anyone can help? Any suggestion? I use: Lazarus 0.9.31 r37846M FPC 2.6.0 i386-win32-win32/win64

I don't know anything about the issue itself, but have you tried setting a watchpoint (context menu in watches list). (Scope = global / Acess write)

Set the watchpoint after TCommonDialog.DoExecute has initialized the value. The watchpoint should stop execution if the value is modified

Reply by email

Andrea Mauri
to Martin

Il 02/07/2012 15:56, Martin ha scritto:

Show quoted text 6 lines
I don't know anything about the issue itself, but have you tried setting a watchpoint (context menu in watches list). (Scope = global / Acess write) Set the watchpoint after TCommonDialog.DoExecute has initialized the value. The watchpoint should stop execution if the value is modified

I tried to evaluate when FUserChoice is assigned 2 (mrCancel).

function TCommonDialog.DoExecute : boolean;
var
   CanClose: boolean;
begin
   FCanCloseCalled := False;
   if Assigned(FOnShow) then
     FOnShow(Self);

--> before this is FUserChoice=0 (mrNone)

   TWSCommonDialogClass(WidgetSetClass).ShowModal(Self);

--> after this is FUserChoice=2 (mrCancel)

I look deeper and I found that in:

class procedure TWin32WSOpenDialog.VistaDialogShowModal(ADialog:
IFileDialog; const AOpenDialog: TOpenDialog);
var
   FileDialogEvents: IFileDialogEvents;
   Cookie: DWord;
   CanClose: Boolean;
begin
   FileDialogEvents := TFileDialogEvents.Create(AOpenDialog);
   ADialog.Advise(FileDialogEvents, @Cookie);
   try
     AOpenDialog.DoShow;
     repeat
       ADialog.Show(GetParentWnd);

--> I set a breakpoint on the line below, the dialog is not shown, UserChoice in the following 'if' line is mrNone, so different from mrOk and then UserChoice is set to mrCancel

       if (AOpenDialog.UserChoice  mrOk) then
       begin
         CanClose := True;
         AOpenDialog.DoCanClose(CanClose);
         AOpenDialog.UserChoice := mrCancel;
       end
       else
         CanClose := True;
     until CanClose;
   finally
     ADialog.unadvise(Cookie);
     FileDialogEvents := nil;
   end;
end;

Reply by email

Andrea Mauri
to Andrea Mauri

Dear all,
also removing the out of memory problem the savedialog is not shown. Someone can give me a feedback in order to understand the problem? What can I check in order to understand why the savedialog is not shown? It is a big issue for me since this affect one of our commercial product.

Let me know,
Andrea

Il 03/07/2012 10:28, Andrea Mauri ha scritto:

Show quoted text 60 lines
Il 02/07/2012 15:56, Martin ha scritto: > > I don't know anything about the issue itself, but have you tried setting > a watchpoint (context menu in watches list). (Scope = global / Acess > write) > > Set the watchpoint after TCommonDialog.DoExecute has initialized the > value. The watchpoint should stop execution if the value is modified I tried to evaluate when FUserChoice is assigned 2 (mrCancel). function TCommonDialog.DoExecute : boolean; var CanClose: boolean; begin FCanCloseCalled := False; if Assigned(FOnShow) then FOnShow(Self); --> before this is FUserChoice=0 (mrNone) TWSCommonDialogClass(WidgetSetClass).ShowModal(Self); --> after this is FUserChoice=2 (mrCancel) I look deeper and I found that in: class procedure TWin32WSOpenDialog.VistaDialogShowModal(ADialog: IFileDialog; const AOpenDialog: TOpenDialog); var FileDialogEvents: IFileDialogEvents; Cookie: DWord; CanClose: Boolean; begin FileDialogEvents := TFileDialogEvents.Create(AOpenDialog); ADialog.Advise(FileDialogEvents, @Cookie); try AOpenDialog.DoShow; repeat ADialog.Show(GetParentWnd); --> I set a breakpoint on the line below, the dialog is not shown, UserChoice in the following 'if' line is mrNone, so different from mrOk and then UserChoice is set to mrCancel if (AOpenDialog.UserChoice mrOk) then begin CanClose := True; AOpenDialog.DoCanClose(CanClose); AOpenDialog.UserChoice := mrCancel; end else CanClose := True; until CanClose; finally ADialog.unadvise(Cookie); FileDialogEvents := nil; end; end;

Reply by email

Mattias Gaertner
to Andrea Mauri

Andrea Mauri hat am 6. Juli 2012 um 13:09
geschrieben:

Dear all, also removing the out of memory problem the savedialog is not shown. Someone can give me a feedback in order to understand the problem? What can I check in order to understand why the savedialog is not shown?

If there is an out of memory exception many things can go wrong. Make sure the out of memory exception only occurs within your function and only because you allocated a big chunk of memory.
There must always be enough memory for the error handling.

Then check with a debugger if any other exception is happening.

It is a big issue for me since this affect one of our commercial product.

Can you show some more context code?

Mattias

Show quoted text 72 lines
> Let me know, Andrea Il 03/07/2012 10:28, Andrea Mauri ha scritto: > Il 02/07/2012 15:56, Martin ha scritto: >> >> I don't know anything about the issue itself, but have you tried setting >> a watchpoint (context menu in watches list). (Scope = global / Acess >> write) >> >> Set the watchpoint after TCommonDialog.DoExecute has initialized the >> value. The watchpoint should stop execution if the value is modified > > I tried to evaluate when FUserChoice is assigned 2 (mrCancel). > > function TCommonDialog.DoExecute : boolean; > var > CanClose: boolean; > begin > FCanCloseCalled := False; > if Assigned(FOnShow) then > FOnShow(Self); > > --> before this is FUserChoice=0 (mrNone) > > TWSCommonDialogClass(WidgetSetClass).ShowModal(Self); > > --> after this is FUserChoice=2 (mrCancel) > > I look deeper and I found that in: > > class procedure TWin32WSOpenDialog.VistaDialogShowModal(ADialog: > IFileDialog; const AOpenDialog: TOpenDialog); > var > FileDialogEvents: IFileDialogEvents; > Cookie: DWord; > CanClose: Boolean; > begin > FileDialogEvents := TFileDialogEvents.Create(AOpenDialog); > ADialog.Advise(FileDialogEvents, @Cookie); > try > AOpenDialog.DoShow; > repeat > ADialog.Show(GetParentWnd); > > --> I set a breakpoint on the line below, the dialog is not shown, > UserChoice in the following 'if' line is mrNone, so different from mrOk > and then UserChoice is set to mrCancel > > if (AOpenDialog.UserChoice mrOk) then > begin > CanClose := True; > AOpenDialog.DoCanClose(CanClose); > AOpenDialog.UserChoice := mrCancel; > end > else > CanClose := True; > until CanClose; > finally > ADialog.unadvise(Cookie); > FileDialogEvents := nil; > end; > end; > -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20120706/7531635b/attachment.html>

Reply by email

Andrea Mauri
to Mattias Gaertner

Il 06/07/2012 13:45, Mattias Gaertner ha scritto:

Show quoted text 6 lines
If there is an out of memory exception many things can go wrong. Make sure the out of memory exception only occurs within your function and only because you allocated a big chunk of memory. There must always be enough memory for the error handling.

The out of memory problem was only inside one of my function since I allocate a lot of memory. Anyway I removed this issue introducing a limit that stops the function before it raises the out of memory exception. Also introducing this modification I still have the same problem with the savedialog.

Usually SaveDialogs and OpenDialogs are shown without any problem, anyway if I run my GUI application on a particular batch then no dialog is shown (neither savedialogs nor opendialogs).
It happens only on windows (I tested it on linux on the same batch and dialogs are shown).

The project is huge, I can't send it, and I can't understand which parts of the code could be useful.
The dialogs are simply called on a buttonclick and I just call the execute method.

I don't know which kind of information could be useful in order to understand the problem..

Show quoted text 8 lines
Then check with a debugger if any other exception is happening. > It is a big issue for me since this affect one of our commercial product. Can you show some more context code?

Reply by email

Mattias Gaertner
to Andrea Mauri
Show quoted text 19 lines
Il 06/07/2012 13:45, Mattias Gaertner ha scritto: > If there is an out of memory exception many things can go wrong. > > Make sure the out of memory exception only occurs within your function > and only because you allocated a big chunk of memory. > > There must always be enough memory for the error handling. The out of memory problem was only inside one of my function since I allocate a lot of memory. Anyway I removed this issue introducing a limit that stops the function before it raises the out of memory exception. Also introducing this modification I still have the same problem with the savedialog. Usually SaveDialogs and OpenDialogs are shown without any problem, anyway if I run my GUI application on a particular batch then no dialog is shown (neither savedialogs nor opendialogs). It happens only on windows (I tested it on linux on the same batch and dialogs are shown).

Can you test if a savedialog can be shown before calling the function?
Maybe it has nothing to do with this function.

Mattias

Reply by email

Andrea Mauri
to Mattias Gaertner

Il 11/07/2012 11:21, Mattias Gaertner ha scritto:

Can you test if a savedialog can be shown before calling the function? Maybe it has nothing to do with this function.

Yes, the savedialog is always shown.

In order to be clearer, the software is this
http://talete.mi.it/products/dragon_description.htm it is a software that calculates molecular descriptors

after calculation descriptors can be saved, the savedialogs (like all the other dialogs) is always shown when I want to save the descriptors after calculation

recently I noticed that if I load a particular set of molecules, after the calculation I am not able to show any dialog, everything in the software works fine but no dialogs are shown (only on windows, on linux it works fine)

I am not able to understand why since no particular exceptions are raised, the only thing is that when I call the execute method the dialogs are not shown returing mrCancel

as reported in a previous mail I noticed

I look deeper and I found that in:

class procedure TWin32WSOpenDialog.VistaDialogShowModal(ADialog:
IFileDialog; const AOpenDialog: TOpenDialog);
var
   FileDialogEvents: IFileDialogEvents;
   Cookie: DWord;
   CanClose: Boolean;
begin
   FileDialogEvents := TFileDialogEvents.Create(AOpenDialog);
   ADialog.Advise(FileDialogEvents, @Cookie);
   try
     AOpenDialog.DoShow;
     repeat
       ADialog.Show(GetParentWnd);

--> I set a breakpoint on the line below, the dialog is not shown, UserChoice in the following 'if' line is mrNone, so different from mrOk and then UserChoice is set to mrCancel

       if (AOpenDialog.UserChoice  mrOk) then
       begin
         CanClose := True;
         AOpenDialog.DoCanClose(CanClose);
         AOpenDialog.UserChoice := mrCancel;
       end
       else
         CanClose := True;
     until CanClose;
   finally
     ADialog.unadvise(Cookie);
     FileDialogEvents := nil;
   end;
end;

Reply by email