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. Why dump in QAbstractAnimation::start
Forum Updated to NodeBB v4.3 + New Features

Why dump in QAbstractAnimation::start

Scheduled Pinned Locked Moved Solved General and Desktop
16 Posts 5 Posters 1.1k Views
  • 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.
  • jsulmJ jsulm

    @Toocold said in Why dump in QAbstractAnimation::start:

    But I dump In QAbstractAnimation::start

    What do you mean with that? The second animation does not start if the first one finishes?

    T Offline
    T Offline
    Toocold
    wrote on last edited by
    #3

    @jsulm I mean that my program crashed in this function.

    1 Reply Last reply
    0
    • T Toocold
      void func()
      {
      ...
          connect(pAnimationBannerOpacity, &QPropertyAnimation::finished,
              [&] { pAnimationTextGeometry->start(); });
      ...
          pAnimationBannerOpacity->start();
      }
      

      I want a Animation start when another Animation end.
      But I dump In QAbstractAnimation::start.
      Can anyone tell me why. Thanks.

      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #4

      @Toocold do you happen to have called start(QAbstractAnimation::DeleteWhenStopped) instead of start(QAbstractAnimation::KeepWhenStopped)


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      T 1 Reply Last reply
      0
      • J.HilkJ J.Hilk

        @Toocold do you happen to have called start(QAbstractAnimation::DeleteWhenStopped) instead of start(QAbstractAnimation::KeepWhenStopped)

        T Offline
        T Offline
        Toocold
        wrote on last edited by
        #5

        @J-Hilk
        no.

        pAnimationBannerOpacity     = new QPropertyAnimation(m_pIntroduction->pOpacityBanner, "opacity", m_pIntroduction->pLableBanner);
        pAnimationTextGeometry      = new QPropertyAnimation(m_pIntroduction->pLableText, "geometry", m_pIntroduction->pLableBanner);
        

        I just set parent to them.
        The Animation like some's Opacity from 0 to 1, and then play Geometry Animation.

        jsulmJ 1 Reply Last reply
        0
        • T Toocold

          @J-Hilk
          no.

          pAnimationBannerOpacity     = new QPropertyAnimation(m_pIntroduction->pOpacityBanner, "opacity", m_pIntroduction->pLableBanner);
          pAnimationTextGeometry      = new QPropertyAnimation(m_pIntroduction->pLableText, "geometry", m_pIntroduction->pLableBanner);
          

          I just set parent to them.
          The Animation like some's Opacity from 0 to 1, and then play Geometry Animation.

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #6

          @Toocold I suggest to use debugger and position a breakpoint at

          pAnimationTextGeometry->start();
          

          and check what happens when you execute that line. Is, fir example, pAnimationTextGeometry really pointing to an existing instance?

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          T 1 Reply Last reply
          0
          • jsulmJ jsulm

            @Toocold I suggest to use debugger and position a breakpoint at

            pAnimationTextGeometry->start();
            

            and check what happens when you execute that line. Is, fir example, pAnimationTextGeometry really pointing to an existing instance?

            T Offline
            T Offline
            Toocold
            wrote on last edited by
            #7

            @jsulm
            In this Function

            void QAbstractAnimation::start(DeletionPolicy policy)
                
                {
                
                    Q_D(QAbstractAnimation);
                
                    if (d->state == Running)
                
                        return;
                
                    d->deleteWhenStopped = policy;
                
                    d->setState(Running);
                
                }
            

            My program crashed because of "d" is Null.
            But it's strange, the QPropertyAnimation instance is newed in heap.
            And I set theirs' parent Null now and start(QAbstractAnimation::KeepWhenStopped) instead of.

            jsulmJ 1 Reply Last reply
            0
            • T Toocold

              @jsulm
              In this Function

              void QAbstractAnimation::start(DeletionPolicy policy)
                  
                  {
                  
                      Q_D(QAbstractAnimation);
                  
                      if (d->state == Running)
                  
                          return;
                  
                      d->deleteWhenStopped = policy;
                  
                      d->setState(Running);
                  
                  }
              

              My program crashed because of "d" is Null.
              But it's strange, the QPropertyAnimation instance is newed in heap.
              And I set theirs' parent Null now and start(QAbstractAnimation::KeepWhenStopped) instead of.

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #8

              @Toocold said in Why dump in QAbstractAnimation::start:

              My program crashed because of "d" is Null.

              Then the object is invalid/not initialised.

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              T 1 Reply Last reply
              1
              • jsulmJ jsulm

                @Toocold said in Why dump in QAbstractAnimation::start:

                My program crashed because of "d" is Null.

                Then the object is invalid/not initialised.

                T Offline
                T Offline
                Toocold
                wrote on last edited by
                #9

                @jsulm

                        connect(pAnimationBannerOpacity, &QPropertyAnimation::finished,
                            [&]
                        {
                            if (pAnimationTextGeometry)
                            {
                                pAnimationTextGeometry->start(QAbstractAnimation::KeepWhenStopped);
                            }
                        });
                

                But I checked it before invoking the function.
                And It can work by added to QSequentialAnimationGroup Class.

                jsulmJ JonBJ 2 Replies Last reply
                0
                • T Toocold

                  @jsulm

                          connect(pAnimationBannerOpacity, &QPropertyAnimation::finished,
                              [&]
                          {
                              if (pAnimationTextGeometry)
                              {
                                  pAnimationTextGeometry->start(QAbstractAnimation::KeepWhenStopped);
                              }
                          });
                  

                  But I checked it before invoking the function.
                  And It can work by added to QSequentialAnimationGroup Class.

                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #10

                  @Toocold said in Why dump in QAbstractAnimation::start:

                  if (pAnimationTextGeometry)

                  This only checks whether the pointer is not nullptr, but it still can point to not allocated memory.

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  T 1 Reply Last reply
                  3
                  • T Toocold

                    @jsulm

                            connect(pAnimationBannerOpacity, &QPropertyAnimation::finished,
                                [&]
                            {
                                if (pAnimationTextGeometry)
                                {
                                    pAnimationTextGeometry->start(QAbstractAnimation::KeepWhenStopped);
                                }
                            });
                    

                    But I checked it before invoking the function.
                    And It can work by added to QSequentialAnimationGroup Class.

                    JonBJ Offline
                    JonBJ Offline
                    JonB
                    wrote on last edited by
                    #11

                    @Toocold
                    Because you cannot afford to deference a pointer if it's pointing to garbage, if you use a debugger as @jsulm suggested you can look in its "watch" window at what pAnimationTextGeometry actually points to. It's not foolproof, but if what the debugger shows doesn't look good, it's probably a bad pointer.

                    1 Reply Last reply
                    1
                    • jsulmJ jsulm

                      @Toocold said in Why dump in QAbstractAnimation::start:

                      if (pAnimationTextGeometry)

                      This only checks whether the pointer is not nullptr, but it still can point to not allocated memory.

                      T Offline
                      T Offline
                      Toocold
                      wrote on last edited by
                      #12

                      @jsulm @JonB Thanks for your suggestion.
                      I don't know how to check the pointer is point to an allocated memory.
                      So I defined the pointer in the lambda function, and it worked.
                      But why my pAnimationTextGeometry was recycled, I didn't give him a parent.

                      T 1 Reply Last reply
                      0
                      • T Toocold

                        @jsulm @JonB Thanks for your suggestion.
                        I don't know how to check the pointer is point to an allocated memory.
                        So I defined the pointer in the lambda function, and it worked.
                        But why my pAnimationTextGeometry was recycled, I didn't give him a parent.

                        T Offline
                        T Offline
                        Toocold
                        wrote on last edited by
                        #13

                        @jsulm @JonB
                        You can try this program, it will crash.

                        void func()
                        {
                            QLabel* p1 = new QLabel;
                            QLabel* p2 = new QLabel;
                            QPropertyAnimation*     pA1;
                            QPropertyAnimation*     pA2;
                        
                            p1->setText("123");
                            p2->setText("456");
                            p1->setGeometry(QRect(0, 0, 0, 0));
                            p2->setGeometry(QRect(0, 0, 0, 0));
                        
                            p1->show();
                            p2->show();
                        
                            pA1 = new QPropertyAnimation(p1, "geometry");
                            pA2 = new QPropertyAnimation(p2, "geometry");
                        
                            pA1->setDuration(1000);
                            pA1->setStartValue(QRect(0, 0, 0, 0));
                            pA1->setEndValue(QRect(660, 660, 60, 60));
                        
                            pA2->setDuration(1000);
                            pA2->setStartValue(QRect(0, 0, 0, 0));
                            pA2->setEndValue(QRect(330, 330, 30, 30));
                        
                            QObject::connect(pA1, &QPropertyAnimation::finished, [&] {
                                pA2->start();
                            });
                        
                            pA1->start();
                        }
                        
                        int main(int argc, char** argv)
                        {
                            QApplication a(argc, argv);
                        
                            func();
                        
                            return a.exec();
                        }
                        
                        1 Reply Last reply
                        0
                        • Christian EhrlicherC Offline
                          Christian EhrlicherC Offline
                          Christian Ehrlicher
                          Lifetime Qt Champion
                          wrote on last edited by
                          #14

                          @Toocold said in Why dump in QAbstractAnimation::start:

                          QObject::connect(pA1, &QPropertyAnimation::finished, [&] {

                          C++ basics - you catch the variables by reference...

                          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                          Visit the Qt Academy at https://academy.qt.io/catalog

                          T 1 Reply Last reply
                          2
                          • Christian EhrlicherC Christian Ehrlicher

                            @Toocold said in Why dump in QAbstractAnimation::start:

                            QObject::connect(pA1, &QPropertyAnimation::finished, [&] {

                            C++ basics - you catch the variables by reference...

                            T Offline
                            T Offline
                            Toocold
                            wrote on last edited by
                            #15

                            @Christian-Ehrlicher
                            Yeah...I didn't notice it.
                            Thank you.

                            Christian EhrlicherC 1 Reply Last reply
                            0
                            • T Toocold

                              @Christian-Ehrlicher
                              Yeah...I didn't notice it.
                              Thank you.

                              Christian EhrlicherC Offline
                              Christian EhrlicherC Offline
                              Christian Ehrlicher
                              Lifetime Qt Champion
                              wrote on last edited by
                              #16

                              @Toocold Then please mark this topic as solved, thx.

                              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                              Visit the Qt Academy at https://academy.qt.io/catalog

                              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