Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved Debug Mode Thread Issue

    General and Desktop
    3
    9
    1589
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T
      TopNotch_Mach07 last edited by

      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 finished

      This 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.!

      1 Reply Last reply Reply Quote 0
      • mrjj
        mrjj Lifetime Qt Champion last edited by

        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-thread

        But should also happen in release.
        Maybe it just dont warnings error in release?

        1 Reply Last reply Reply Quote 1
        • T
          TopNotch_Mach07 last edited by

          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.

          mrjj kshegunov 2 Replies Last reply Reply Quote 0
          • mrjj
            mrjj Lifetime Qt Champion @TopNotch_Mach07 last edited by

            @TopNotch_Mach07

            Ok, i mostly seen this warning with c++ and using QThread.

            Do you have your own threads or anything that could cause this?

            T 1 Reply Last reply Reply Quote 0
            • kshegunov
              kshegunov Moderators @TopNotch_Mach07 last edited by

              @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.

              Read and abide by the Qt Code of Conduct

              1 Reply Last reply Reply Quote 0
              • T
                TopNotch_Mach07 @mrjj last edited by

                @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.

                1 Reply Last reply Reply Quote 0
                • T
                  TopNotch_Mach07 last edited by TopNotch_Mach07

                  @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));

                  kshegunov 1 Reply Last reply Reply Quote 0
                  • kshegunov
                    kshegunov Moderators @TopNotch_Mach07 last edited by kshegunov

                    @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 call setupMainWindow from a thread different than the one that created QGuiApplication (and QQmlEngine). How and why though, you should trace through your code.

                    Read and abide by the Qt Code of Conduct

                    1 Reply Last reply Reply Quote 0
                    • T
                      TopNotch_Mach07 last edited by

                      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.

                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post