Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-49335

Animations don't run when started in a slot for QPropertyAnimation::finished during a local event loop's lifetime

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Reported
    • Priority: P3: Somewhat important
    • Resolution: Unresolved
    • Affects Version/s: 4.8.x, 5.5.1
    • Fix Version/s: None
    • Labels:
      None

      Description

      If you create and start a new QPropertyAnimation in a slot connected to QPropertyAnimation::finished, and create a local event loop (possibly implicitly by using a QDialog), the new animation doesn't run. Testcase (probably also works with other animation classes)

      testcase.cpp
      #include <QPropertyAnimation>
      #include <QApplication>
      #include <QMessageBox>
      
      int main(int argc, char **argv) {
         QApplication qapp(argc, argv);
      
          QPropertyAnimation qa; 
          qa.setProperty("foo", 1.0);
          qa.setTargetObject(&qa); 
          qa.setPropertyName("foo");  
          qa.setStartValue(1.0); 
          qa.setEndValue(0.0); 
          qa.setDuration(50); 
          qa.start(); 
      
          QObject::connect(&qa, &QPropertyAnimation::finished, &qa, [&]{
            QPropertyAnimation &qa = *new QPropertyAnimation; 
            qa.setProperty("foo", 1.0);
            qa.setTargetObject(&qa); 
            qa.setPropertyName("foo");  
            qa.setStartValue(1.0); 
            qa.setEndValue(0.0); 
            qa.setDuration(50); 
            qa.start(); 
      
            QObject::connect(&qa, &QPropertyAnimation::finished, &qa, []{
               QMessageBox::information(nullptr, "Test", "Will not appear");
            });
      
            QMessageBox::information(nullptr, "Test", "Eventloop");
          });
          qapp.exec();
      }
      

      If you connect the finished of the first animation using Qt::QueuedConnection, it works like a charm.

        Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            stromme Christian
            Reporter:
            litb Johannes Schaub
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:

                Gerrit Reviews

                There are no open Gerrit changes