I am using the QFileDialog::getOpenFileName
function to get a file to open. However, on a client's computer running Windows 7 this either displays a corrupted open file dialog as shown in the screenshot, or crashes the entire application.
The code I use to open the file dialog is:
void MainWindow::on_action_triggered() {
auto filename = QFileDialog::getSaveFileName(this, "Generate Report", "", "CSV files (*.csv)");
if (filename.isEmpty()) {
return;
}
// Do operations on filename...
}
I am using Qt 5.5 with Visual Studio 2013.
The issue in this particular case ended up being an incompatibility between Qt and the Dell Backup and Recovery software installed on the client's computer, which included an incompatible shell extension. The solution I used was to remove the backup and recovery software, but it sounds like namespacing Qt is also an alternative. More information is available in QTBUG-41416.
I'm guessing that there is a problem with directory. This empty string provided as path might be problematic. Try fix this this way:
auto filename = QFileDialog::getSaveFileName(this,
tr("Generate Report"),
QString(),
tr("CSV files (*.csv)"));
// or this way
auto filename = QFileDialog::getSaveFileName(this,
tr("Generate Report"),
QDir::home().absolutePath(),
tr("CSV files (*.csv)"));
The root of your problem seems to be memory corruption. To find it, install Microsoft Application Verifier
and configure your app with Basics\Heaps
. You can do it on your own computer, even if the original problem didn't reproduce. After that, try to reproduce the problem, and I guess you will find your memory corruption.
Update
Now that the problem didn't reproduce on your machine and you say the dialog is hung, I suggest the following additional steps (you can do everything yourself in a TeamViewer session to make it easier)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With