Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QProgressDialog, bug in Qt 4.8.0 or something else ?

QProgressDialog, bug in Qt 4.8.0 or something else ?

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 3.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Anticross
    wrote on last edited by
    #1

    I'm using Qt 4.8.0 under Windows OS and I have the division by zero error when set value to 1:
    @void QProgressDialog::setValue(int progress)
    {
    Q_D(QProgressDialog);
    if (progress == d->bar->value()
    || (d->bar->value() == -1 && progress == d->bar->maximum()))
    return;

    d->bar->setValue(progress);
    
    if (d->shown_once) {
        if (isModal())
            QApplication::processEvents();
    } else {
        if (progress == 0) {
            d->starttime.start();
            d->forceTimer->start(d->showTime);
            return;
        } else {
            bool need_show;
            int elapsed = d->starttime.elapsed();
            if (elapsed >= d->showTime) {
                need_show = true;
            } else {
                if (elapsed > minWaitTime) {
                    int estimate;
                    int totalSteps = maximum() - minimum();
                    int myprogress = progress - minimum();
                    if ((totalSteps - myprogress) >= INT_MAX / elapsed)
                        estimate = (totalSteps - myprogress) / myprogress * elapsed;
                    else
                        estimate = elapsed * (totalSteps - myprogress) / myprogress;
                    need_show = estimate >= d->showTime;
                } else {
                    need_show = false;
                }
            }
            if (need_show) {
                int w = qMax(isVisible() ? width() : 0, sizeHint().width());
                int h = qMax(isVisible() ? height() : 0, sizeHint().height());
                resize(w, h);
                show();
                d->shown_once = true;
            }
        }@
    

    right here @estimate = elapsed * (totalSteps - myprogress) / myprogress;@ I have @myprogress = 0;@ As I see @int myprogress = progress - minimum();@ Where minimum() returns 1 and progress is 1. So when I'm switch to Qt 4.7.4 there is no error using QProgressDialog. So maybe it's a bug in 4.8.0 version.

    1 Reply Last reply
    0
    • L Offline
      L Offline
      lgeyer
      wrote on last edited by
      #2

      Related to "http://developer.qt.nokia.com/forums/viewthread/8993":http://developer.qt.nokia.com/forums/viewthread/8993.

      Feel free to file a "bugreport":http://developer.qt.nokia.com/doc/qt-4.8/bughowto.html. This behaviour should be fixed.

      1 Reply Last reply
      0
      • G Offline
        G Offline
        goetz
        wrote on last edited by
        #3

        The source code of qprogressdialog.cpp did not change between Qt 4.7.4 and 4.8.0.

        http://www.catb.org/~esr/faqs/smart-questions.html

        1 Reply Last reply
        0
        • A Offline
          A Offline
          Anticross
          wrote on last edited by
          #4

          I only show the place where I have error using qt 4.8.0. There is no error using 4.7.4 so I can't know exactly what the reason.

          1 Reply Last reply
          0
          • A Offline
            A Offline
            Anticross
            wrote on last edited by
            #5

            Here is my code where I use QProgressDialog:
            @ QProgressDialog progress(tr("Save configuration to station"), tr("Abort"), 0, 0, parent);
            progress.setWindowModality(Qt::WindowModal);

            int offset = 0;
            int fullSize = model.getBukDataSize();
            
            if (transfer.startCommit() == false) {
                isAborted = true;
                hasErrors = true;
            } else {
                progress.setRange(1, fullSize+1);
                progress.setValue(1);
            
                int nWrong = 0;
            
                while (offset < fullSize) {
                    qApp->processEvents();
            
                    if (progress.wasCanceled()) {
                        isAborted = true;
                        break;
                    }
            
                    int size = fullSize - offset;
                    if (size > packsize)
                        size = packsize;
            
                    if (size != transfer.storeCommit(model.getBukData(), offset, size)) {
                        if (nWrong > 10) {
                            isAborted = true;
                            hasErrors = true;
                            break;
                        }
                        nWrong++;
                        continue;
                    }
            
                    offset += size;
                    progress.setValue(offset);
                }
            }@
            
            1 Reply Last reply
            0
            • A Offline
              A Offline
              Anticross
              wrote on last edited by
              #6

              So it seemed like I've got a crash when setting value to "1" : @progress.setValue(1);@ I tried to set value to zero before it, as here:http://developer.qt.nokia.com/forums/viewthread/8993 But it has no effect. One more thing: when I make some delay before calling setValue by putting sleep for 10 msecs, all working good.

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved