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. QStorageInfo and QPair Qt Reentrancy

QStorageInfo and QPair Qt Reentrancy

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 2 Posters 1.5k 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.
  • C Offline
    C Offline
    Crag_Hack
    wrote on last edited by
    #1

    Hi both QStorageInfo and QPair are not listed as Qt reentrant in the online API docs. I was previously using these in a worker thread but am feeling inclined to find other ways of doing things due to the lack of Qt reentrancy. As long as you only use these classes in one thread only (exclusively the worker thread or gui thread) is that safe behavior? Is the STL pair class qt reentrant and safe to use in a worker thread with its own object instances? Can I safely use QStorageInfo in my main thread to retrieve what I need (free space on drives) then pass that information to my worker thread? Anything else to know?
    Thanks!

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      std::pair works mostly the same as QPair.

      What exactly do you want to pass to your worker thread ?

      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
      • C Offline
        C Offline
        Crag_Hack
        wrote on last edited by
        #3

        Thanks SGaist. Is std::pair going to be qt reentrant? I am just passing free space amounts stored in integers as determined from QStorageInfo. So only the GUI thread is using the QStorageInfo object. Is this safe? Is this in general safe for any non-reentrant class to be accessed as long as it's only in the main gui thread? How about if only in the worker thread? I was trying the win32 API for the same but it's a hideous syntactical nightmare and it's giving me attitude. :)

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          There's no "Qt reentrant" concept. Qt is a C++ framework so the same rules applies to Qt as any other piece of code when dealing with threads.

          There's nothing to worry about when accessing something if you do it cleanly. An object that is created in one thread and is only accessed in that thread doesn't need to be something special. It's when you start to access or modify an object from several threads that you need to start worrying about side-effects.

          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
          • C Offline
            C Offline
            Crag_Hack
            wrote on last edited by
            #5

            So then is it safe to use QStorageInfo in a worker thread even though it's not reentrant as long as you only use it there?

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Yes it should be.

              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