I've run into a problem that's really confusing me. I'm using Qt Creator 3.1.2, with Qt 5.3 on Windows 7, using the MSVC 10.0 compiler and CDB from Debugging Tools for Windows 8.1. (Not sure if I should be looking for a Windows 7-specific debugger, but I haven't had any issues until now).
The problem: when I try to use QFileDialog::getOpenFileName() while debugging, the program throws an exception.
The inferior stopped because it triggered an exception.
Stopped in thread 0 by: Exception at 0x745f7736, code: 0xc0000005: read access violation at: 0x0, flags=0x0 (first chance).
Release/debug build doesn't matter. If I'm running the debugger, it crashes. If I'm not, it works. I tried a bunch of different things to try to figure out why this was happening - I moved the getOpenFileName to a different part of the program, I tried changing/removing the parameters on the function call, I stripped down basically all my code except the bare minimum required to display this file dialog - a QApplication and a main window that called getOpenFileName() when a menubar item is clicked. Nothing worked.
Then I created a new project that was basically the same thing. Inexplicably, -that- worked. So a whole lot of messing around later, and copying things from my main project until it started crashing again, I ended up finding the problem: apparently, it's the executable name set by "TARGET" in the .pro file. If it's set to PrimeWorldEditor (my application's name), it crashes. If I change it to anything else, it works.
So my first thought was that there were leftover files that share their name with the executable somewhere causing problems. However, clearing out the build folder, rebuilding the project, and anything else doesn't help.
I'm at the point where I've run out of ideas for what could be causing the problem, and I've tried and failed to find via search any other files that either share their name with the executable or point to it. If anyone has any idea what the issue could be, I'd really appreciate the help. I could work around it for now by changing the executable's name, but I'd really like to find out why this is happening and fix it.
EDIT: A few people are asking for code, so here's an example of a program that crashes. Once again, this only crashes when running the debugger with the target executable name set to PrimeWorldEditor. Under other circumstances, it works as expected and opens the getOpenFileName() dialog.
#include <QApplication>
#include <QFileDialog>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QFileDialog::getOpenFileName();
return 0;
}
I think the issue is likely something related to my setup, so I'm not sure it'll be easily reproducible.
EDIT 2: I wanna add that I did spend a while Googling to try to find any information related to the issue. I did find a couple people who seemed to have the same problem as me, like this post, but there weren't any solutions on those posts.
I had the same problem and the solution was to uninstall git software, which made context menu in windows explorer.
I got the problem that the program crashed in Visual Studio 2013 Debugger when using QFileDialog::getOpenFileName()
:
Access Violation while reading position 0xFEEEFEEE
It did not crash when I run the program without debugger or when I set the combine Context option in the project configuration -> debugger -> combine with environment = "No".
I re-installed Visual Studio, Qt and nothing helped.
Finally I removed the git-software I have installed the same day and I uninstalled the software; then afterwards the program didn't crash in Debugger anymore.
I am using a Windows 64-bit computer, but run the Qt program with 32 bit. The git software had a context menu in the windows explorer and somehow this interfered with QFileDialog
and caused the problem.
Uhhhh wow okay. I noticed DropboxExt_24 in my call stack for some reason. So I uninstalled the Dropbox app, and suddenly, everything is working correctly. Reinstalled it, and everything still works, so problem solved, I guess?
I've been hosting my code on Dropbox to keep it backed up, not sure if that was related to the issue or not.
来源:https://stackoverflow.com/questions/25270513/qfiledialoggetopenfilename-crashes-when-debugging-apparently-caused-by-projec