Subnavigation

Qt Commercial Support Weekly #23 - Explaining the warnings/errors

After an unfortunately long hiatus mainly due to the vacation period we are finally back and hopefully back on track with having weekly updates. So without further delay then here is this week's support weekly.

 

As most of us, if not all of us, would have encountered by now when running Qt applications, warning or error messages in the debug output, some are straightforward to understand and some are a bit more cryptic. So this week I will go over some of the warning messages that may come up that aren't necessarily the easiest to make sense of and go into some detail as to what causes the warning and how to fix it.

 

Initializing QFontEngineQPF failed for /app/lib/fonts/fontname.ttf


This is an indication that the application cannot handle ttf fonts, you may see this message more than once as it will occur for all the ttf fonts that it finds. In order to fix this then the system needs to have FreeType made available so that Qt can be configured with it (it will auto-detect it so as long as it is installed and in place it should pick it up). Alternatively, you can configure with -qt-freetype and it will use the version of FreeType that is bundled with the Qt package.

 

QPainter::begin: Paint device returned engine == 0, type: 2


When you get a message from QPainter saying that the engine returned 0, this means that for some reason it is unable to paint on the paint device in question. Pretty much all the times you see this it would be in relation to a QPixmap or a QImage. In the case of QPixmap/QImage it means that it is null, meaning that it has no size set which is why it cannot paint to it. This is either because no size was specified for it or because the size requested was too big that it would have caused an overflow which meant that it ended up not having that size set. If you call isNull() then most of the time it will return true, but sometimes it is possible that QPixmap will not return true but will still have a problem if the size of the pixmap was too large. Reducing the size will make it work.

 

QObject: Cannot create children for a parent that is in a different thread. (Parent is ..., parent's thread is ..., current thread is ...)


This one is a bit more understandable at least, but sometimes it is still not clear as to why it occurs. The key problem is that when you want to use objects inside another thread then they have to be created inside the run() function of the thread in question. For example in this case, the warning would be triggered if the object was created in the main() function (thus making it owned by the main thread) and then when used in the other thread it created a child object. Another way that this could be triggered is that the object is created inside the run() function but has been given a parent object which means that the parent and the child belong to different threads. The way to solve this is to either create the objects inside the run() function or to ensure moveToThread() is called on the object before using it inside the run() function.

 

locking qpf: Permission denied


This is a problem that can come up with Qt for Embedded Linux applications when they are deployed, basically it is not able to lock a font file for usage. The reason this happens is because NFS is not enabled for the device, if NFS is enabled for the device then it should solve this problem.

 

If anyone has any other warnings that are not clear then please feel free to let me know in the comments, if there are enough then I can do a follow up post explaining some more. Alternatively you can always contact Qt Commercial Support at http://qt.digia.com/customerportal and ask us directly if you encounter one that you don't know what to do about.

 

Finally, I would like to thank everyone who gave feedback about support in the recent customer survey, I will be going through all the results carefully and we will be taking all the feedback on board and will use this to improve on our service to you. And if you ever want to give us further feedback you can either do so by sending it via the customer portal (where I will see it) or if you prefer you can send it via your account manager in Qt Commercial Sales who will pass it on to me.

 

Until next time, happy coding!


Comments