Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Debug Mode Thread Issue
Forum Updated to NodeBB v4.3 + New Features

Debug Mode Thread Issue

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 3 Posters 2.1k Views 2 Watching
  • 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 Offline
    T Offline
    TopNotch_Mach07
    wrote on 21 Dec 2016, 07:39 last edited by
    #1

    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
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 21 Dec 2016, 07:45 last edited by
      #2

      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
      1
      • T Offline
        T Offline
        TopNotch_Mach07
        wrote on 21 Dec 2016, 07:54 last edited by
        #3

        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.

        M K 2 Replies Last reply 21 Dec 2016, 08:01
        0
        • T TopNotch_Mach07
          21 Dec 2016, 07:54

          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.

          M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 21 Dec 2016, 08:01 last edited by
          #4

          @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 22 Dec 2016, 05:33
          0
          • T TopNotch_Mach07
            21 Dec 2016, 07:54

            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.

            K Offline
            K Offline
            kshegunov
            Moderators
            wrote on 21 Dec 2016, 11:17 last edited by
            #5

            @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
            0
            • M mrjj
              21 Dec 2016, 08:01

              @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 Offline
              T Offline
              TopNotch_Mach07
              wrote on 22 Dec 2016, 05:33 last edited by
              #6

              @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
              0
              • T Offline
                T Offline
                TopNotch_Mach07
                wrote on 22 Dec 2016, 05:48 last edited by TopNotch_Mach07
                #7

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

                K 1 Reply Last reply 22 Dec 2016, 08:17
                0
                • T TopNotch_Mach07
                  22 Dec 2016, 05:48

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

                  K Offline
                  K Offline
                  kshegunov
                  Moderators
                  wrote on 22 Dec 2016, 08:17 last edited by kshegunov
                  #8

                  @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
                  0
                  • T Offline
                    T Offline
                    TopNotch_Mach07
                    wrote on 23 Dec 2016, 06:19 last edited by
                    #9

                    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
                    0

                    1/9

                    21 Dec 2016, 07:39

                    • Login

                    • Login or register to search.
                    1 out of 9
                    • First post
                      1/9
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved