Code changes don't take effect?



  • I had the strangest issue last night. To make it simple I'll break it down.

    I have two classes. Class A and class B. Class B has a signal that has a hard coded string as a parameter. Class A connects this signal to a slot. Lets say that this signal is emitted when a button is pushed in class A (MainWindow). In Class A's slot there's a qDebug() that prints the string parameter.

    Class B::emit sig("This is a test");
    Class A prints this to the debug console. So far so good.

    Class B::emit sig("This is the second test");
    Class A prints "This is a test" to the console.

    Ok. just need to rebuild the project.
    Rebuild, execute: same thing.
    Class B emits "This is the second test"
    Class A prints "This is a test"

    Now I delete the class B compiled files (.o and moc file)
    This forces a recompile of class B.
    Rebuild, execute: same thing.
    Class B emits "This is the second test"
    Class A prints "This is a test"

    Step through it with the debugger
    I set a breakpoint on the emit line and the slot in class A.
    The emit line is correct "emit sig("This is the second test");
    The slot parameter, however, equals "This is a test"

    So I shutdown Qt Creator, restart it, load the project, build, execute
    Same damn thing.

    It finally runs correctly after I restart the computer.

    Has anyone encountered this before?


  • Lifetime Qt Champion

    Hi
    I have tried some thing like that by having a moc_xxx file in the project folder
    so it would link that and not the new fresh on in build folder.

    However, that would not be resolved by rebooting so not sure its same issue.

    But check the project folder for any build artifacts. ( moc_xx, qmake.cache etc)



  • I looked for any leftover build files. There was nothing. It's crazy that it printed the wrong text even stepping though it in the debugger.


  • Lifetime Qt Champion

    @PsylumDan
    Yes it really sounded like it ran other code that it was displaying.


Log in to reply