Hello, I was trying to discover the origin of a strange crash in my application and I came up with a strange beaviour of gdb whilst using QProcess and QFileDialog. This is the code to test:
#include <QProcess>
#include <QString>
#include <QFileDialog>
#include <QApplication>
void fai()
{
myProcess2.start("ps -aux");
myProcess2.waitForFinished(-1);
//Choose a file or press "Cancel", it's the same
QFileDialog::getOpenFileName(0,
"Select File Name",
"",
"*");
myProcess.start("ps -aux");
myProcess.waitForFinished(-1);
}
int main(int argc, char **argv)
{
fai();
fai();
return 0;
}
#include <QProcess>
#include <QString>
#include <QFileDialog>
#include <QApplication>
void fai()
{
QProcess myProcess2;
myProcess2.start("ps -aux");
myProcess2.waitForFinished(-1);
//Choose a file or press "Cancel", it's the same
QFileDialog::getOpenFileName(0,"Select File Name","","*");
QProcess myProcess;
myProcess.start("ps -aux");
myProcess.waitForFinished(-1);
}
int main(int argc, char **argv)
{
QApplication app(argc,argv);
fai();
fai();
return 0;
}
To copy to clipboard, switch view to plain text mode
The basic behaviour is to run a process, show a filedialog, close the dialog (no matter which choice do you make), and start another process.
Usually the problem arisies at the beginning of the second iteration but sometimes happes even during the first call to "fai()".
The program runs fine if I run it w/o a gdb attached to it. But if I try to debug it, gdb fails giving an error about "Couldn't get register" and the program hangs w/o the possibility to resume it. If I put a breakpoint during the execution of the program, the problems doens't show either. Using visual studio this problem doens't show.
Any hints?
I apologize for being of topic if this is not a Qt releated problem.
Bookmarks