Silicomancer
Silicomancer

Reputation: 9156

Code changes do not take effect

I just started using Qt Creator 3.5.0, Qt 5.4.2 with GCC on Kubuntu 15.10. I created a new project, added a window and currently I am trying to develop a new module.

However strange things happen.

I wrote a debug output line in my template class X. The line is located in a function of class X in the header of its module, e.g.:

qDebug() << "Hello1" << endl;

After building and running the application this line is executed and "Hello1" is printed in the debug console as desired. Also I can use the debugger and step through the line. When building the application the compiler does essentially nothing since no code file was changed (as expected).

When editing the above line things go weired:

More facts:

I have no idea how this is possible. Maybe I missed something obvious. Any ideas?

UPDATE: Using system monitor I could confirm that the running process uses the expected executeable.

Upvotes: 3

Views: 10983

Answers (5)

fyngyrz
fyngyrz

Reputation: 2648

Problem still exists under Qt 5.8:

This problem continues to arise with Qt 5.8 using clang, building 64-bit for OSX, under OSX, from within Qt Creator. So it's not a GCC issue.

Solution:

I was able to get dependent compiles to respond correctly to changes to a newly added header file by:

  • Cleaning the project
  • Running QMake
  • Rebuilding the entire project.

Checks:

Before doing the above, I checked the project file and made sure that the new file was listed in the HEADERS section (it was.) Despite this, Qt would not rebuild the file that included the .h file.

Upvotes: 1

JRG
JRG

Reputation: 11

Modify your main.cpp and recompile this should update your code. Not sure why this is happening but I add a cout << "Ver: 1 \n"; and update the number every time I change the header file. This seems to be a workaround.

Upvotes: 1

Matt
Matt

Reputation: 57

I've experienced this issue as well. I was able to resolve it by cleaning (in my case running catkin clean) and then re-building it (catkin_make).

Unfortunately I haven't been able to figure out the exact cause of the problem, but hopefully someone more knowledgeable has an idea.

In addition, my development environment is different (Ubuntu 14.04, Qmake 3.1, Qt 5.9.1, gcc 4.8.4, catkin tools 0.4.4, Qt Creator etc) so obviously my fix may not work for everyone.

Upvotes: 0

Megasa3
Megasa3

Reputation: 764

You can try some things:

  1. Check if the exe your are opening its on the same path as the created one (you can verify it looking into .pro.user file.
  2. Check if when you compile, it does save the changes first and then compile it together otherwise it may seem it does it but don't.
  3. If you have changed your .pro file run qmake and build it again.
  4. Try cleaning, runing qmake and re-building the project.
  5. If you changed your .pro file or you are including external libs or files, check the output log to see if everything is ok, sometimes it is not but stills compiles (and then doesn't link well or just let you the old compiled version).

It seems to be compiling the last 'version' of your code and not applying the changes for some of that reasons and others (If I think in other things I'll edit the post later).

Hope it helps

Upvotes: 2

JDługosz
JDługosz

Reputation: 5642

Check which exe the debugger is actually running. It may be another copy! Look at a process listing to know for sure what EXE is under the debugger.

This general issue has happened for various reasons in my personal experience. Files get copied to an install/staging area; the environment shadows things; the wrong project is set to "start up"; the way the component is run when starting the debug session ends up resolving to the wrong file; the wrong configuration or flavor is being changed; etc.

Rule 1: verify your assumptions. You checked file dates etc. but add to that checking what file (full path) is actually under the debugger.

Upvotes: 1

Related Questions