We have moved to a new Sailfish OS Forum. Please start new discussions there.
4

QT_NO_DEBUG_OUTPUT not effective until clean build

asked 2020-03-22 22:39:35 +0300

Direc gravatar image

Hi,

I have scratching my head - again - over QT_NO_DEBUG_OUTPUT, and finally I managed to pin it down. Here are the steps to reproduce the problem with Sailfish Application SDK 3.0.7:

  • Create new project
  • Add #include <QDebug> in main.cpp
  • Add qDebug() << "Debug messages enabled"; to main() function
  • Set the app run in release mode in Sailfish emulator and click the "play" button to run it
  • Note that the line is printed, as expected, and close the application
  • Add line DEFINES += QT_NO_DEBUG_OUTPUT to the project file
  • Save the file, Qt Creator disables and enables the "play" button as the changed project file is processed
  • Click the "play" to run the application again
  • Note that the line is still printed, despite the DEFINE, and close the application
  • Select Build > Clean project "name" from the menu
  • Click the "play" to run the application again
  • Note that the line is no longer printed, as expected

Other way to test this is to wrap qInfo() inside #ifdef QT_NO_DEBUG_OUTPUT block, and it too requires cleaning the project before the project files becomes effective.

Now, if instead of QT_NO_DEBUG_OUTPUT I use a custom string, say NO_BLAH instead, no clean build is required in order for the #ifdef block to be effective.

So, it looks to me that QT_NO_DEBUG_OUTPUT is handled differently and something fishy is going on in that front. I think this qualifies as a bug.

Thanks!

PS. Clean build doesn't solve this question, hence this new question.

edit retag flag offensive close delete

1 Answer

Sort by » oldest newest most voted
3

answered 2020-05-11 11:06:06 +0300

martyone gravatar image

The behavior is expected and 100% correct. qmake does not track use of preprocessor macros inside source files. This is not limited to preprocessor macros. Whenever you change anything in the project files, it is up to you to determine if anything needs to be rebuilt. Similarly, there are cases when you need to re-run qmake manually after changing source files, so that it notices changes in dependencies. E.g. when you newly use Q_OBJECT macro in a header file where it was not used before.

edit flag offensive delete publish link more

Comments

Thanks for the explanation! Now that I understand the situation, it's trivial to deal with it.

Direc ( 2020-05-23 21:15:26 +0300 )edit
Login/Signup to Answer

Question tools

Follow
3 followers

Stats

Asked: 2020-03-22 22:39:35 +0300

Seen: 693 times

Last updated: May 11 '20