Qt Forum

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

    Update: Forum Guidelines & Code of Conduct

    Solved Using data from different thread

    General and Desktop
    2
    3
    161
    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.
    • S
      Svirac last edited by

      Hi guys,

      Sorry for if this question was already occurred, it is related to Thread affinity.
      I read "you are doing it wrong" and I am following principles stated there.
      I don't experience app crashes, but just want to be sure.

      Is it safe to directly call data from another thread ? I am aware that I need to use mutex in that case.

      I have a situation that in main thread I am loading Settings from configuration file, and those data I am calling directly in separate thread (when thread is already moved/started).

      1 Reply Last reply Reply Quote 0
      • sierdzio
        sierdzio Moderators last edited by

        Yes it's OK. If you are 100% sure you won't change that config during runtime, you can even do it without a mutex (but that is quite dangerous for hopefully obvious reasons).

        (Z(:^

        1 Reply Last reply Reply Quote 5
        • S
          Svirac last edited by

          Thanks for a replay, I appreciate it...

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