Board index » cppbuilder » OpenDialog->Execute() Collapse/Crash , why?

OpenDialog->Execute() Collapse/Crash , why?


2006-10-05 08:19:09 PM
cppbuilder8
Hi all, I'm having a strange problem, I'm having a single
function that I call when clicking a button, the function only
use 'OpenDialog->Execute()' to let the user select a file, that's
it, if I click the button several times then after 3-5 tries the
application Collapse/Crash (I get the assembler debugging window)
and it's crashing ONLY when the open file box is open and I set
the mouse cursor over one of the files in the list, at the moment
that I do that, and the yellow pop-up bobble is display, the
application collapse, not before that.
What can it be?
Thanks!
 
 

Re:OpenDialog->Execute() Collapse/Crash , why?

Alex wrote:
Quote
... I'm having a single
function that I call when clicking a button, the function only
use 'OpenDialog->Execute()'
Please show the complete eventhandler for that button and show the
complete function.
Hans.
 

Re:OpenDialog->Execute() Collapse/Crash , why?

Quote
Please show the complete eventhandler for that button and show the
complete function.

Hans.
Hi and thanks Hans, I tested it a little, it's seems like it's
happening ONLY when I try to select a file that is outside my
project folder, first time I select the file (double click on
the file) and no problem at all, but when I click on the button
the second time and I only put the mouse cursor over the file
name the application crash! (just when the yellow pop-up
appears), I'm using Builder 6.0 on a PC with Windows-XP.
When I tried to run the application on another PC with Win-2000
I don't see this problem, as I said I also don't see the problem
when I selecting a file that is inside my Execute folder.
What can be the problem here?
Here is the function -
#include <vcl.h>
#pragma hdrstop
#include "FlashPrgHeader.h"
//--------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//--------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//--------------------------------------------------------------
void __fastcall TForm1::SpeedButton1Click(TObject *Sender)
{
OpenDialog1->Execute();
}
//--------------------------------------------------------------
 

{smallsort}

Re:OpenDialog->Execute() Collapse/Crash , why?

It's looks like it's crashing ONLY when I try to select a file
from my Desktop, when I try to select THE SAME file from
another path then everything looks OK...
 

Re:OpenDialog->Execute() Collapse/Crash , why?

Alex wrote:
Quote
Hi and thanks Hans, I tested it a little, it's seems like it's
happening ONLY when I try to select a file that is outside my
project folder, first time I select the file (double click on
the file) and no problem at all, but when I click on the button
the second time and I only put the mouse cursor over the file
name the application crash!
void __fastcall TForm1::SpeedButton1Click(TObject *Sender)
{
OpenDialog1->Execute();
}
There is not a function that you call wich calls OpenDialog->Execute().
You just call OpenDialog->Execute(); in the eventhandler for the Speedbutton.
Well I can confirm your problems.
Running the program outside the ide.
The firsttime the opendialog is used: choose a file (I did not choose
a different directory first) with a doubleclick. (the opendialogbox will
close then).
The second time the opendialogbox is used it is sufficient
to place the mouse above the same filename and the application
exists! (TurboC++ Explorer and XP) (No troubles with bcb5 on XP)
Hans.
 

Re:OpenDialog->Execute() Collapse/Crash , why?

Alex wrote:
Quote
It's looks like it's crashing ONLY when I try to select a file
from my Desktop, when I try to select THE SAME file from
another path then everything looks OK...
Indeed. Both Turbo C++ and bcb5 do so on XP.
But only if the firsttime the openbox is used it displays the desktop.
No problems after changing directories -as far as I can see-.
Hans.
 

Re:OpenDialog->Execute() Collapse/Crash , why?

Quote
Well I can confirm your problems.
Well.....? so what can be the broblem? and how can I solve it?
Thanks :-)
 

Re:OpenDialog->Execute() Collapse/Crash , why?

Well, *THAT* is certainly an odd beast that I have never come across before.
I followed your code and your directions and also Hans' directions and can
cause a crash in BCB6 and BDS2006. These were the steps I took:
- Create the application
- Drop a TOpenDialog and TButton on the form
- Add OnClick handler for the button
- Put the code "OpenDialog1->Execute()" in the event handler
- Run the program
- Click the button
- Switch to the Desktop (if not already there)
- Double click a file
- Click the button
- Hover over the file double-clicked the last time
- If no AV then repeat at "Double click a file"
I added additional code to the test. I emptied the filename before opening
the dialog. This didn't stop the AV from happening. I removed the visual
OpenDialog1 and changed my code to the following:
TOpenDialog* dialog = new TOpenDialog(this);
dialog->Execute();
delete dialog;
Even this causes the AV. The crash is happening in shell32.dll. This
doesn't mean that it is a Microsoft's fault but it is an interesting fact.
- Clayton
 

Re:OpenDialog->Execute() Collapse/Crash , why?

BTW, I duplicated it in BCB5.
- Clayton
 

Re:OpenDialog->Execute() Collapse/Crash , why?

I implemented a very generic call to GetOpenFileName() in a plain vanilla
windows application and the error happens there, too. Here are the steps:
- File | New | Console Wizard
- Source Type = C
No check boxes
In WinMain() put the following code:
while (1)
{
char filter[] = "All files\0*.*\0\0";
char filename[MAX_PATH + 2] = {0};
OPENFILENAME ofn;
memset(&ofn, 0, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hInstance = hInstance;
ofn.lpstrFilter = filter;
ofn.nFilterIndex = 1;
ofn.lpstrFile = filename;
ofn.nMaxFile = MAX_PATH;
if (GetOpenFileName(&ofn) == 0)
break;
}
BTW, the AV happens using GetSaveFileName() as well.
I tested this on the following machines
XP Home SP2: Crash
Windows 2000 SP4: No crash
Windows 2003 Server SP1: No crash
I don't have access to XP SP1 so I cannot test that. It would appear to me
from my limited sample that this is a Windows XP problem. I did a google
search and found a couple other instances of developers having problems with
XP SP2 and GetOpenFileName().
I posted my test app to the attachments group in a post titled: "Crash using
GetOpenFileName on XP SP2"
- Clayton
 

Re:OpenDialog->Execute() Collapse/Crash , why?

Clayton Arends wrote:
Quote
I posted my test app to the attachments group in a post titled: "Crash using
GetOpenFileName on XP SP2"
You posted an .exe.
If I run that .exe how do I know that it will not force
my {*word*272} to take a picture of me which it would post in the
attachmentsgroup? Or do other thinghs that I do not like?
It hardly is a project, and you posted all code too, but
I prefer the complete project posted.
You did a lot of serious work for it. Well who should
thank you now? Microsoft or Borland?
Of course I trust you Clayton. My remark is more in general.
Hans.
 

Re:OpenDialog->Execute() Collapse/Crash , why?

Heh heh, I thought the same thing. I trust myself, of course! ;-)
I will comply with your wishes and post the project. It does make sense.
- Clayton
 

Re:OpenDialog->Execute() Collapse/Crash , why?

?"Clayton Arends" < XXXX@XXXXX.COM >έγραψε στ?μήνυμα
Quote
I tested this on the following machines

XP Home SP2: Crash
Windows 2000 SP4: No crash
Windows 2003 Server SP1: No crash

I don't have access to XP SP1 so I cannot test that. It would appear to
me from my limited sample that this is a Windows XP problem. I did a
google search and found a couple other instances of developers having
problems with XP SP2 and GetOpenFileName().

I did the same test on C++ Builder IDE (WIN XP SP2 Greek ) to open
a test.txt file ( and mouse over ) to see if also IDE has the symptoms and I
got NO AV !!
Is there any trick ?
_minas harokopos
------
"Only the virtue's conquests have certainty" Sofokleous Erephyle
 

Re:OpenDialog->Execute() Collapse/Crash , why?

I haven't found a trick but my system seems to crash on CSV files more often
;-). Also, I haven't had a crash in any directory other than the Desktop.
BTW, when I say "crash" that only applies to when running in the IDE. If
run outside of the IDE the application simply closes.
- Clayton
 

Re:OpenDialog->Execute() Collapse/Crash , why?

Hi,
Quote
BTW, when I say "crash" that only applies to when running in the IDE. If
run outside of the IDE the application simply closes.
I didn't follow the whole thread but if this is something
that reproduces only with certain versions of the compiler
and OS, it reminded me of an issues with -DWINVER=<OS version>
having an affect on the compilation/size of the OPENFILENAME
struct. Google might show something on that (WINVER).
--Craig