Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qmldebug/qqmldebugconnection.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||
2 | - | |||||||||||||
3 | - | |||||||||||||
4 | - | |||||||||||||
5 | - | |||||||||||||
6 | static const int protocolVersion = 1; | - | ||||||||||||
7 | static const QString serverId = QLatin1String("QDeclarativeDebugServer"); | - | ||||||||||||
8 | static const QString clientId = QLatin1String("QDeclarativeDebugClient"); | - | ||||||||||||
9 | - | |||||||||||||
10 | class QQmlDebugConnectionPrivate : public QObjectPrivate | - | ||||||||||||
11 | { | - | ||||||||||||
12 | inline QQmlDebugConnection* q_func() { return static_cast<QQmlDebugConnection *>(q_ptr); } inline const QQmlDebugConnection* q_func() const { return static_cast<const QQmlDebugConnection *>(q_ptr); } friend class QQmlDebugConnection; | - | ||||||||||||
13 | - | |||||||||||||
14 | public: | - | ||||||||||||
15 | QQmlDebugConnectionPrivate(); | - | ||||||||||||
16 | QPacketProtocol *protocol = nullptr; | - | ||||||||||||
17 | QIODevice *device = nullptr; | - | ||||||||||||
18 | QLocalServer *server = nullptr; | - | ||||||||||||
19 | QEventLoop handshakeEventLoop; | - | ||||||||||||
20 | QTimer handshakeTimer; | - | ||||||||||||
21 | - | |||||||||||||
22 | bool gotHello = false; | - | ||||||||||||
23 | int currentDataStreamVersion = QDataStream::Qt_4_7; | - | ||||||||||||
24 | int maximumDataStreamVersion = QDataStream::Qt_DefaultCompiledVersion; | - | ||||||||||||
25 | QHash <QString, float> serverPlugins; | - | ||||||||||||
26 | QHash<QString, QQmlDebugClient *> plugins; | - | ||||||||||||
27 | QStringList removedPlugins; | - | ||||||||||||
28 | - | |||||||||||||
29 | void advertisePlugins(); | - | ||||||||||||
30 | void createProtocol(); | - | ||||||||||||
31 | void flush(); | - | ||||||||||||
32 | }; | - | ||||||||||||
33 | - | |||||||||||||
34 | QQmlDebugConnectionPrivate::QQmlDebugConnectionPrivate() | - | ||||||||||||
35 | { | - | ||||||||||||
36 | handshakeTimer.setSingleShot(true); | - | ||||||||||||
37 | handshakeTimer.setInterval(3000); | - | ||||||||||||
38 | } executed 550 times by 11 tests: end of block Executed by:
| 550 | ||||||||||||
39 | - | |||||||||||||
40 | void QQmlDebugConnectionPrivate::advertisePlugins() | - | ||||||||||||
41 | { | - | ||||||||||||
42 | QQmlDebugConnection * const q = q_func(); | - | ||||||||||||
43 | if (!q->isConnected()
| 3192-3208 | ||||||||||||
44 | return; executed 3192 times by 9 tests: return; Executed by:
| 3192 | ||||||||||||
45 | - | |||||||||||||
46 | QPacket pack(currentDataStreamVersion); | - | ||||||||||||
47 | pack << serverId << 1 << plugins.keys(); | - | ||||||||||||
48 | protocol->send(pack.data()); | - | ||||||||||||
49 | flush(); | - | ||||||||||||
50 | } executed 3208 times by 11 tests: end of block Executed by:
| 3208 | ||||||||||||
51 | - | |||||||||||||
52 | void QQmlDebugConnection::socketConnected() | - | ||||||||||||
53 | { | - | ||||||||||||
54 | QQmlDebugConnectionPrivate * const d = d_func(); | - | ||||||||||||
55 | QPacket pack(d->currentDataStreamVersion); | - | ||||||||||||
56 | pack << serverId << 0 << protocolVersion << d->plugins.keys() << d->maximumDataStreamVersion | - | ||||||||||||
57 | << true; | - | ||||||||||||
58 | d->protocol->send(pack.data()); | - | ||||||||||||
59 | d->flush(); | - | ||||||||||||
60 | } executed 547 times by 11 tests: end of block Executed by:
| 547 | ||||||||||||
61 | - | |||||||||||||
62 | void QQmlDebugConnection::socketDisconnected() | - | ||||||||||||
63 | { | - | ||||||||||||
64 | QQmlDebugConnectionPrivate * const d = d_func(); | - | ||||||||||||
65 | d->gotHello = false; | - | ||||||||||||
66 | disconnected(); | - | ||||||||||||
67 | } executed 11 times by 3 tests: end of block Executed by:
| 11 | ||||||||||||
68 | - | |||||||||||||
69 | void QQmlDebugConnection::protocolReadyRead() | - | ||||||||||||
70 | { | - | ||||||||||||
71 | QQmlDebugConnectionPrivate * const d = d_func(); | - | ||||||||||||
72 | if (!d->gotHello
| 544-7394 | ||||||||||||
73 | QPacket pack(d->currentDataStreamVersion, d->protocol->read()); | - | ||||||||||||
74 | QString name; | - | ||||||||||||
75 | - | |||||||||||||
76 | pack >> name; | - | ||||||||||||
77 | - | |||||||||||||
78 | bool validHello = false; | - | ||||||||||||
79 | if (name == clientId
| 0-544 | ||||||||||||
80 | int op = -1; | - | ||||||||||||
81 | pack >> op; | - | ||||||||||||
82 | if (op == 0
| 0-544 | ||||||||||||
83 | int version = -1; | - | ||||||||||||
84 | pack >> version; | - | ||||||||||||
85 | if (version == protocolVersion
| 0-544 | ||||||||||||
86 | QStringList pluginNames; | - | ||||||||||||
87 | QList<float> pluginVersions; | - | ||||||||||||
88 | pack >> pluginNames; | - | ||||||||||||
89 | if (!pack.atEnd()
| 0-544 | ||||||||||||
90 | pack >> pluginVersions; executed 544 times by 11 tests: pack >> pluginVersions; Executed by:
| 544 | ||||||||||||
91 | - | |||||||||||||
92 | const int pluginNamesSize = pluginNames.size(); | - | ||||||||||||
93 | const int pluginVersionsSize = pluginVersions.size(); | - | ||||||||||||
94 | for (int i = 0; i < pluginNamesSize
| 544-3274 | ||||||||||||
95 | float pluginVersion = 1.0; | - | ||||||||||||
96 | if (i < pluginVersionsSize
| 0-3274 | ||||||||||||
97 | pluginVersion = pluginVersions.at(i); executed 3274 times by 11 tests: pluginVersion = pluginVersions.at(i); Executed by:
| 3274 | ||||||||||||
98 | d->serverPlugins.insert(pluginNames.at(i), pluginVersion); | - | ||||||||||||
99 | } executed 3274 times by 11 tests: end of block Executed by:
| 3274 | ||||||||||||
100 | - | |||||||||||||
101 | pack >> d->currentDataStreamVersion; | - | ||||||||||||
102 | validHello = true; | - | ||||||||||||
103 | } executed 544 times by 11 tests: end of block Executed by:
| 544 | ||||||||||||
104 | } executed 544 times by 11 tests: end of block Executed by:
| 544 | ||||||||||||
105 | } executed 544 times by 11 tests: end of block Executed by:
| 544 | ||||||||||||
106 | - | |||||||||||||
107 | if (!validHello
| 0-544 | ||||||||||||
108 | QMessageLogger(__FILE__, 158, __PRETTY_FUNCTION__).warning("QQmlDebugConnection: Invalid hello message"); | - | ||||||||||||
109 | close(); | - | ||||||||||||
110 | return; never executed: return; | 0 | ||||||||||||
111 | } | - | ||||||||||||
112 | d->gotHello = true; | - | ||||||||||||
113 | connected(); | - | ||||||||||||
114 | - | |||||||||||||
115 | QHash<QString, QQmlDebugClient *>::Iterator iter = d->plugins.begin(); | - | ||||||||||||
116 | for (; iter != d->plugins.end()
| 544-3166 | ||||||||||||
117 | QQmlDebugClient::State newState = QQmlDebugClient::Unavailable; | - | ||||||||||||
118 | if (d->serverPlugins.contains(iter.key())
| 384-2782 | ||||||||||||
119 | newState = QQmlDebugClient::Enabled; executed 2782 times by 9 tests: newState = QQmlDebugClient::Enabled; Executed by:
| 2782 | ||||||||||||
120 | iter.value()->stateChanged(newState); | - | ||||||||||||
121 | } executed 3166 times by 9 tests: end of block Executed by:
| 3166 | ||||||||||||
122 | - | |||||||||||||
123 | d->handshakeTimer.stop(); | - | ||||||||||||
124 | d->handshakeEventLoop.quit(); | - | ||||||||||||
125 | } executed 544 times by 11 tests: end of block Executed by:
| 544 | ||||||||||||
126 | - | |||||||||||||
127 | while (d->protocol->packetsAvailable()
| 7394-7938 | ||||||||||||
128 | QPacket pack(d->currentDataStreamVersion, d->protocol->read()); | - | ||||||||||||
129 | QString name; | - | ||||||||||||
130 | pack >> name; | - | ||||||||||||
131 | - | |||||||||||||
132 | if (name == clientId
| 0-7394 | ||||||||||||
133 | int op = -1; | - | ||||||||||||
134 | pack >> op; | - | ||||||||||||
135 | - | |||||||||||||
136 | if (op == 1
| 0 | ||||||||||||
137 | - | |||||||||||||
138 | QHash<QString, float> oldServerPlugins = d->serverPlugins; | - | ||||||||||||
139 | d->serverPlugins.clear(); | - | ||||||||||||
140 | - | |||||||||||||
141 | QStringList pluginNames; | - | ||||||||||||
142 | QList<float> pluginVersions; | - | ||||||||||||
143 | pack >> pluginNames; | - | ||||||||||||
144 | if (!pack.atEnd()
| 0 | ||||||||||||
145 | pack >> pluginVersions; never executed: pack >> pluginVersions; | 0 | ||||||||||||
146 | - | |||||||||||||
147 | const int pluginNamesSize = pluginNames.size(); | - | ||||||||||||
148 | const int pluginVersionsSize = pluginVersions.size(); | - | ||||||||||||
149 | for (int i = 0; i < pluginNamesSize
| 0 | ||||||||||||
150 | float pluginVersion = 1.0; | - | ||||||||||||
151 | if (i < pluginVersionsSize
| 0 | ||||||||||||
152 | pluginVersion = pluginVersions.at(i); never executed: pluginVersion = pluginVersions.at(i); | 0 | ||||||||||||
153 | d->serverPlugins.insert(pluginNames.at(i), pluginVersion); | - | ||||||||||||
154 | } never executed: end of block | 0 | ||||||||||||
155 | - | |||||||||||||
156 | QHash<QString, QQmlDebugClient *>::Iterator iter = d->plugins.begin(); | - | ||||||||||||
157 | for (; iter != d->plugins.end()
| 0 | ||||||||||||
158 | const QString pluginName = iter.key(); | - | ||||||||||||
159 | QQmlDebugClient::State newSate = QQmlDebugClient::Unavailable; | - | ||||||||||||
160 | if (d->serverPlugins.contains(pluginName)
| 0 | ||||||||||||
161 | newSate = QQmlDebugClient::Enabled; never executed: newSate = QQmlDebugClient::Enabled; | 0 | ||||||||||||
162 | - | |||||||||||||
163 | if (oldServerPlugins.contains(pluginName)
| 0 | ||||||||||||
164 | != d->serverPlugins.contains(pluginName)
| 0 | ||||||||||||
165 | iter.value()->stateChanged(newSate); | - | ||||||||||||
166 | } never executed: end of block | 0 | ||||||||||||
167 | } never executed: end of block | 0 | ||||||||||||
168 | } never executed: else {end of block | 0 | ||||||||||||
169 | QMessageLogger(__FILE__, 219, __PRETTY_FUNCTION__).warning() << "QQmlDebugConnection: Unknown control message id" << op; | - | ||||||||||||
170 | } never executed: end of block | 0 | ||||||||||||
171 | } else { | - | ||||||||||||
172 | QHash<QString, QQmlDebugClient *>::Iterator iter = d->plugins.find(name); | - | ||||||||||||
173 | if (iter == d->plugins.end()
| 409-6985 | ||||||||||||
174 | - | |||||||||||||
175 | - | |||||||||||||
176 | if (!d->removedPlugins.contains(name)
| 0-409 | ||||||||||||
177 | QMessageLogger(__FILE__, 227, __PRETTY_FUNCTION__).warning() << "QQmlDebugConnection: Message received for missing plugin" never executed: QMessageLogger(__FILE__, 227, __PRETTY_FUNCTION__).warning() << "QQmlDebugConnection: Message received for missing plugin" << name; | 0 | ||||||||||||
178 | << name; never executed: QMessageLogger(__FILE__, 227, __PRETTY_FUNCTION__).warning() << "QQmlDebugConnection: Message received for missing plugin" << name; | 0 | ||||||||||||
179 | } executed 409 times by 4 tests: else {end of block Executed by:
| 409 | ||||||||||||
180 | QQmlDebugClient *client = *iter; | - | ||||||||||||
181 | QByteArray message; | - | ||||||||||||
182 | while (!pack.atEnd()
| 3697-6985 | ||||||||||||
183 | pack >> message; | - | ||||||||||||
184 | client->messageReceived(message); | - | ||||||||||||
185 | } executed 3697 times by 11 tests: end of block Executed by:
| 3697 | ||||||||||||
186 | } executed 6985 times by 11 tests: end of block Executed by:
| 6985 | ||||||||||||
187 | } | - | ||||||||||||
188 | } | - | ||||||||||||
189 | } executed 7938 times by 11 tests: end of block Executed by:
| 7938 | ||||||||||||
190 | - | |||||||||||||
191 | void QQmlDebugConnection::handshakeTimeout() | - | ||||||||||||
192 | { | - | ||||||||||||
193 | QQmlDebugConnectionPrivate * const d = d_func(); | - | ||||||||||||
194 | if (!d->gotHello
| 0-3 | ||||||||||||
195 | QMessageLogger(__FILE__, 245, __PRETTY_FUNCTION__).warning() << "QQmlDebugConnection: Did not get handshake answer in time"; | - | ||||||||||||
196 | d->handshakeEventLoop.quit(); | - | ||||||||||||
197 | } executed 3 times by 2 tests: end of block Executed by:
| 3 | ||||||||||||
198 | } executed 3 times by 2 tests: end of block Executed by:
| 3 | ||||||||||||
199 | - | |||||||||||||
200 | QQmlDebugConnection::QQmlDebugConnection(QObject *parent) : | - | ||||||||||||
201 | QObject(*(new QQmlDebugConnectionPrivate), parent) | - | ||||||||||||
202 | { | - | ||||||||||||
203 | QQmlDebugConnectionPrivate * const d = d_func(); | - | ||||||||||||
204 | connect(&d->handshakeTimer, &QTimer::timeout, this, &QQmlDebugConnection::handshakeTimeout); | - | ||||||||||||
205 | } executed 550 times by 11 tests: end of block Executed by:
| 550 | ||||||||||||
206 | - | |||||||||||||
207 | QQmlDebugConnection::~QQmlDebugConnection() | - | ||||||||||||
208 | { | - | ||||||||||||
209 | QQmlDebugConnectionPrivate * const d = d_func(); | - | ||||||||||||
210 | QHash<QString, QQmlDebugClient*>::iterator iter = d->plugins.begin(); | - | ||||||||||||
211 | for (; iter != d->plugins.end()
| 4-550 | ||||||||||||
212 | iter.value()->stateChanged(QQmlDebugClient::NotConnected); executed 4 times by 2 tests: iter.value()->stateChanged(QQmlDebugClient::NotConnected); Executed by:
| 4 | ||||||||||||
213 | } executed 550 times by 11 tests: end of block Executed by:
| 550 | ||||||||||||
214 | - | |||||||||||||
215 | int QQmlDebugConnection::currentDataStreamVersion() const | - | ||||||||||||
216 | { | - | ||||||||||||
217 | const QQmlDebugConnectionPrivate * const d = d_func(); | - | ||||||||||||
218 | return executed 5415 times by 8 tests: d->currentDataStreamVersion;return d->currentDataStreamVersion; Executed by:
executed 5415 times by 8 tests: return d->currentDataStreamVersion; Executed by:
| 5415 | ||||||||||||
219 | } | - | ||||||||||||
220 | - | |||||||||||||
221 | void QQmlDebugConnection::setMaximumDataStreamVersion(int maximumVersion) | - | ||||||||||||
222 | { | - | ||||||||||||
223 | QQmlDebugConnectionPrivate * const d = d_func(); | - | ||||||||||||
224 | d->maximumDataStreamVersion = maximumVersion; | - | ||||||||||||
225 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||
226 | - | |||||||||||||
227 | bool QQmlDebugConnection::isConnected() const | - | ||||||||||||
228 | { | - | ||||||||||||
229 | const QQmlDebugConnectionPrivate * const d = d_func(); | - | ||||||||||||
230 | return executed 26853 times by 11 tests: d->gotHello;return d->gotHello; Executed by:
executed 26853 times by 11 tests: return d->gotHello; Executed by:
| 26853 | ||||||||||||
231 | } | - | ||||||||||||
232 | - | |||||||||||||
233 | bool QQmlDebugConnection::isConnecting() const | - | ||||||||||||
234 | { | - | ||||||||||||
235 | const QQmlDebugConnectionPrivate * const d = d_func(); | - | ||||||||||||
236 | return never executed: !d->gotHello && d->device;return !d->gotHello && d->device; never executed: return !d->gotHello && d->device; | 0 | ||||||||||||
237 | } | - | ||||||||||||
238 | - | |||||||||||||
239 | void QQmlDebugConnection::close() | - | ||||||||||||
240 | { | - | ||||||||||||
241 | QQmlDebugConnectionPrivate * const d = d_func(); | - | ||||||||||||
242 | if (d->gotHello
| 0-2 | ||||||||||||
243 | d->gotHello = false; | - | ||||||||||||
244 | d->device->close(); | - | ||||||||||||
245 | - | |||||||||||||
246 | QHash<QString, QQmlDebugClient*>::iterator iter = d->plugins.begin(); | - | ||||||||||||
247 | for (; iter != d->plugins.end()
| 0-2 | ||||||||||||
248 | iter.value()->stateChanged(QQmlDebugClient::NotConnected); never executed: iter.value()->stateChanged(QQmlDebugClient::NotConnected); | 0 | ||||||||||||
249 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||
250 | - | |||||||||||||
251 | if (d->device
| 0-2 | ||||||||||||
252 | d->device->deleteLater(); | - | ||||||||||||
253 | d->device = nullptr; | - | ||||||||||||
254 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||
255 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||
256 | - | |||||||||||||
257 | bool QQmlDebugConnection::waitForConnected(int msecs) | - | ||||||||||||
258 | { | - | ||||||||||||
259 | QQmlDebugConnectionPrivate * const d = d_func(); | - | ||||||||||||
260 | QAbstractSocket *socket = qobject_cast<QAbstractSocket*>(d->device); | - | ||||||||||||
261 | if (!socket
| 2-67 | ||||||||||||
262 | if (!d->server
| 0-2 | ||||||||||||
263 | !d->server->waitForNewConnection(msecs)
| 0-2 | ||||||||||||
264 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
265 | } executed 2 times by 1 test: else if (!socket->waitForConnected(msecs)end of block Executed by:
| 0-67 | ||||||||||||
266 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
267 | } | - | ||||||||||||
268 | - | |||||||||||||
269 | d->handshakeTimer.start(); | - | ||||||||||||
270 | d->handshakeEventLoop.exec(); | - | ||||||||||||
271 | return executed 69 times by 6 tests: d->gotHello;return d->gotHello; Executed by:
executed 69 times by 6 tests: return d->gotHello; Executed by:
| 69 | ||||||||||||
272 | } | - | ||||||||||||
273 | - | |||||||||||||
274 | QQmlDebugClient *QQmlDebugConnection::client(const QString &name) const | - | ||||||||||||
275 | { | - | ||||||||||||
276 | const QQmlDebugConnectionPrivate * const d = d_func(); | - | ||||||||||||
277 | return executed 3696 times by 8 tests: d->plugins.value(name, 0);return d->plugins.value(name, 0); Executed by:
executed 3696 times by 8 tests: return d->plugins.value(name, 0); Executed by:
| 3696 | ||||||||||||
278 | } | - | ||||||||||||
279 | - | |||||||||||||
280 | bool QQmlDebugConnection::addClient(const QString &name, QQmlDebugClient *client) | - | ||||||||||||
281 | { | - | ||||||||||||
282 | QQmlDebugConnectionPrivate * const d = d_func(); | - | ||||||||||||
283 | if (d->plugins.contains(name)
| 4-3202 | ||||||||||||
284 | return executed 4 times by 2 tests: false;return false; Executed by:
executed 4 times by 2 tests: return false; Executed by:
| 4 | ||||||||||||
285 | d->removedPlugins.removeAll(name); | - | ||||||||||||
286 | d->plugins.insert(name, client); | - | ||||||||||||
287 | d->advertisePlugins(); | - | ||||||||||||
288 | return executed 3202 times by 11 tests: true;return true; Executed by:
executed 3202 times by 11 tests: return true; Executed by:
| 3202 | ||||||||||||
289 | } | - | ||||||||||||
290 | - | |||||||||||||
291 | bool QQmlDebugConnection::removeClient(const QString &name) | - | ||||||||||||
292 | { | - | ||||||||||||
293 | QQmlDebugConnectionPrivate * const d = d_func(); | - | ||||||||||||
294 | if (!d->plugins.contains(name)
| 0-3198 | ||||||||||||
295 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
296 | d->plugins.remove(name); | - | ||||||||||||
297 | d->removedPlugins.append(name); | - | ||||||||||||
298 | d->advertisePlugins(); | - | ||||||||||||
299 | return executed 3198 times by 11 tests: true;return true; Executed by:
executed 3198 times by 11 tests: return true; Executed by:
| 3198 | ||||||||||||
300 | } | - | ||||||||||||
301 | - | |||||||||||||
302 | float QQmlDebugConnection::serviceVersion(const QString &serviceName) const | - | ||||||||||||
303 | { | - | ||||||||||||
304 | const QQmlDebugConnectionPrivate * const d = d_func(); | - | ||||||||||||
305 | return executed 18603 times by 11 tests: d->serverPlugins.value(serviceName, -1);return d->serverPlugins.value(serviceName, -1); Executed by:
executed 18603 times by 11 tests: return d->serverPlugins.value(serviceName, -1); Executed by:
| 18603 | ||||||||||||
306 | } | - | ||||||||||||
307 | - | |||||||||||||
308 | bool QQmlDebugConnection::sendMessage(const QString &name, const QByteArray &message) | - | ||||||||||||
309 | { | - | ||||||||||||
310 | QQmlDebugConnectionPrivate * const d = d_func(); | - | ||||||||||||
311 | if (!isConnected()
| 0-1782 | ||||||||||||
312 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
313 | - | |||||||||||||
314 | QPacket pack(d->currentDataStreamVersion); | - | ||||||||||||
315 | pack << name << message; | - | ||||||||||||
316 | d->protocol->send(pack.data()); | - | ||||||||||||
317 | d->flush(); | - | ||||||||||||
318 | - | |||||||||||||
319 | return executed 1782 times by 9 tests: true;return true; Executed by:
executed 1782 times by 9 tests: return true; Executed by:
| 1782 | ||||||||||||
320 | } | - | ||||||||||||
321 | - | |||||||||||||
322 | void QQmlDebugConnectionPrivate::flush() | - | ||||||||||||
323 | { | - | ||||||||||||
324 | if (QAbstractSocket *socket = qobject_cast<QAbstractSocket *>(device)
| 18-5519 | ||||||||||||
325 | socket->flush(); executed 5519 times by 10 tests: socket->flush(); Executed by:
| 5519 | ||||||||||||
326 | else if (QLocalSocket *socket = qobject_cast<QLocalSocket *>(device)
| 0-18 | ||||||||||||
327 | socket->flush(); executed 18 times by 1 test: socket->flush(); Executed by:
| 18 | ||||||||||||
328 | } executed 5537 times by 11 tests: end of block Executed by:
| 5537 | ||||||||||||
329 | - | |||||||||||||
330 | void QQmlDebugConnection::connectToHost(const QString &hostName, quint16 port) | - | ||||||||||||
331 | { | - | ||||||||||||
332 | QQmlDebugConnectionPrivate * const d = d_func(); | - | ||||||||||||
333 | if (d->gotHello
| 0-545 | ||||||||||||
334 | close(); never executed: close(); | 0 | ||||||||||||
335 | QTcpSocket *socket = new QTcpSocket(this); | - | ||||||||||||
336 | d->device = socket; | - | ||||||||||||
337 | d->createProtocol(); | - | ||||||||||||
338 | connect(socket, &QAbstractSocket::disconnected, this, &QQmlDebugConnection::socketDisconnected); | - | ||||||||||||
339 | connect(socket, &QAbstractSocket::connected, this, &QQmlDebugConnection::socketConnected); | - | ||||||||||||
340 | connect(socket, static_cast<void(QAbstractSocket::*)(QAbstractSocket::SocketError)>( | - | ||||||||||||
341 | &QAbstractSocket::error), this, &QQmlDebugConnection::socketError); | - | ||||||||||||
342 | connect(socket, &QAbstractSocket::stateChanged, this, &QQmlDebugConnection::socketStateChanged); | - | ||||||||||||
343 | socket->connectToHost(hostName, port); | - | ||||||||||||
344 | } executed 545 times by 10 tests: end of block Executed by:
| 545 | ||||||||||||
345 | - | |||||||||||||
346 | void QQmlDebugConnection::startLocalServer(const QString &fileName) | - | ||||||||||||
347 | { | - | ||||||||||||
348 | QQmlDebugConnectionPrivate * const d = d_func(); | - | ||||||||||||
349 | if (d->gotHello
| 0-2 | ||||||||||||
350 | close(); never executed: close(); | 0 | ||||||||||||
351 | if (d->server
| 0-2 | ||||||||||||
352 | d->server->deleteLater(); never executed: d->server->deleteLater(); | 0 | ||||||||||||
353 | d->server = new QLocalServer(this); | - | ||||||||||||
354 | - | |||||||||||||
355 | connect(d->server, &QLocalServer::newConnection, | - | ||||||||||||
356 | this, &QQmlDebugConnection::newConnection, Qt::QueuedConnection); | - | ||||||||||||
357 | d->server->listen(fileName); | - | ||||||||||||
358 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||
359 | - | |||||||||||||
360 | class LocalSocketSignalTranslator : public QObject | - | ||||||||||||
361 | { | - | ||||||||||||
362 | public: | - | ||||||||||||
363 | #pragma GCC diagnostic push | - | ||||||||||||
364 | - | |||||||||||||
365 | #pragma GCC diagnostic ignored "-Wsuggest-override" | - | ||||||||||||
366 | static const QMetaObject staticMetaObject; virtual const QMetaObject *metaObject() const; virtual void *qt_metacast(const char *); virtual int qt_metacall(QMetaObject::Call, int, void **); static inline QString tr(const char *s, const char *c = nullptr, int n = -1) { return staticMetaObject.tr(s, c, n); } __attribute__ ((__deprecated__)) static inline QString trUtf8(const char *s, const char *c = nullptr, int n = -1) { return staticMetaObject.tr(s, c, n); } private: | - | ||||||||||||
367 | #pragma GCC diagnostic ignored "-Wattributes" | - | ||||||||||||
368 | __attribute__((visibility("hidden"))) static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); | - | ||||||||||||
369 | #pragma GCC diagnostic pop | - | ||||||||||||
370 | struct QPrivateSignal {}; | - | ||||||||||||
371 | public: | - | ||||||||||||
372 | LocalSocketSignalTranslator(QLocalSocket *parent) : QObject(parent) | - | ||||||||||||
373 | { | - | ||||||||||||
374 | connect(parent, &QLocalSocket::stateChanged, | - | ||||||||||||
375 | this, &LocalSocketSignalTranslator::onStateChanged); | - | ||||||||||||
376 | connect(parent, static_cast<void(QLocalSocket::*)(QLocalSocket::LocalSocketError)>( | - | ||||||||||||
377 | &QLocalSocket::error), this, &LocalSocketSignalTranslator::onError); | - | ||||||||||||
378 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||
379 | - | |||||||||||||
380 | void onError(QLocalSocket::LocalSocketError error) | - | ||||||||||||
381 | { | - | ||||||||||||
382 | socketError(static_cast<QAbstractSocket::SocketError>(error)); | - | ||||||||||||
383 | } never executed: end of block | 0 | ||||||||||||
384 | - | |||||||||||||
385 | void onStateChanged(QLocalSocket::LocalSocketState state) | - | ||||||||||||
386 | { | - | ||||||||||||
387 | socketStateChanged(static_cast<QAbstractSocket::SocketState>(state)); | - | ||||||||||||
388 | } executed 4 times by 1 test: end of block Executed by:
| 4 | ||||||||||||
389 | - | |||||||||||||
390 | public : | - | ||||||||||||
391 | void socketError(QAbstractSocket::SocketError error); | - | ||||||||||||
392 | void socketStateChanged(QAbstractSocket::SocketState state); | - | ||||||||||||
393 | }; | - | ||||||||||||
394 | - | |||||||||||||
395 | void QQmlDebugConnection::newConnection() | - | ||||||||||||
396 | { | - | ||||||||||||
397 | QQmlDebugConnectionPrivate * const d = d_func(); | - | ||||||||||||
398 | delete d->device; | - | ||||||||||||
399 | QLocalSocket *socket = d->server->nextPendingConnection(); | - | ||||||||||||
400 | d->server->close(); | - | ||||||||||||
401 | d->device = socket; | - | ||||||||||||
402 | d->createProtocol(); | - | ||||||||||||
403 | connect(socket, &QLocalSocket::disconnected, this, &QQmlDebugConnection::socketDisconnected); | - | ||||||||||||
404 | LocalSocketSignalTranslator *translator = new LocalSocketSignalTranslator(socket); | - | ||||||||||||
405 | - | |||||||||||||
406 | connect(translator, &LocalSocketSignalTranslator::socketError, | - | ||||||||||||
407 | this, &QQmlDebugConnection::socketError); | - | ||||||||||||
408 | connect(translator, &LocalSocketSignalTranslator::socketStateChanged, | - | ||||||||||||
409 | this, &QQmlDebugConnection::socketStateChanged); | - | ||||||||||||
410 | socketConnected(); | - | ||||||||||||
411 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||
412 | - | |||||||||||||
413 | void QQmlDebugConnectionPrivate::createProtocol() | - | ||||||||||||
414 | { | - | ||||||||||||
415 | QQmlDebugConnection * const q = q_func(); | - | ||||||||||||
416 | delete protocol; | - | ||||||||||||
417 | protocol = new QPacketProtocol(device, q); | - | ||||||||||||
418 | QObject::connect(protocol, &QPacketProtocol::readyRead, | - | ||||||||||||
419 | q, &QQmlDebugConnection::protocolReadyRead); | - | ||||||||||||
420 | } executed 547 times by 11 tests: end of block Executed by:
| 547 | ||||||||||||
421 | - | |||||||||||||
422 | - | |||||||||||||
423 | - | |||||||||||||
424 | - | |||||||||||||
Switch to Source code | Preprocessed file |