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. 3d and threads
Forum Updated to NodeBB v4.3 + New Features

3d and threads

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 2 Posters 1.9k Views 1 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.
  • L Offline
    L Offline
    Louai
    wrote on last edited by
    #1

    I'm switching over from OpenSceneGraph to Qt3d, but as soon as I started setting up I ran into the following issue:

    Qt3DCore::QEntity* lightEntity = new Qt3DCore::QEntity(m_rootEntity);
    Qt3DRender::QPointLight* light = new Qt3DRender::QPointLight(m_rootEntity);
    lightEntity->addComponent(light);
    

    Yields an error stating that I cannot assign a parent from a different thread. I'm familiar with this issue when working with different threads explicitly, but in this case Qt3DCore and Qt3DRender run in different threads by design I assume.

    Anyone encounter a similar issue? and if so any advice?
    (I am using Qt 5.7 under Visual Studio 2015, with multithreaded dll)

    Thanks

    kshegunovK 1 Reply Last reply
    0
    • L Louai

      I'm switching over from OpenSceneGraph to Qt3d, but as soon as I started setting up I ran into the following issue:

      Qt3DCore::QEntity* lightEntity = new Qt3DCore::QEntity(m_rootEntity);
      Qt3DRender::QPointLight* light = new Qt3DRender::QPointLight(m_rootEntity);
      lightEntity->addComponent(light);
      

      Yields an error stating that I cannot assign a parent from a different thread. I'm familiar with this issue when working with different threads explicitly, but in this case Qt3DCore and Qt3DRender run in different threads by design I assume.

      Anyone encounter a similar issue? and if so any advice?
      (I am using Qt 5.7 under Visual Studio 2015, with multithreaded dll)

      Thanks

      kshegunovK Offline
      kshegunovK Offline
      kshegunov
      Moderators
      wrote on last edited by
      #2

      @Louai said in 3d and threads:

      Yields an error stating that I cannot assign a parent from a different thread.

      Are you sure that's this piece of code that's causing it?

      I'm familiar with this issue when working with different threads explicitly, but in this case Qt3DCore and Qt3DRender run in different threads by design I assume.

      Under the hood, but not for the interface (i.e. public) objects.

      Read and abide by the Qt Code of Conduct

      1 Reply Last reply
      0
      • L Offline
        L Offline
        Louai
        wrote on last edited by
        #3

        Re: 3d and threads

        Stepping through the program shows that the errors come from here. There is also the error message that explicitly names the threads.
        I'm not sure what happens under the hood, but again stepping through I can easily see the 2 extra threads, which have been instantiated at some point.
        I loaded a bare bone example with similar code and it doesn't do that. Perhaps it's because I have this encapsulated in a class, though I don't see how.

        Thanks

        kshegunovK 1 Reply Last reply
        0
        • L Louai

          Re: 3d and threads

          Stepping through the program shows that the errors come from here. There is also the error message that explicitly names the threads.
          I'm not sure what happens under the hood, but again stepping through I can easily see the 2 extra threads, which have been instantiated at some point.
          I loaded a bare bone example with similar code and it doesn't do that. Perhaps it's because I have this encapsulated in a class, though I don't see how.

          Thanks

          kshegunovK Offline
          kshegunovK Offline
          kshegunov
          Moderators
          wrote on last edited by
          #4

          @Louai said in 3d and threads:

          Perhaps it's because I have this encapsulated in a class, though I don't see how.

          No it shouldn't be that. What about the root entity, any funny thing you might be doing with it? Perhaps moving it into a thread by means of QObject::moveToThread?

          Read and abide by the Qt Code of Conduct

          1 Reply Last reply
          0
          • L Offline
            L Offline
            Louai
            wrote on last edited by
            #5

            Tried that but failed later on (corruption, so must be doing something really wrong).
            I loaded a similar example (the basic-shape-cpp included in the distrib) project and put in a breakpoint, and I see both threads in addition to the main GUI. No warning though.
            I tried removing the light to just see what it can draw and I run into a heap corruption. Must be something else. I'll update if I find something.

            Thanks

            kshegunovK 1 Reply Last reply
            0
            • L Louai

              Tried that but failed later on (corruption, so must be doing something really wrong).
              I loaded a similar example (the basic-shape-cpp included in the distrib) project and put in a breakpoint, and I see both threads in addition to the main GUI. No warning though.
              I tried removing the light to just see what it can draw and I run into a heap corruption. Must be something else. I'll update if I find something.

              Thanks

              kshegunovK Offline
              kshegunovK Offline
              kshegunov
              Moderators
              wrote on last edited by
              #6

              That's really odd. Could you paste your example code that reproduces this?

              Read and abide by the Qt Code of Conduct

              1 Reply Last reply
              0
              • L Offline
                L Offline
                Louai
                wrote on last edited by
                #7

                It's the exact code in the example of the distrib.
                So I got everything to work after comparing the project options with the one from the converted .pro. One of these options must have caused it, I'll try to isolate it and post it here.
                Thanks

                kshegunovK 1 Reply Last reply
                0
                • L Louai

                  It's the exact code in the example of the distrib.
                  So I got everything to work after comparing the project options with the one from the converted .pro. One of these options must have caused it, I'll try to isolate it and post it here.
                  Thanks

                  kshegunovK Offline
                  kshegunovK Offline
                  kshegunov
                  Moderators
                  wrote on last edited by
                  #8

                  Yes, thanks for that. It may help someone else tracking a similar problem.

                  Read and abide by the Qt Code of Conduct

                  1 Reply Last reply
                  0
                  • L Offline
                    L Offline
                    Louai
                    wrote on last edited by
                    #9

                    Update:

                    I couldn't isolate exactly what was causing it because it's taking a very long time to try out different combinations, but I know it was either one of the QT preprocessor directives (perhaps the QT_OPENGL being placed before something else) or the order of the link libraries (I was missing one of the 3d ones too, but didn't get any linking error).
                    I currently have the libraries & directives given as most specialized to least and it seems to solve the issue.

                    Thanks for the help

                    1 Reply Last reply
                    0

                    • Login

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