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



  • 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 :)



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



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



  • Yeah probably a stale file in your build.


  • Moderators

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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.