From 8b71ea32134b2eeff2a69f1113744bc11a14c6b3 Mon Sep 17 00:00:00 2001 From: Szymon Kłos Date: Wed, 9 Dec 2020 12:00:59 +0100 Subject: jsdialog: properly destroy JsonWriter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ic9bc13b60284ece25b6c72326fd2185d14e17029 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107466 Tested-by: Szymon Kłos Reviewed-by: Szymon Kłos --- vcl/jsdialog/jsdialogbuilder.cxx | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'vcl/jsdialog') diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx index 50954dcec727..0b439f57e2f3 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -40,21 +40,28 @@ JSDialogNotifyIdle::JSDialogNotifyIdle(VclPtr aNotifierWindow, void JSDialogNotifyIdle::ForceUpdate() { m_bForce = true; } -void JSDialogNotifyIdle::send(std::unique_ptr aJsonWriter) +void JSDialogNotifyIdle::send(tools::JsonWriter& aJsonWriter) { if (!m_aNotifierWindow) + { + free(aJsonWriter.extractData()); return; + } const vcl::ILibreOfficeKitNotifier* pNotifier = m_aNotifierWindow->GetLOKNotifier(); if (pNotifier) { - if (m_bForce || !aJsonWriter->isDataEquals(m_LastNotificationMessage)) + if (m_bForce || !aJsonWriter.isDataEquals(m_LastNotificationMessage)) { m_bForce = false; - m_LastNotificationMessage = aJsonWriter->extractAsStdString(); + m_LastNotificationMessage = aJsonWriter.extractAsStdString(); pNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_JSDIALOG, m_LastNotificationMessage.c_str()); } + else + { + free(aJsonWriter.extractData()); + } } } @@ -101,9 +108,9 @@ std::unique_ptr JSDialogNotifyIdle::generateCloseMessage() co return aJsonWriter; } -void JSDialogNotifyIdle::Invoke() { send(dumpStatus()); } +void JSDialogNotifyIdle::Invoke() { send(*dumpStatus()); } -void JSDialogNotifyIdle::sendClose() { send(generateCloseMessage()); } +void JSDialogNotifyIdle::sendClose() { send(*generateCloseMessage()); } void JSDialogSender::notifyDialogState(bool bForce) { -- cgit v1.2.3