PDA

View Full Version : QObject::moveToThread() warnings



gri
2nd April 2007, 09:20
Hello,

I'm simply using the Designer to create a window. When I call setupUi(this) there are a few warning messages appearing.


QObject::moveToThread: Current thread (0204C070) is not the object's thread (003FEF78).
Cannot move to target thread (003FEF78)

They come when Qt loads it's image plugins but at this point only the main thread exists ... so how to prevent these warnings? Am I doing something wrong?

Thanks

high_flyer
2nd April 2007, 09:32
Are you using threads in your application?

marcel
2nd April 2007, 09:40
Most likely you are creating the object in a different thread than the GUI thread.

Is this necessary? You should instead emit a signal from the thread to the interface to create your object when it is needed.

Marcel

gri
2nd April 2007, 09:54
As I told at this point only one thread exists. And yes, I'm using threads but not at this point of initialization.

I think the problem is more that my program is statically linked and tries to load the "imageformat/qjpegd.dll". So maybe the warning reason is because of something done in the qjpegd.dll? The object which tries to be moved is the QObject returned by the QPluginLoader::instance()-call.

high_flyer
2nd April 2007, 10:44
As I told at this point only one thread exists. And yes, I'm using threads but not at this point of initialization.
Well, with threads its often the case, that we THINK we are doing X, but after carfully inspecting the code, we discover that we are actually doing Y.
So I think it would be best if you would post relevant code segments (where the ui is initialized, and your thread initializtion).

I think the problem is more that my program is statically linked and tries to load the "imageformat/qjpegd.dll". So maybe the warning reason is because of something done in the qjpegd.dll? The object which tries to be moved is the QObject returned by the QPluginLoader::instance()-call.
Possible, but not likely, since then it would always be the case, for other users as well.
It is easy to test though - make a dummy project, no threads, make a simple ui with the widget you are using and see if this still happens.

But as I said, code segment would help much more.

jacek
2nd April 2007, 10:45
Do you have any static objects derived from QObject in your application?

gri
2nd April 2007, 12:48
Well, with threads its often the case, that we THINK we are doing X, but after carfully inspecting the code, we discover that we are actually doing Y.
So I think it would be best if you would post relevant code segments (where the ui is initialized, and your thread initializtion).

Possible, but not likely, since then it would always be the case, for other users as well.
It is easy to test though - make a dummy project, no threads, make a simple ui with the widget you are using and see if this still happens.

But as I said, code segment would help much more.
There is no need for code because this is in Qt source. The first use of QIcon/QPixmap loads the "qjpegd.dll" which results in these warnings. If I remove the DLL, no warnings appear. As jpeg is the only format which can not be statically compiled I don't use it, so I don't care about these warnings. I just wanted to know why they happen :)


Do you have any static objects derived from QObject in your application?
No, there are no static objects. Except of the png lib and static Qt plugins.

wysota
2nd April 2007, 13:55
Did I understand correctly that you said JPEG couldn't be used as a static plugin? Could you elaborate on that? Maybe a link to the docs? I haven't seen it mentioned anywhere...

gri
2nd April 2007, 15:25
Did I understand correctly that you said JPEG couldn't be used as a static plugin? Could you elaborate on that? Maybe a link to the docs? I haven't seen it mentioned anywhere...
When you run the configure with "-static" all image plugins are "qt" except of jpeg which stays as "plugin"

Third Party Libraries:
ZLIB support............qt
GIF support.............no
JPEG support............plugin
PNG support.............qt
MNG support.............qt

wysota
2nd April 2007, 16:46
Yes, but this will be a static plugin which you can then add to your application. It just means jpeg plugin can't be compiled directly into Qt libraries. See the Q_IMPORT_PLUGIN macro.