I ran into a problem that really baffled me. I am 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 look for a Windows 7-dependent debugger, but so far I have not had any problems).
Problem: when I try to use QFileDialog :: getOpenFileName () during debugging, the program throws an exception.
The demotion is terminated because it caused an exception.
Stopped in thread 0: Exception in 0x745f7736, code: 0xc0000005: read access violation: 0x0, flags = 0x0 (first chance).
Building releases / debugging doesn't matter. If I run the debugger, it will work. If not, it will work. I tried a bunch of different things to try to figure out why this is happening. I moved getOpenFileName to another part of the program, I tried to change / delete the function call parameters, I deleted basically all of my code except the minimum minimum required to display this file dialog box - QApplication and the main window that calls getOpenFileName () when it is clicked menu item. Nothing succeeded.
Then I created a new project, which was basically the same. Inexplicably, something worked. Thus, much later, and copying things from my main project until it crashed again, I discovered a problem: apparently this is the executable name given by “TARGET” in the .pro file. If it is installed on PrimeWorldEditor (my application name), it will work. If I change it to anything else, it will work.
So my first thought was that there were remaining files that shared their name with the executable, which caused problems. However, cleaning the build folder, restoring the project, and something else does not help.
I am at the point where I am running out of ideas about what might cause the problem, and I tried and could not find through the search any other files that either share their name with the executable, or point to It. If anyone knows what the problem is, I would really appreciate help. I could get around this now by changing the name of the executable, but I would really like to know why this is happening and fix it.
EDIT: A few people request the code, so here is an example of a failed program. Once again, this only happens when the debugger starts with the target executable name set in PrimeWorldEditor. In other cases, it works as expected and opens the getOpenFileName () dialog box.
#include <QApplication> #include <QFileDialog> int main(int argc, char *argv[]) { QApplication a(argc, argv); QFileDialog::getOpenFileName(); return 0; }
I think the problem is probably related to my setup, so I'm not sure if it will be easy to reproduce.
EDIT 2: I want to add that I spent some time on Google to try and find any information related to the problem. I found a couple of people who seemed to have the same problem as myself, like this post , but there were no solutions on these posts.