src/declarative/debugger/qdeclarativedebugservice.cpp
changeset 33 3e2da88830cd
parent 30 5dc02b23752f
child 37 758a864f9613
equal deleted inserted replaced
30:5dc02b23752f 33:3e2da88830cd
    59     Q_DECLARE_PRIVATE(QDeclarativeDebugServer)
    59     Q_DECLARE_PRIVATE(QDeclarativeDebugServer)
    60     Q_DISABLE_COPY(QDeclarativeDebugServer)
    60     Q_DISABLE_COPY(QDeclarativeDebugServer)
    61 public:
    61 public:
    62     static QDeclarativeDebugServer *instance();
    62     static QDeclarativeDebugServer *instance();
    63     void listen();
    63     void listen();
       
    64     void waitForConnection();
    64     bool hasDebuggingClient() const;
    65     bool hasDebuggingClient() const;
    65 
    66 
    66 private Q_SLOTS:
    67 private Q_SLOTS:
    67     void readyRead();
    68     void readyRead();
    68     void newConnection();
    69     void newConnection();
   113         qWarning("QDeclarativeDebugServer: Waiting for connection on port %d...", d->port);
   114         qWarning("QDeclarativeDebugServer: Waiting for connection on port %d...", d->port);
   114     else
   115     else
   115         qWarning("QDeclarativeDebugServer: Unable to listen on port %d", d->port);
   116         qWarning("QDeclarativeDebugServer: Unable to listen on port %d", d->port);
   116 }
   117 }
   117 
   118 
       
   119 void QDeclarativeDebugServer::waitForConnection()
       
   120 {
       
   121     Q_D(QDeclarativeDebugServer);
       
   122     d->tcpServer->waitForNewConnection(-1);
       
   123 }
       
   124 
   118 void QDeclarativeDebugServer::newConnection()
   125 void QDeclarativeDebugServer::newConnection()
   119 {
   126 {
   120     Q_D(QDeclarativeDebugServer);
   127     Q_D(QDeclarativeDebugServer);
   121 
   128 
   122     if (d->connection) {
   129     if (d->connection) {
   142     static QDeclarativeDebugServer *server = 0;
   149     static QDeclarativeDebugServer *server = 0;
   143 
   150 
   144     if (!envTested) {
   151     if (!envTested) {
   145         envTested = true;
   152         envTested = true;
   146         QByteArray env = qgetenv("QML_DEBUG_SERVER_PORT");
   153         QByteArray env = qgetenv("QML_DEBUG_SERVER_PORT");
       
   154         QByteArray block = qgetenv("QML_DEBUG_SERVER_BLOCK");
   147 
   155 
   148         bool ok = false;
   156         bool ok = false;
   149         int port = env.toInt(&ok);
   157         int port = env.toInt(&ok);
   150 
   158 
   151         if (ok && port > 1024) {
   159         if (ok && port > 1024) {
   152             server = new QDeclarativeDebugServer(port);
   160             server = new QDeclarativeDebugServer(port);
   153             server->listen();
   161             server->listen();
       
   162             if (!block.isEmpty()) {
       
   163                 server->waitForConnection();
       
   164             }
   154         }
   165         }
   155     }
   166     }
   156 
   167 
   157     return server;
   168     return server;
   158 }
   169 }