Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. [SOLVED] QVector3D normalization not working in Qt Creator debug mode?
QtWS25 Last Chance

[SOLVED] QVector3D normalization not working in Qt Creator debug mode?

Scheduled Pinned Locked Moved C++ Gurus
5 Posts 3 Posters 3.2k 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.
  • D Offline
    D Offline
    DocSavage
    wrote on last edited by
    #1

    I'm trying to debug a C++ program in Qt Creator and I've encountered a bug that seems very odd. I initialize a QVector3D, call it foo, and after I run foo.normalize(), inspecting the variables show it's not normalized.

    Specifically, in the watch window:

    normal.x() 1.8946852...
    normal.y() 0.7071067...
    normal.z() 0.7071067...
    normal.length() 0.9999999...

    This is after a normal.normalize(). How can the length be about 1.0 when the x component is close to 2? It happens with other QVector3D names as well. Could this be memory corruption or am I missing something obvious and should just go to bed :)

    1 Reply Last reply
    0
    • Z Offline
      Z Offline
      ZapB
      wrote on last edited by
      #2

      Can you make a small compilable example that demonstrates this please? I suspect you are overwriting some memory somewhere in your application.

      Nokia Certified Qt Specialist
      Interested in hearing about Qt related work

      1 Reply Last reply
      0
      • D Offline
        D Offline
        DocSavage
        wrote on last edited by
        #3

        After shutting down Qt Creator, making sure my build directory was fully cleaned, and recompiling everything, it looks like the error went away. I've got Q_ASSERTs scattered through the code and nothing has hit again, so it must have been just an odd state.

        1 Reply Last reply
        0
        • Z Offline
          Z Offline
          ZapB
          wrote on last edited by
          #4

          Yeah probably a stale file in your build.

          Nokia Certified Qt Specialist
          Interested in hearing about Qt related work

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mlong
            wrote on last edited by
            #5

            Please be sure and add a [Solved] to the title of your post if it's all taken care of! Thanks!

            Software Engineer
            My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

            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