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

Wrong behavior for QVariantAnimation with unsigned datatype and decreasing interpolation

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 5.11.2
    • 5.7, 5.10.0
    • None
    • Doesn't matter, plattform independent code
    • 02b3d43fd4661271e6e8dc8940d84cb2ba352fe0

    Description

      When using a QVariantAnimation with an unsigned value and it has to interpolate from a bigger to a smaller value, it will fail to do so.

      The reason is _q_interpolate in qvariantanimation_p.h.

      template<typename T> inline T _q_interpolate(const T &f, const T &t, qreal progress)
      {
          return T(f + (t - f) * progress);
      }
      

      For example for unsigned, this method will be called with T=unsigned.
      f ist the interpolation start and t the interpolation end. Progress is the normalized current time.

      So for example for f = 100,t = 0 and progress = 0.5 the formular is:

          100 + (0 - 100) * 0.5;
      

      Thats a perfect 50 with normal math. But because f and t are unsigned, so unsigned math applies. In unsigned math (0 - 100) is not -100, but (for 32 bit unsigned) 4294967196 (uint_max - 100 + 1).

      Attachments

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

        Activity

          People

            VRonin Luca
            jvehlow jvehlow
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes