wsd: preserve close reason when disconnected from Kit

If we already have a closeReason, we should preserve
it upon disconnecting from the Kit instance. For
example when unloading, we request the disconnection
ourselves, so no need to clobber the real reason
for closing in that case.

Change-Id: Ie71faed5a4051659b426e3ba6bbf30950d21c328
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
This commit is contained in:
Ashod Nakashian 2022-12-16 06:15:05 -05:00 committed by Ashod Nakashian
parent ada1dd1a0b
commit 6abd8d114a

View file

@ -3437,9 +3437,18 @@ void DocumentBroker::closeDocument(const std::string& reason)
void DocumentBroker::disconnectedFromKit()
{
LOG_INF("DocBroker " << _docKey << " Disconnected from Kit. Flagging to close.");
_docState.setDisconnected();
closeDocument("docdisconnected");
_docState.setDisconnected(); // Always set the disconnected flag.
if (_closeReason.empty())
{
// If we have a reason to close, no advantage in clobbering it.
LOG_INF("DocBroker [" << _docKey << "] Disconnected from Kit. Flagging to close");
closeDocument("docdisconnected");
}
else
{
LOG_INF("DocBroker [" << _docKey << "] Disconnected from Kit while closing with reason ["
<< _closeReason << ']');
}
}
std::size_t DocumentBroker::broadcastMessage(const std::string& message) const