Dear all, After debugging a little, it appears that in order: - QProgressDialog destructor is called - Then QProgressDialog::setValue(slot) is called by the connection from BackgroundFileWorker::progressChanged(int) signal
This means the slot is called after the dialog was destroyed. It was automatically destroyed by a WA_DeleteOnClose flag. This really looks like a Qt bug I have looked for this bug but only found something python related : http://srinikom.github.io/pyside-bz-archive/904.html However this could be a more generic bug not related to QProgressDialog. Cheers, Etienne 2014/1/23 Etienne Sandré-Chardonnal <etienne.san...@m4x.org> > Dear all, > > I'm tracking a bug since a few days, which happens at the end of file > saving in my app. It saves using a separate thread, while the GUI displays > a modal progress dialog. The app crashes in the QProgressDialog destructor, > and this does not happen all the time. I have double checked that the > destructor is called only once; it's allocated on the heap and I let Qt > destroy it with the flag WA_DeleteOnClose. > > I spent a few hours stripping my app to the bare minimum that keeps it > crashing. The good news is that it's possible to reproduce it with a small > project, the bad is the probability for crashing at each click on the > "save" button decreases when the GUI becomes simple (I had to keep a few > widgets and UI to keep it at a detectable level) but everything is made > with .ui's and generated by Qt, so my code is minimal. You may find the > project attached, I'm running Qt 4.8.1 under win7 64 bit, with mingw32 and > mingw64 (both crash). *To trigger the crash, you need to click on "Save" > toolbutton, then press enter. This needs to be repeated several times, > several varying between 2 and 50.* > > > Here is the only non trivial code that could contain the bug if it's not a > Qt bug. This is a QThread subclass worker doing the file saving (here it > does nothing but this crashes anyway on the QProgressDialog destruction) > > > BackgroundFileWorker::BackgroundFileWorker(QObject *parent) : > > QThread(parent) > > { > > } > > > > bool BackgroundFileWorker::startWriting() > > { > > if(isRunning()) > > { > > return false; > > } > > > _progress = 0; > > > //Create a timer for polling progress update > > QTimer * progressPollingTimer = new QTimer(this); > > progressPollingTimer->setInterval(200); > > connect(this, SIGNAL(started()), progressPollingTimer, SLOT(start())); > > connect(progressPollingTimer, SIGNAL(timeout()), this, > SLOT(updateProgress())); > > connect(this, SIGNAL(finished()), progressPollingTimer, SLOT(stop())); > > connect(this, SIGNAL(finished()), progressPollingTimer, > SLOT(deleteLater())); > > connect(this, SIGNAL(finished()), this, SLOT(updateProgress())); > > > > //Create an application modal progress dialog > > QProgressDialog * progress = new QProgressDialog("Please wait while > writing the file...", "Abort", 0, 100, dynamic_cast<QWidget*>(parent())); > > progress->setWindowTitle("Saving File"); > > connect(this, SIGNAL(progressChanged(int)), progress, > SLOT(setValue(int))); > > connect(this, SIGNAL(finished()), progress, SLOT(close())); > > progress->setWindowModality(Qt::WindowModal); > > progress->setAttribute(Qt::WA_DeleteOnClose); > > progress->setMinimumDuration(0); > > > emit progressChanged(0); > > > start(); > > return true; > > } > > > void BackgroundFileWorker::updateProgress() > > { > > if(isRunning() ) > > { > > _progress+=10; > > emit progressChanged(_progress); > > } > > else if (_progress!=100) > > { > > _progress = 100; > > emit progressChanged(_progress); > > } > > } > > > void BackgroundFileWorker::run() > > { > > } > > > > > Thanks, > > Etienne > > > > >
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest