0

A Qt project gives a number of errors - that I do not actually consider errors I think:

Some examples:

Fontconfig error: "/etc/fonts/conf.d/65-khmer.conf", line 32: out of memory
  // ? 
QGraphicsItem::ungrabMouse: not a mouse grabber 
  // i think happens when the mouse grab didn't quite happen, user moved too fast...

A few others

the first one seems it has an answer here https://askubuntu.com/questions/421891/fontconfig-error-out-of-memory

So I cannot fix it through software, the user must fix it... since it is system dependent...

Even built in release, these errors will still show up on command line... Since they do not cause the application to behave abnormally, I don't think the user should see them.

How can I build/deploy the application without these errors showing ?

ideally of course there would be no errors in a deployed application, but I don't know what I can do about those types of errors...

Community
  • 1
  • 1
Thalia
  • 13,637
  • 22
  • 96
  • 190
  • Assuming the errors are printed to `stderr`: `freopen( "/dev/null", "w", stderr );` should do the trick. Obviously you need some other way to get a null device on Windows though. Are more portable way might be the code in http://stackoverflow.com/questions/4954140/how-to-redirect-qdebug-qwarning-qcritical-etc-output but I don't know if the fonconfig error is printed using with the Qt message infrastructure. – pmr Sep 22 '14 at 21:41
  • Since it is a GUI application, it is unlikely that the Windows users will ever see these errors... But I don't understand where to place that "freopen( "/dev/null", "w", stderr );" command ? – Thalia Sep 22 '14 at 21:48
  • I did not see where these errors are printed, they are not qDebug outputs – Thalia Sep 22 '14 at 21:56
  • For Windows: Yes, but you might get more errors when you try to redirect a stream to a non-existing file. Where to place it: in your `main`, before anything else happens. – pmr Sep 22 '14 at 22:02
  • can you please post as answer so I can accept, and thank you – Thalia Sep 22 '14 at 22:16

1 Answers1

1

It is possible to redirect a stream (in this case stderr) after the fact using

freopen("/dev/null", "w", stderr);

Just place this in your main before any other code runs and you should be good. Keep in mind that this might need more work on Windows.

If the error message is posted through the Qt Message infrastructure (qDebug etc.) you can set a new message handler through the function qInstallMsgHandler.

pmr
  • 58,701
  • 10
  • 113
  • 156
  • @Thalia Don't forget to also a `#if !defined(NDEBUG)` so that you still get output in debug builds. – pmr Sep 22 '14 at 22:23
  • oh I added the definition in pro file - unix:CONFIG(release):DEFINES += NO_RELEASE_ERRORS... though maybe using the NODEBUG may be better ? – Thalia Sep 22 '14 at 22:37
  • @Thalia `NDEBUG` is the kind of standard define to indicate debug mode and is also honored by `` a.k.a. `std::assert`. – pmr Sep 23 '14 at 13:28
  • Tried... #if !defined(Q_OS_WIN32) && !defined(NDEBUG) but this seems to be true in either DEBUG or RELEASE, maybe not all compilers define the same symbols ? – Thalia Sep 23 '14 at 20:49
  • @Thalia This very much depends on your build system and the comments are not the right place to figure it out. – pmr Sep 23 '14 at 21:53