Qt Forum

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

    Update: Forum Guidelines & Code of Conduct

    [Solved] QProcess and recursive QThread

    General and Desktop
    3
    6
    2726
    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.
    • T
      tucnak last edited by

      Hi, Qt Developer Network Community!

      I am on some step of developing new "Programming Contest Checking System". So I have to run many executable modules many times.

      I have an idea to use recursive QThread object.

      So I created model:

      Main Program creates QVector with tests and QStack with program's pathes.

      Load it into QThread.

      Recursive calls.

      Main object of thread return result of testing

      Will it do something bad with system? I need an advice.

      1 Reply Last reply Reply Quote 0
      • L
        lgeyer last edited by

        I'm not quite sure what the "recursive call" in your case could be - could you provide some pseudo-code or alike?

        Why do you need threads in the first place (the first rule of multithreaded programming is: don't do it)? External processes are asynchronous by nature and QProcess has an ansynchronous interface too.

        If you elaborate your initial problem statement we definitly can give you a more reasonable advice.

        1 Reply Last reply Reply Quote 0
        • T
          tucnak last edited by

          Thread run QProcess.

          Thread finish process.

          If !stack.isEmpty(): Thread call itself

          At the end, "parent" thread returns special vector

          1 Reply Last reply Reply Quote 0
          • T
            tucnak last edited by

            Thanks for attention.

            1 Reply Last reply Reply Quote 0
            • G
              goetz last edited by

              This design looks completely broken to me.

              As you do not start multiple threads, you do not need QThread at all. Just loop through your list. A recursive call is completely unnecessary in all cirumstances.

              Why do you want to do that recursively?
              What do you expect from the usage of QThread?

              http://www.catb.org/~esr/faqs/smart-questions.html

              1 Reply Last reply Reply Quote 0
              • L
                lgeyer last edited by

                [quote author="tucnak" date="1320351674"]

                Thread run QProcess.

                Thread finish process.

                [/quote]

                Well, you do not need threads to start external processes at all. A call to QProcess::start() immediately returns and the program runs as a completely independet process which doesn't influence or block yours in any way. If the state of the external process changes (aborted, finished) you are notified via signals.

                There is no need for recursion at all. Just loop through your list as Volker suggested.

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