From 53a9745c2a1dc4444c659b954d7d6f0588ffb5d7 Mon Sep 17 00:00:00 2001 From: Szymon Kłos Date: Thu, 11 Aug 2022 09:21:30 +0200 Subject: jsdialog: send MessageDialog on run not when built MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - some message boxes doesn't have correct notifier set initially - then when runAsync is called it is ok so we can remember widget Signed-off-by: Szymon Kłos Change-Id: I8ecf2d20ef4c2ebda3acf3b80bb390717b6caf6b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138107 Tested-by: Jenkins CollaboraOffice Reviewed-by: Michael Meeks --- vcl/jsdialog/jsdialogbuilder.cxx | 45 +++++++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 8 deletions(-) (limited to 'vcl/jsdialog/jsdialogbuilder.cxx') diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx index 11edcb26d94d..5c62face9769 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -1174,18 +1174,14 @@ weld::MessageDialog* JSInstanceBuilder::CreateMessageDialog(weld::Widget* pParen aJsonWriter.put("jsontype", "dialog"); std::unique_ptr message(aJsonWriter.extractData()); pNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_JSDIALOG, message.get()); + + std::string sWindowId = std::to_string(xMessageDialog->GetLOKWindowId()); + InsertWindowToMap(sWindowId); } xMessageDialog->SetLOKTunnelingState(false); - std::string sWindowId = std::to_string(xMessageDialog->GetLOKWindowId()); - InsertWindowToMap(sWindowId); - - weld::MessageDialog* pRet = new JSMessageDialog(xMessageDialog, nullptr, true); - - if (pRet) - RememberWidget(sWindowId, "__DIALOG__", pRet); - return pRet; + return new JSMessageDialog(xMessageDialog, nullptr, true); } JSDialog::JSDialog(JSDialogSender* pSender, ::Dialog* pDialog, SalInstanceBuilder* pBuilder, @@ -1421,6 +1417,39 @@ JSMessageDialog::~JSMessageDialog() JSInstanceBuilder::RemoveWindowWidget(m_sWindowId); } +void JSMessageDialog::RememberMessageDialog() +{ + static OStringLiteral sWidgetName = "__DIALOG__"; + std::string sWindowId = std::to_string(m_xMessageDialog->GetLOKWindowId()); + if (JSInstanceBuilder::FindWeldWidgetsMap(sWindowId, sWidgetName) != nullptr) + return; + + JSInstanceBuilder::InsertWindowToMap(sWindowId); + JSInstanceBuilder::RememberWidget(sWindowId, sWidgetName, this); +} + +bool JSMessageDialog::runAsync(std::shared_ptr aOwner, + const std::function& rEndDialogFn) +{ + bool bRet = SalInstanceMessageDialog::runAsync(aOwner, rEndDialogFn); + + RememberMessageDialog(); + sendFullUpdate(); + + return bRet; +} + +bool JSMessageDialog::runAsync(std::shared_ptr const& rxSelf, + const std::function& rEndDialogFn) +{ + bool bRet = SalInstanceMessageDialog::runAsync(rxSelf, rEndDialogFn); + + RememberMessageDialog(); + sendFullUpdate(); + + return bRet; +} + IMPL_LINK_NOARG(JSMessageDialog, OKHdl, weld::Button&, void) { response(RET_OK); } IMPL_LINK_NOARG(JSMessageDialog, CancelHdl, weld::Button&, void) { response(RET_CANCEL); } -- cgit