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. Doc > Qt 4.8 > Mandelbrot Example
QtWS25 Last Chance

Doc > Qt 4.8 > Mandelbrot Example

Scheduled Pinned Locked Moved Unsolved General and Desktop
docsdocumentationthreadsyncronization
10 Posts 2 Posters 3.3k Views
  • 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.
  • D Offline
    D Offline
    dm_kiselev
    wrote on 13 Mar 2016, 15:00 last edited by
    #1

    In this example Mandelbrot Example | Qt 4.8, in function RenderThread::run() why we don't protect the image member by a mutex? We write image here and read it in other thread, in function MandelbrotWidget::updatePixmap(const QImage &image, double scaleFactor). So why its not conflict?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 13 Mar 2016, 22:49 last edited by
      #2

      Hi and welcome to devnet,

      Because each time you pass in the loop a new image is created so you are not accessing a shared resource.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      D 2 Replies Last reply 14 Mar 2016, 15:33
      0
      • S SGaist
        13 Mar 2016, 22:49

        Hi and welcome to devnet,

        Because each time you pass in the loop a new image is created so you are not accessing a shared resource.

        D Offline
        D Offline
        dm_kiselev
        wrote on 14 Mar 2016, 15:33 last edited by
        #3

        @SGaist you mean forever loop or while (pass < NumPasses) loop?

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 14 Mar 2016, 20:41 last edited by
          #4

          The forever loop contains the while (pass < NumPasses)

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • S SGaist
            13 Mar 2016, 22:49

            Hi and welcome to devnet,

            Because each time you pass in the loop a new image is created so you are not accessing a shared resource.

            D Offline
            D Offline
            dm_kiselev
            wrote on 15 Mar 2016, 13:43 last edited by
            #5

            @SGaist said:

            each time you pass in the loop a new image is created

            What loop you mean here?

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 15 Mar 2016, 16:52 last edited by
              #6

              The forever loop

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • D Offline
                D Offline
                dm_kiselev
                wrote on 15 Mar 2016, 16:59 last edited by
                #7

                Ok, but after emitting the signal we go to the next iteration of the while (pass < NumPasses) and write to the same image. And we read it in another thread at the same time.

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 15 Mar 2016, 22:00 last edited by
                  #8

                  From the documentation of the example: "With queued connections, Qt must store a copy of the arguments that were passed to the signal so that it can pass them to the slot later on."

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • D Offline
                    D Offline
                    dm_kiselev
                    wrote on 16 Mar 2016, 12:41 last edited by
                    #9

                    Thank you!

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on 16 Mar 2016, 22:08 last edited by
                      #10

                      You're welcome !

                      Since it's all clear now, please mark the thread as solved using the "Topic Tool" button so that other forum users may know an answer has been found :)

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      0

                      10/10

                      16 Mar 2016, 22:08

                      • Login

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