Solved Debug Mode Thread Issue
-
Hi,
When I run my project in Debug Mode I am getting this following Error.
Warning (default): :0 (in ): QObject: Cannot create children for a parent that is in a different thread.
(Parent is QmlUiLoggerPlugin(0x7fffe005aab0), parent's thread is QThread(0x686660), current thread is QThread(0x630c40)
Debugging has finishedThis error only happens when i run in Debug Mode . In Release mode the project runs fine.
I am using Qt 5.7 and CMake.
Any help would be appreciated.
Thanks.!
-
Hi
Its a warning only.Is this a QML project?
It sounds like the classic
http://stackoverflow.com/questions/3268073/qobject-cannot-create-children-for-a-parent-that-is-in-a-different-threadBut should also happen in release.
Maybe it just dont warnings error in release? -
Thanks for the quick response.
Yes its a qml project .Theoretically this should also happen in release, BUT ITS NOT. Even though its a warning, the debugger exits automatically.
-
Ok, i mostly seen this warning with c++ and using QThread.
Do you have your own threads or anything that could cause this?
-
@TopNotch_Mach07
Release might (most probably) suppress those kind of warnings. Do you know which object generates the warning? From the looks of it you're trying to add an object that lives in a (worker) thread to QML, which runs in the GUI thread. -
@mrjj , A small correction , Its a both C++ and QML Project. C++ acts as a backed. And Yes the error is caused by a C++ Class.
-
@kshegunov If its issue of the thread. It should happen in the release build also right ? doesn’t it ?
And error throws up at line which is bold and italicised
static QQuickWindow *setupMainWindow(QQmlEngine *engine, const QString &mainFile)
{
Profiler::instance()->tagItStart(Profiler::TAG_CAT_FW, Profiler::TAG_FUNC_FW_CREATINGMAINWINDOW);
QQmlComponent rootComponent(engine, QUrl(mainFile)); -
@TopNotch_Mach07 said in Debug Mode Thread Issue:
If its issue of the thread. It should happen in the release build also right ? doesn’t it ?
It probably does, Qt might not issue the warning though, as it is release, i.e. production code.
Well, apparently you callsetupMainWindow
from a thread different than the one that createdQGuiApplication
(andQQmlEngine
). How and why though, you should trace through your code. -
Finally I am able to some how solve the issue without completely understanding it.
There were 5 threads running in the Qt , I had put a break point on the code just one line before where it generates the Warning . After that I switched to different thread other than the default one and then I hit continue button in the debugger. Voila ! ! it worked.
Thanks for all the help and suggestions.