First, not sure if this is really a Qt Creator question or a general Qt 
question, so feel free to suggest I move this over to qt-interest if you think 
it fits better there.

When debugging an application within Qt Creator, is there any reason that an 
application would crash by sending signals to a QProgressDialog too quickly?

The setup:
Our application programs a flash based device over the serial port. I have the 
programming object running in a separate thread from the GUI, and then there's 
a QProgressDialog in the main UI thread that shows the status of the 
programming. These two objects communicate via a signal: void 
sigPageProgrammed(int currentPage, int totalPageCount). We program the device 
in 256 byte pages, with 1024 pages total. As part of that programming process, 
we check to see if the page is "empty" (all bytes equal 0xff within a given 256 
byte block). If it's empty, we skip it to save time. I realized while testing 
that I was only emitting that sigPageProgrammed() signal when we actual wrote a 
page, and didn't emit anything when we get to skip an empty page. One of our 
devices only uses the first 180 pages, so when programming that device, the 
progress dialog increments from 0 to 17% and then doesn't increment anymore 
since the rest of the pages are blank.

So I figured I'd add code to emit that signal even on the empty pages just so 
that the progress bar will always see 0 to 100%, regardless of how many pages 
need to get programmed. Once I made that change, and I'm 100% sure that's the 
only change I made, the application now segfaults when running in debug mode at 
the following line in a slot that is connected to the above signal:
void MainWindow::slotProgrammingStatus(int current, int total)
{
    if(mDlgProgrammingProgress->maximum() != total)
    {
        mDlgProgrammingProgress->setMaximum(total);
    }
    mDlgProgrammingProgress->setValue(current); // <- segfault happens here
    qDebug() << "Programming page" << current << "of" << total;
}

If I rebuild the application in release mode, and run it either from within Qt 
Creator (using CTRL+R) or run it outside Qt Creator altogether it runs just 
fine without crashing, only crashing inside Qt Creator and only in debug mode.  
So the only real difference I see is that for the first 17% of programming, the 
signals are coming out fairly slowly, after that, the next clump of signals are 
going to come out much faster based on how quickly that programming thread can 
determine that each of the remaining pages are empty.

Any ideas?
Sean


This message has been scanned for malware by Forcepoint. www.forcepoint.com
_______________________________________________
Qt-creator mailing list
Qt-creator@qt-project.org
https://lists.qt-project.org/listinfo/qt-creator

Reply via email to