OpenDialog.execute reliably crashes - OleInitialize not called for Windows executables
Original Reporter info from Mantis: crlab @neurolabusc1
-
Reporter name: Chris Rorden
Original Reporter info from Mantis: crlab @neurolabusc1
- Reporter name: Chris Rorden
Description:
Hello-
I have found the following bug with Lazarus SVN 13291 (2007-12-12) and also Delphi versions 4-7 (at least) running on Windows XP2 (service pack 2). In general, I found that Delphi OpenDialog boxes occasionally crashes when the user looks around the desktop. Below I illustrate a way to see this behavior 100% of the time. I have seen identical performance on three machines (2 are 32-bit, one has XP 64-bit). By the way, notepad.exe shows the same behavior on Windows XP SP2 32-bit. I think you get the same behavior with SaveDialog.
To elicit the bug:
1.) Show the TOpendialog (opendialog1.execute)
2.) Select an item on the desktop.
3.) Wait for a tooltip to appear.
4.) Press 'Cancel'
5.) Show the TOpendialog (opendialog1.execute)
6.) Select an item on the desktop.
7.) Wait for a tooltip to appear.
-- at this point the program crashes.
The reasons for this bug are described on the Microsoft web site:
http://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.platformsdk.shell&tid=8e6b9b76-3d7f-4e5e-9e17-a555601d5e39&cat=&lang=en&cr=US&sloc=en-us&p=1
The code below is a kludge to fix the problem, but it is pretty clumsy, as every programmer. I wonder if Lazarus could automatically add this to the code during compilation..
{$IFNDEF UNIX}
uses activex;
{$ENDIF}
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
begin
opendialog1.execute;
end;
initialization
{IFDEF FPC} {
I unit1.lrs} {$ENDIF}
{$IFNDEF UNIX}
OleInitialize(nil);
{$ENDIF}
finalization
{$IFNDEF UNIX}
OleUninitialize
{$ENDIF}
end.
Mantis conversion info:
- Mantis ID: 10409
- Version: 0.9.25 (SVN)
- Fixed in version: 0.9.27 (SVN)
- Fixed in revision: 18807 (#cdcb46fc)
- Monitored by: » Christian (Christian)
- Target version: 1.0.0
- LazTarget: 1.0