[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kdev-xdebug] /: show error when opening port fails
From:       Niko Sams <niko.sams () gmail ! com>
Date:       2014-01-28 19:29:43
Message-ID: E1W8ELv-0003dj-Tm () scm ! kde ! org
[Download RAW message or body]

Git commit 3731c7f57bc493922a9c2f1463c8d011d5fc1b78 by Niko Sams.
Committed on 28/01/2014 at 19:29.
Pushed by nsams into branch 'master'.

show error when opening port fails

M  +14   -2    debugjob.cpp
M  +3    -1    debugsession.cpp
M  +1    -1    debugsession.h

http://commits.kde.org/kdev-xdebug/3731c7f57bc493922a9c2f1463c8d011d5fc1b78

diff --git a/debugjob.cpp b/debugjob.cpp
index 9ccad0d..87e589a 100644
--- a/debugjob.cpp
+++ b/debugjob.cpp
@@ -188,7 +188,14 @@ void XDebugJob::start()
     kDebug() << "launching?" << m_proc;
     if( m_proc )
     {
-        m_session->listenForConnection();
+        QString err;
+        if (!m_session->listenForConnection(err)) {
+            kWarning() << "listening for connection failed";
+            setError( -1 );
+            setErrorText( err );
+            emitResult();
+            return;
+        }
 
         startOutput();
         kDebug() << "starting" << m_proc->program().join(" ");
@@ -302,11 +309,16 @@ void XDebugBrowserJob::start()
         emitResult();
         return;
     }
-    if (!m_session->listenForConnection()) {
+
+    QString err;
+    if (!m_session->listenForConnection(err)) {
         kWarning() << "listening for connection failed";
+        setError( -1 );
+        setErrorText( err );
         emitResult();
         return;
     }
+
     KUrl url = m_url;
     url.addQueryItem("XDEBUG_SESSION_START", "kdev");
     if (m_browser.isEmpty()) {
diff --git a/debugsession.cpp b/debugsession.cpp
index 309e027..b594ec0 100644
--- a/debugsession.cpp
+++ b/debugsession.cpp
@@ -28,6 +28,7 @@
 
 #include <KDebug>
 #include <KProcess>
+#include <KLocalizedString>
 
 #include <interfaces/ilaunchconfiguration.h>
 #include <debugger/util/pathmappings.h>
@@ -63,7 +64,7 @@ void DebugSession::setAcceptMultipleConnections(bool v)
     m_acceptMultipleConnections = v;
 }
 
-bool DebugSession::listenForConnection()
+bool DebugSession::listenForConnection(QString& error)
 {
     Q_ASSERT(!m_server);
     m_server = new QTcpServer(this);
@@ -71,6 +72,7 @@ bool DebugSession::listenForConnection()
     if(m_server->listen(QHostAddress::Any, 9000)) {
         connect(m_server, SIGNAL(newConnection()), this, SLOT(incomingConnection()));
     } else {
+        error = i18n("Opening port 9000 failed: %1.", m_server->errorString());
         kWarning() << "Error" << m_server->errorString();
         delete m_server;
         m_server = 0;
diff --git a/debugsession.h b/debugsession.h
index 639a2e7..b2685be 100644
--- a/debugsession.h
+++ b/debugsession.h
@@ -45,7 +45,7 @@ public:
     void setLaunchConfiguration(KDevelop::ILaunchConfiguration *cfg);
     void setAcceptMultipleConnections(bool v);
 
-    bool listenForConnection();
+    bool listenForConnection(QString& error);
     
     bool waitForState(DebuggerState state, int msecs = 30000);
     bool waitForFinished(int msecs = 30000);
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic