0

I'm using Qt 5.2.1 MinGW 32bit on a Windows 7 machine with gdb from the MinGW 4.8. There is a strange behaviour when i try to singlestep through the code.

QFileDialog open;
open.setDefaultSuffix("tst");
QString fileName=open.getSaveFileName(this,tr("New File"),"",tr("Test File (*.tst)"));
if(fileName!="")
{
...

Im setting a breakpoint at the 1st Line. Singlestepping works until the 3rd Line, than, after choosing a file, gdb says:

Cannot insert breakpoint -1217. Error accessing memory address 0x7219cd30: Input/output error.

When i set a Breakpoint insede the if or after, the Debugger stops at the Breakpoint, but when i try to singlestep after the stop, the same error occurs.

When i set the FileName directly like:

QFileDialog open;
open.setDefaultSuffix("tst");
QString fileName="D:\path\to\File.tst";
if(fileName!="")
{
...

Singlestepping works without any problems.

The Code above runs without any problem, the problem only occurs when i try to singlestep.

Does anyone knows the problem, or a suitable workaround?

Haselnussstrauch
  • 333
  • 2
  • 10
  • The problem is probably in `open.getSaveFileName()` that opens a modal dialog that blocks the execution to the next line `if(fileName!="")...`. I would put a breakpoint on line four too to stop when a file is selected. – vahancho Mar 02 '16 at 10:30
  • I tried that. But when I place a breakpoint at Line 4 (or later, i'm doing a lot of things in the if) the same error occurs. @vahancho – Haselnussstrauch Mar 02 '16 at 10:33

1 Answers1

1

QFileDialog::getSaveFileName() is a static function, but you call it like a member method. I'm only guessing, but probably the way you are calling a static member via an object confuses your debugging environment - the compiler should generate valid code though, so running over your code will work.

BTW, setDefaultSuffix will not work as expected, as getSaveFileName is a static member and will not look at your QFileDialog object.

Jens
  • 6,173
  • 2
  • 24
  • 43