Results 1 to 15 of 15

Thread: QFilediaog assertion failure

  1. #1
    Join Date
    Jan 2008
    Location
    Bengaluru
    Posts
    144
    Thanks
    8
    Thanked 7 Times in 7 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Question QFilediaog assertion failure

    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,
    Qt Code:
    1. QFileDialog l_pFiledDlg(this, tr("Open Files"), sPath, tr("All Files (*)"));
    2. QString sFilename1;
    3. l_pFiledDlg.setViewMode(QFileDialog::Detail);
    4. l_pFiledDlg.setFileMode(QFileDialog::ExistingFile);
    5. if (l_pFiledDlg.exec()) sFilename1 = l_pFiledDlg.selectedFiles()[0];
    To copy to clipboard, switch view to plain text mode 

    I have also attached a snapshot of the assertion failure dialog.
    Attached Images Attached Images

  2. #2
    Join Date
    Jan 2008
    Location
    Bengaluru
    Posts
    144
    Thanks
    8
    Thanked 7 Times in 7 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: QFilediaog assertion failure

    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

  3. #3
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QFilediaog assertion failure

    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.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  4. #4
    Join Date
    Jan 2008
    Location
    Bengaluru
    Posts
    144
    Thanks
    8
    Thanked 7 Times in 7 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: QFilediaog assertion failure

    Thanks for the reply. Yes it happens even after commenting out,

    Qt Code:
    1. l_pFiledDlg.setFileMode(QFileDialog::ExistingFile) ;
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    Jan 2008
    Location
    Bengaluru
    Posts
    144
    Thanks
    8
    Thanked 7 Times in 7 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: QFilediaog assertion failure

    It does not happens if I use the static method,

    Qt Code:
    1. QFileDialog::getOpenFileName(this,tr("Open Files"),sPath,tr("All Files (*.*)"));
    To copy to clipboard, switch view to plain text mode 

    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.

  6. #6
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QFilediaog assertion failure

    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.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  7. #7
    Join Date
    Jan 2008
    Location
    Bengaluru
    Posts
    144
    Thanks
    8
    Thanked 7 Times in 7 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: QFilediaog assertion failure

    Qt Code:
    1. QString sPath;
    2. Util.readFilepath(sPath);
    3. QString sFilename3;
    4.  
    5. QFileDialog l_pFiledDlg(this, tr("Open Files"), sPath, tr("All Files (*)"));
    6. l_pFiledDlg.setViewMode(QFileDialog::Detail);
    7. l_pFiledDlg.setFileMode(QFileDialog::ExistingFile);
    8. if (l_pFiledDlg.exec()) sFilename3 = l_pFiledDlg.selectedFiles()[0];
    To copy to clipboard, switch view to plain text mode 

    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 ?

  8. #8
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QFilediaog assertion failure

    You are getting the selection in to 'sFilename3 ', and not do with it anything... ?!
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  9. #9
    Join Date
    Jan 2008
    Location
    Bengaluru
    Posts
    144
    Thanks
    8
    Thanked 7 Times in 7 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: QFilediaog assertion failure

    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.

  10. #10
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QFilediaog assertion failure

    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.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  11. #11
    Join Date
    Jan 2008
    Location
    Bengaluru
    Posts
    144
    Thanks
    8
    Thanked 7 Times in 7 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: QFilediaog assertion failure

    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,

    Qt Code:
    1. QString sPath;
    2. Util.readFilepath(sPath);
    3. QString sFilename3;
    4.  
    5. QFileDialog l_pFiledDlg(this, tr("Open Files"), sPath, tr("All Files (*)"));
    6. l_pFiledDlg.setViewMode(QFileDialog::Detail);
    7. l_pFiledDlg.setFileMode(QFileDialog::ExistingFile);
    8. if (l_pFiledDlg.exec()) sFilename3 = l_pFiledDlg.selectedFiles()[0];
    9.  
    10. if( sFilename3.isEmpty() )
    11. return;
    12.  
    13. m_sFilename3 = sFilename3;
    14.  
    15. Util.storeFilepath(m_sFilename3);
    16. m_pLineEdit3->setText(m_sFilename3);
    17. validateandParseLineEdit3(m_sFilename3);
    To copy to clipboard, switch view to plain text mode 

  12. #12
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QFilediaog assertion failure

    Is the parent of the dialog visible when this slot is executed?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  13. #13
    Join Date
    Jan 2008
    Location
    Bengaluru
    Posts
    144
    Thanks
    8
    Thanked 7 Times in 7 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: QFilediaog assertion failure

    Yes the parent is visible.

  14. #14
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QFilediaog assertion failure

    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.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  15. #15
    Join Date
    Jan 2008
    Location
    Bengaluru
    Posts
    144
    Thanks
    8
    Thanked 7 Times in 7 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: QFilediaog assertion failure

    Thanks. I will look into it. Please let me know if anything you get related to it.

Similar Threads

  1. Debug Assertion Failed
    By ^NyAw^ in forum General Programming
    Replies: 5
    Last Post: 28th December 2007, 11:48
  2. setPixmap cause assertion?
    By Equilibrium in forum Qt Programming
    Replies: 3
    Last Post: 23rd October 2007, 00:34
  3. QGLWIdget renderText() assertion...
    By adonel in forum Qt Programming
    Replies: 3
    Last Post: 22nd October 2007, 21:30
  4. Replies: 5
    Last Post: 20th June 2006, 19:40
  5. ASSERT(Failed assertion in Qt == Qt bug)
    By 0xBulbizarre in forum Qt Programming
    Replies: 1
    Last Post: 20th March 2006, 19:06

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.