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.
  • T Toocold
    22 Nov 2019, 08:20
    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 Offline
    J Offline
    J.Hilk
    Moderators
    wrote on 22 Nov 2019, 08:50 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 22 Nov 2019, 08:55
    0
    • J J.Hilk
      22 Nov 2019, 08:50

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

      T Offline
      T Offline
      Toocold
      wrote on 22 Nov 2019, 08:55 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.

      J 1 Reply Last reply 22 Nov 2019, 08:57
      0
      • T Toocold
        22 Nov 2019, 08:55

        @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.

        J Offline
        J Offline
        jsulm
        Lifetime Qt Champion
        wrote on 22 Nov 2019, 08:57 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 22 Nov 2019, 09:27
        0
        • J jsulm
          22 Nov 2019, 08:57

          @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 22 Nov 2019, 09:27 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.

          J 1 Reply Last reply 22 Nov 2019, 09:47
          0
          • T Toocold
            22 Nov 2019, 09:27

            @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.

            J Offline
            J Offline
            jsulm
            Lifetime Qt Champion
            wrote on 22 Nov 2019, 09:47 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 22 Nov 2019, 10:09
            1
            • J jsulm
              22 Nov 2019, 09:47

              @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 22 Nov 2019, 10:09 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.

              J J 2 Replies Last reply 22 Nov 2019, 10:14
              0
              • T Toocold
                22 Nov 2019, 10:09

                @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.

                J Offline
                J Offline
                jsulm
                Lifetime Qt Champion
                wrote on 22 Nov 2019, 10:14 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 23 Nov 2019, 02:01
                3
                • T Toocold
                  22 Nov 2019, 10:09

                  @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.

                  J Offline
                  J Offline
                  JonB
                  wrote on 22 Nov 2019, 10:18 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
                  • J jsulm
                    22 Nov 2019, 10:14

                    @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 23 Nov 2019, 02:01 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 23 Nov 2019, 03:09
                    0
                    • T Toocold
                      23 Nov 2019, 02:01

                      @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 23 Nov 2019, 03:09 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
                      • C Offline
                        C Offline
                        Christian Ehrlicher
                        Lifetime Qt Champion
                        wrote on 23 Nov 2019, 06:03 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 23 Nov 2019, 06:27
                        2
                        • C Christian Ehrlicher
                          23 Nov 2019, 06:03

                          @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 23 Nov 2019, 06:27 last edited by
                          #15

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

                          C 1 Reply Last reply 23 Nov 2019, 08:08
                          0
                          • T Toocold
                            23 Nov 2019, 06:27

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

                            C Offline
                            C Offline
                            Christian Ehrlicher
                            Lifetime Qt Champion
                            wrote on 23 Nov 2019, 08:08 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

                            13/16

                            23 Nov 2019, 03:09

                            • Login

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