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.
  • dm_kiselevD Offline
    dm_kiselevD Offline
    dm_kiselev
    wrote on 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
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on 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

      dm_kiselevD 2 Replies Last reply
      0
      • SGaistS SGaist

        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.

        dm_kiselevD Offline
        dm_kiselevD Offline
        dm_kiselev
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on 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
          • SGaistS SGaist

            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.

            dm_kiselevD Offline
            dm_kiselevD Offline
            dm_kiselev
            wrote on 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
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on 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
              • dm_kiselevD Offline
                dm_kiselevD Offline
                dm_kiselev
                wrote on 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
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 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
                  • dm_kiselevD Offline
                    dm_kiselevD Offline
                    dm_kiselev
                    wrote on last edited by
                    #9

                    Thank you!

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on 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

                      • Login

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