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. Qued Connection not queing...
Forum Updated to NodeBB v4.3 + New Features

Qued Connection not queing...

Scheduled Pinned Locked Moved General and Desktop
7 Posts 4 Posters 2.1k Views 1 Watching
  • 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 Offline
    S Offline
    SavageTwinky
    wrote on last edited by
    #1

    I'm having a strange issue with a connection not working properly as a queed connection. The idea is that we need to kill an QProcess, start another process, then allow the program to run the exit function. The app exit processes only when used as direct but this causes an issue with calling the exit prematurely.

    @ // notify windows ce we started
    int main()
    {
    test s;

    return a.exec();
    

    }
    @

    test.cpp
    @
    #include "StdAfx.h"

    test::test(QObject *parent) :
    QObject(parent)
    {
    firstApp = new QProcess(this);
    ahurarun = new QProcess(this);

    // connect both exits to appExit
    connect(firstApp, SIGNAL(finished(int,QProcess::ExitStatus)),
    this, SLOT(appExit(int,QProcess::ExitStatus)),
    Qt::QueuedConnection);

        firstApp->start("some app");
    

    }

    void test::startSecondApp()
    {
    if(QProcess::Running == firstApp->state())
    {
    // politely ask app to close
    firstApp->terminate();
    // then kill it if it doesn't
    QTimer::singleShot(10000, firstApp, SLOT(kill()));
    firstApp->waitForFinished(15000);
    }

    secondApp->start("some app");
    if(!secondApp->waitForStarted(30000))
    {

    }
    }

    void test::appExit(int exitCode, QProcess::ExitStatus exitStatus)
    {
    if(QObject::sender() == firstApp)
    {
    qDebug() << "firstApp exited early with code=" << QString::number(exitCode);

    if(QProcess::Running != secondApp->state())
    {
    // display some error for the app if it wasn't us
    }
    }
    }
    @

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SavageTwinky
      wrote on last edited by
      #2

      just to clarify

      this doesn't work
      @
      // connect both exits to appExit
      connect(firstApp, SIGNAL(finished(int,QProcess::ExitStatus)),
      this, SLOT(appExit(int,QProcess::ExitStatus)),
      Qt::QueuedConnection);
      @

      this does
      @
      // connect both exits to appExit
      connect(firstApp, SIGNAL(finished(int,QProcess::ExitStatus)),
      this, SLOT(appExit(int,QProcess::ExitStatus)));
      @

      1 Reply Last reply
      0
      • D Offline
        D Offline
        dbzhang800
        wrote on last edited by
        #3

        Maybe you should register the QProcess::ExitStatus type using qRegisterMetaType before it can be used in queuedConnection.

        1 Reply Last reply
        0
        • raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          there should be some output on the console in that case which tells you what went wrong.

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SavageTwinky
            wrote on last edited by
            #5

            Stupid question, why would i need to register QProcess::ExitStatus?

            Should it make a difference if I leave the arguments out?
            ie:
            @connect(firstApp, SIGNAL(finished()),
            this, SLOT(appExit()),
            Qt::QueuedConnection);
            @
            This doesn't work either..

            Also, my console is extremely limited, its on a WinCE device, and the only output I get is from my ::OutPutDebugStr(). (or something to that extent)

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SavageTwinky
              wrote on last edited by
              #6

              I ended up making a funny work around

              I connected a finished(int,QPRocess::exitStatus) to a queuedFinish(int,QProcess::exitStatus)

              and emited a appDone(QProcess*,int) as a queued connection to appExit(QProcess*,int)

              1 Reply Last reply
              0
              • A Offline
                A Offline
                andre
                wrote on last edited by
                #7

                I think the QMetaType registration would have been the easier and cleaner solution...

                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