I will repeat my unanswered questions then:
- How do you run this method?
- So you got rid of all the threads?
I will repeat my unanswered questions then:
- How do you run this method?
- So you got rid of all the threads?
Gotha, somehow I must have missed those original questions.
- In this code yes everything is running on the main GUI thread (for solving this problem). The code which collects up the UDP packets into a frame runs on a separate thread and sends a signal that the frame is complete with an index of the frame inside the buffer pool.
- When the slot is received (on the main GUI thread, I verified this with the debugger, and there are no messages that the QPixmap can't be used on the non gui thread) it calls a method to get the address of the buffer and the length (yes they are protected by a mutex), it then calls the routine which i provided a snippet from. When this routine finishes the caller release the buffer so the secondary thread can reuse it.
I just tried something else today. After I load the QImage from the buffer I call QImge.isNull() which returns false. After I convert the QImage to the QPixmap I call QPixmap.isNull() and it returns true. So something is going wrong with that conversion, even through QPixmap.fromImage() is returning true.
I figured out what the problem was. Somehow I didn't see that fromImage was a static member so my code was bogus
my_pixmap.fromImage(image); should have been my_pixmap = QPixmap::fromImage(image);
I wonder why do you use QImage as a temporary data container?
Wouldn't it be easier and faster to use QByteArray to store the data and load it directly to QPixmap?
Because my original goal was to do the JPEG decoding on a secondary thread. QPixmap cannot run on a secondary thread but QImage can. Therefore I load (which does the decode) QImage on the secondary thread, then let QPixmap render the image on the GUI thread.
Bookmarks