Changeset View
Changeset View
Standalone View
Standalone View
debugsession.cpp
Show First 20 Lines • Show All 69 Lines • ▼ Show 20 Line(s) | |||||
70 | bool DebugSession::listenForConnection(QString& error) | 70 | bool DebugSession::listenForConnection(QString& error) | ||
71 | { | 71 | { | ||
72 | Q_ASSERT(!m_server); | 72 | Q_ASSERT(!m_server); | ||
73 | m_server = new QTcpServer(this); | 73 | m_server = new QTcpServer(this); | ||
74 | qCDebug(KDEV_PHP_DEBUGGER); | 74 | qCDebug(KDEV_PHP_DEBUGGER); | ||
75 | int remotePortSetting = m_launchConfiguration->config().readEntry("RemotePort", 9000); | 75 | int remotePortSetting = m_launchConfiguration->config().readEntry("RemotePort", 9000); | ||
76 | if (m_server->listen(QHostAddress::Any, remotePortSetting)) { | 76 | if (m_server->listen(QHostAddress::Any, remotePortSetting)) { | ||
77 | connect(m_server, &QTcpServer::newConnection, this, &DebugSession::incomingConnection); | 77 | connect(m_server, &QTcpServer::newConnection, this, &DebugSession::incomingConnection); | ||
78 | // avoid 'debug launch' button | ||||
79 | stateChanged(ActiveState); | ||||
78 | } else { | 80 | } else { | ||
79 | error = i18n("Opening port %1 failed: %2.", remotePortSetting, m_server->errorString()); | 81 | error = i18n("Opening port %1 failed: %2.", remotePortSetting, m_server->errorString()); | ||
80 | qCWarning(KDEV_PHP_DEBUGGER) << "Error" << m_server->errorString(); | 82 | qCWarning(KDEV_PHP_DEBUGGER) << "Error" << m_server->errorString(); | ||
81 | delete m_server; | 83 | delete m_server; | ||
82 | m_server = nullptr; | 84 | m_server = nullptr; | ||
83 | return false; | 85 | return false; | ||
84 | } | 86 | } | ||
85 | return m_server->isListening(); | 87 | return m_server->isListening(); | ||
Show All 32 Lines | 100 | { | |||
118 | } | 120 | } | ||
119 | } | 121 | } | ||
120 | 122 | | |||
121 | void DebugSession::connectionClosed() | 123 | void DebugSession::connectionClosed() | ||
122 | { | 124 | { | ||
123 | Q_ASSERT(sender() == m_connection); | 125 | Q_ASSERT(sender() == m_connection); | ||
124 | 126 | | |||
125 | if (m_acceptMultipleConnections && m_server && m_server->isListening() | 127 | if (m_acceptMultipleConnections && m_server && m_server->isListening() | ||
126 | && m_server->hasPendingConnections() | | |||
127 | ) { | 128 | ) { | ||
128 | m_connection->setState(DebugSession::NotStartedState); | 129 | // clear variable widget | ||
130 | emit stateChanged(NotStartedState); | ||||
131 | // avoid 'debug launch' button | ||||
132 | emit stateChanged(ActiveState); | ||||
129 | } else { | 133 | } else { | ||
130 | m_connection->setState(DebugSession::EndedState); | 134 | m_connection->setState(DebugSession::EndedState); | ||
131 | } | 135 | } | ||
132 | m_connection->deleteLater(); | 136 | m_connection->deleteLater(); | ||
133 | m_connection = nullptr; | 137 | m_connection = nullptr; | ||
134 | } | 138 | } | ||
135 | 139 | | |||
136 | void DebugSession::_stateChanged(KDevelop::IDebugSession::DebuggerState state) | 140 | void DebugSession::_stateChanged(KDevelop::IDebugSession::DebuggerState state) | ||
▲ Show 20 Lines • Show All 65 Lines • ▼ Show 20 Line(s) | |||||
202 | 206 | | |||
203 | void DebugSession::interruptDebugger() | 207 | void DebugSession::interruptDebugger() | ||
204 | { | 208 | { | ||
205 | } | 209 | } | ||
206 | 210 | | |||
207 | void DebugSession::stopDebugger() | 211 | void DebugSession::stopDebugger() | ||
208 | { | 212 | { | ||
209 | closeServer(); | 213 | closeServer(); | ||
210 | if (!m_connection || m_connection->currentState() == DebugSession::StoppedState || !m_connection->socket()) { | 214 | // finish debugger when no connection active | ||
215 | if ( state() == DebugSession::NotStartedState && !m_connection ) { | ||||
216 | stateChanged(DebugSession::EndedState); | ||||
211 | emit finished(); | 217 | emit finished(); | ||
212 | } else { | 218 | } else { | ||
213 | m_connection->sendCommand("stop"); | 219 | m_connection->sendCommand("stop"); | ||
214 | } | 220 | } | ||
215 | } | 221 | } | ||
216 | 222 | | |||
217 | void DebugSession::restartDebugger() | 223 | void DebugSession::restartDebugger() | ||
218 | { | 224 | { | ||
▲ Show 20 Lines • Show All 111 Lines • Show Last 20 Lines |