PDA

View Full Version : QFilediaog assertion failure



nikhilqt
25th May 2010, 14:35
Hi,

I am building my GUI app on Qt 4.5.3. when i try to copy/insert any values in the linedit of QFileDialog, There will be a prompt of assertion failure from visual studio 2005. Could you please let me know how to fix this issue.

Here is the simple code,

QFileDialog l_pFiledDlg(this, tr("Open Files"), sPath, tr("All Files (*)"));
QString sFilename1;
l_pFiledDlg.setViewMode(QFileDialog::Detail);
l_pFiledDlg.setFileMode(QFileDialog::ExistingFile) ;
if (l_pFiledDlg.exec()) sFilename1 = l_pFiledDlg.selectedFiles()[0];

I have also attached a snapshot of the assertion failure dialog. :confused:

nikhilqt
26th May 2010, 10:59
Hi,

Any information you need, let me know such that I can narrow down the scope of issue. I have both the versions ofQt 4.5.3 and 4.4.0 are installed but I made sure it neatly compiled and linked with Qt 4.5.3.

And one more thing It works fine in Release mode. IS there would be any Debug visual studio settings ?. Let me know if you
get anything related to this.

Thanks,
Nikhil

high_flyer
26th May 2010, 12:39
Does it still happen if you comment out:
l_pFiledDlg.setFileMode(QFileDialog::ExistingFile) ;


And one more thing It works fine in Release mode.
the assertion dialog only pops up in debug build.
The release build ignores it.
You can choose "Ignore" on the dialog and the application will continue to run in debug mode too.

nikhilqt
26th May 2010, 13:30
Thanks for the reply. Yes it happens even after commenting out,


l_pFiledDlg.setFileMode(QFileDialog::ExistingFile) ;

nikhilqt
26th May 2010, 13:35
It does not happens if I use the static method,


QFileDialog::getOpenFileName(this,tr("Open Files"),sPath,tr("All Files (*.*)"));


QFileDialog l_pFiledDlg(this, tr("Open Files"), sPath, tr("All Files (*)"));
QString sFilename1;
l_pFiledDlg.setViewMode(QFileDialog:: Detail);
l_pFiledDlg.setFileMode(QFileDialog::ExistingFile) ;
if (l_pFiledDlg.exec()) sFilename1 = l_pFiledDlg.selectedFiles()[0];

The main intention of using this part of the QFileDialog code is, I want to use detailed view, which cannot be set by using static method.

high_flyer
26th May 2010, 13:40
Can you show the whole function that has the code section you posted?
It "smells" like its a problem of variable getting out of scope.

nikhilqt
26th May 2010, 13:45
QString sPath;
Util.readFilepath(sPath);
QString sFilename3;

QFileDialog l_pFiledDlg(this, tr("Open Files"), sPath, tr("All Files (*)"));
l_pFiledDlg.setViewMode(QFileDialog::Detail);
l_pFiledDlg.setFileMode(QFileDialog::ExistingFile) ;
if (l_pFiledDlg.exec()) sFilename3 = l_pFiledDlg.selectedFiles()[0];

The function contains only this little part of it.


It "smells" like its a problem of variable getting out of scope.
Which variable are you talking about ?

high_flyer
26th May 2010, 13:47
You are getting the selection in to 'sFilename3 ', and not do with it anything... ?!

nikhilqt
26th May 2010, 13:51
I will the pass the filename to the fileparser which no way link with the functionality of the file dialog open, right ?.


You are getting the selection in to 'sFilename3 ', and not do with it anything... ?!


Since QFileDialog enters eventloop. The assertion failure happens even before I(code) get the control.

high_flyer
26th May 2010, 13:53
I will the pass the filename to the fileparser
This means its not the whole code in the function.
Do you want help or not?
I have no time to guess what your mistake is.
You should offer all the information you can so that we can help you.

nikhilqt
26th May 2010, 13:59
I need help. I just asked you whether it anyways helps you. Please do not interpret wrongly. Here is the entire code in the function,


QString sPath;
Util.readFilepath(sPath);
QString sFilename3;

QFileDialog l_pFiledDlg(this, tr("Open Files"), sPath, tr("All Files (*)"));
l_pFiledDlg.setViewMode(QFileDialog::Detail);
l_pFiledDlg.setFileMode(QFileDialog::ExistingFile) ;
if (l_pFiledDlg.exec()) sFilename3 = l_pFiledDlg.selectedFiles()[0];

if( sFilename3.isEmpty() )
return;

m_sFilename3 = sFilename3;

Util.storeFilepath(m_sFilename3);
m_pLineEdit3->setText(m_sFilename3);
validateandParseLineEdit3(m_sFilename3);

high_flyer
26th May 2010, 15:06
Is the parent of the dialog visible when this slot is executed?

nikhilqt
26th May 2010, 15:50
Yes the parent is visible.

high_flyer
26th May 2010, 15:55
Hmm...
Try the following:
let the dialog popup, and just close it with cancel.
Then, have it popup again, and try to edit the filename, see if it still has the error.
It might be also a bug in Qt. you might want to check the bug tracker.
At the moment, I don't see any problem in the code you posted.

nikhilqt
27th May 2010, 09:01
Thanks. I will look into it. Please let me know if anything you get related to it.