qt - Crash/misfunction of QFileDialog in debug builds -
i know post quite old, i'm experiencing same kind of problem.
i'm using qt 4.6 on windows 7 64 bits, application built visual studio 2008.
i have same kind of use of qfiledialog
class. in slot of 1 of widgets try open "browse window" select file open.
i've tried combinations of following:
- native vs.
qfiledialog
instance on stack vs.qfiledialog
instance on heap. - "parent" parameter set null vs. vs. mainwindow
qfiledialog::dontusenativedialog
settrue
orfalse
const int cfile_open_dlg_type = 0; #define file_open_dlg_parent null //#define file_open_dlg_parent //#define file_open_dlg_parent mmainwindow const bool cfile_open_dlg_native = false; void vgqtmodelwidget::on_mbrowsebutton_clicked() { qstring lfilepath; qfiledialog::options loptions = (cfile_open_dlg_native ? qfiledialog::dontusenativedialog : 0); if (cfile_open_dlg_type == 0) // heap allocated dialog { qfiledialog* lfiledlg = new qfiledialog (file_open_dlg_parent); lfiledlg->setoptions(loptions); lfiledlg->setwindowtitle(tr("open model")); lfiledlg->setfilter(tr("model file (*.vsg4)")); if (!lfiledlg->exec() || !lfiledlg->selectedfiles().size()) { delete lfiledlg; return; } lfilepath = lfiledlg->selectedfiles().at(0); delete lfiledlg; } else if (cfile_open_dlg_type == 1) // stack allocated version { qfiledialog lfiledlg (file_open_dlg_parent); lfiledlg.setoptions(loptions); lfiledlg.setwindowtitle(tr("open model")); lfiledlg.setfilter(tr("model file (*.vsg4)")); if (!lfiledlg.exec() || !lfiledlg.selectedfiles().size()) { return; } lfilepath = lfiledlg.selectedfiles().at(0); } else { lfilepath = qfiledialog::getopenfilename(file_open_dlg_parent,tr("open model file"), tr("."), tr("model file (*.vsg4)"), 0, loptions); } qfile lfile (lfilepath); if (lfile.exists()) { // file... } }
this works flawless in release builds, on debug builds here results:
heap allocated dialog
all versions (native/non-native, parent=this/parent=null) crash.
stack allocated dialog
all versions (native/non-native, parent=this/parent=null) crash.
static helper
- native, whichever parent: getopenfilename returns empty string without showing
- native, whichever parent: crash
thing is, when crash, ugly one, call stack messed up. looks kind debug/non-debug mixup, have double-checked qt_debug defined , link debug libraries qt.
anyone has clue ?
Comments
Post a Comment