diff options
author | Martin Kampas <martin.kampas@jolla.com> | 2016-11-16 15:49:46 +0100 |
---|---|---|
committer | Juergen Bocklage-Ryannel <juergen.bocklage-ryannel@pelagicore.com> | 2016-11-23 05:25:10 +0000 |
commit | de034fc669116d09a69dc6b467019e729243c243 (patch) | |
tree | b183a53beb139747b8c742e29aa46ee468e50e15 | |
parent | 364b4370f7712021a54e418a14cbc88f226e518b (diff) |
Allow to delay and repeate sending whole error log on connect
Change-Id: I27185aaafdb747a5b8ee2777b2184c96b7617d6b
Reviewed-by: Juergen Bocklage-Ryannel <juergen.bocklage-ryannel@pelagicore.com>
-rw-r--r-- | src/bench/hostmanager.cpp | 1 | ||||
-rw-r--r-- | src/remotereceiver.cpp | 32 | ||||
-rw-r--r-- | src/remotereceiver.h | 7 |
3 files changed, 35 insertions, 5 deletions
diff --git a/src/bench/hostmanager.cpp b/src/bench/hostmanager.cpp index 1d80eb4..546f46e 100644 --- a/src/bench/hostmanager.cpp +++ b/src/bench/hostmanager.cpp @@ -162,6 +162,7 @@ void HostManager::addHost(int index) LogView *view = new LogView(false, dock); connect(widget, SIGNAL(remoteLog(int,QString,QUrl,int,int)), view, SLOT(appendToLog(int,QString,QUrl,int,int))); connect(widget, SIGNAL(clearLog()), view, SLOT(clear())); + connect(widget, SIGNAL(connected()), view, SLOT(clear())); dock->setWidget(view); m_logList.append(dock); emit logWidgetAdded(dock); diff --git a/src/remotereceiver.cpp b/src/remotereceiver.cpp index d434a5b..7dbdb36 100644 --- a/src/remotereceiver.cpp +++ b/src/remotereceiver.cpp @@ -82,6 +82,7 @@ RemoteReceiver::RemoteReceiver(QObject *parent) , m_client(0) , m_bulkUpdateInProgress(false) , m_updateDocumentsOnConnectState(UpdateNotStarted) + , m_logSentPosition(0) { connect(m_server, SIGNAL(received(QString,QByteArray)), this, SLOT(handleCall(QString,QByteArray))); connect(m_server, SIGNAL(clientConnected(QTcpSocket*)), this, SLOT(onClientConnected(QTcpSocket*))); @@ -216,6 +217,7 @@ void RemoteReceiver::handleCall(const QString &method, const QByteArray &content emit endBulkUpdate(); if (m_updateDocumentsOnConnectState == UpdateStarted) { m_updateDocumentsOnConnectState = UpdateFinished; + finishConnectionInitialization(); emit updateDocumentsOnConnectFinished(true); } } else { @@ -293,21 +295,38 @@ void RemoteReceiver::onClientDisconnected(QTcpSocket *socket) } void RemoteReceiver::maybeStartUpdateDocumentsOnConnect() { - if (!(m_connectionOptions & UpdateDocumentsOnConnect)) - return; - - if (m_updateDocumentsOnConnectState == UpdateNotStarted) { + if (m_connectionOptions & UpdateDocumentsOnConnect + && m_updateDocumentsOnConnectState == UpdateNotStarted) { m_client->send("needsPublishWorkspace()", QByteArray()); m_updateDocumentsOnConnectState = UpdateRequested; + } else { + finishConnectionInitialization(); } } +void RemoteReceiver::finishConnectionInitialization() +{ + m_logSentPosition = 0; + flushLog(); +} + /*! * Called to send \a errors to remote for remote logging */ void RemoteReceiver::appendToLog(const QList<QQmlError> &errors) { - foreach (const QQmlError &err, errors) { + m_log.append(errors); + + if (!m_client) + return; + + flushLog(); +} + +void RemoteReceiver::flushLog() +{ + for (; m_logSentPosition < m_log.count(); ++m_logSentPosition) { + const QQmlError &err = m_log.at(m_logSentPosition); if (!err.isValid()) continue; @@ -337,6 +356,9 @@ void RemoteReceiver::appendToLog(const QList<QQmlError> &errors) */ void RemoteReceiver::clearLog() { + m_log.clear(); + m_logSentPosition = 0; + m_client->send("clearLog()", QByteArray()); } diff --git a/src/remotereceiver.h b/src/remotereceiver.h index 6877f50..b67d22d 100644 --- a/src/remotereceiver.h +++ b/src/remotereceiver.h @@ -103,6 +103,10 @@ private Q_SLOTS: void onClientConnected(QTcpSocket *socket); void onClientDisconnected(QTcpSocket *socket); void maybeStartUpdateDocumentsOnConnect(); + void finishConnectionInitialization(); + +private: + void flushLog(); private: IpcServer *m_server; @@ -117,6 +121,9 @@ private: ConnectionOptions m_connectionOptions; bool m_bulkUpdateInProgress; UpdateState m_updateDocumentsOnConnectState; + + QList<QQmlError> m_log; + int m_logSentPosition; }; Q_DECLARE_OPERATORS_FOR_FLAGS(RemoteReceiver::ConnectionOptions) |